Skip to content

Commit d82e1c8

Browse files
authored
Fix: Premature configuration of default_yaml caused to be ineffective (#653)
1 parent e697ace commit d82e1c8

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

ms_agent/agent/base.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) Alibaba, Inc. and its affiliates.
22
import importlib
33
import inspect
4+
import os
45
import sys
56
from abc import abstractmethod
67
from typing import Dict, List, Optional, Union
@@ -10,6 +11,9 @@
1011
from ms_agent.llm import Message
1112
from omegaconf import DictConfig
1213

14+
DEFAULT_YAML = os.path.join(
15+
os.path.dirname(os.path.abspath(__file__)), 'agent.yaml')
16+
1317

1418
class Agent:
1519
"""
@@ -37,10 +41,13 @@ def __init__(self,
3741
env: Optional[Dict[str, str]] = None,
3842
tag: Optional[str] = None,
3943
trust_remote_code: bool = False):
40-
if config_dir_or_id is None:
44+
if config_dir_or_id is not None:
45+
self.config: DictConfig = Config.from_task(config_dir_or_id, env)
46+
elif config is not None:
4147
self.config: DictConfig = config
4248
else:
43-
self.config: DictConfig = Config.from_task(config_dir_or_id, env)
49+
self.config: DictConfig = Config.from_task(DEFAULT_YAML)
50+
4451
if tag is None:
4552
self.tag = getattr(config, 'tag', None) or self.DEFAULT_TAG
4653
else:

ms_agent/agent/llm_agent.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
from .plan.utils import planer_mapping
2525
from .runtime import Runtime
2626

27-
DEFAULT_YAML = os.path.join(
28-
os.path.dirname(os.path.abspath(__file__)), 'agent.yaml')
29-
3027

3128
class LLMAgent(Agent):
3229
"""
@@ -51,7 +48,7 @@ class LLMAgent(Agent):
5148
DEFAULT_SYSTEM = 'You are a helpful assistant.'
5249

5350
def __init__(self,
54-
config_dir_or_id: Optional[str] = DEFAULT_YAML,
51+
config_dir_or_id: Optional[str] = None,
5552
config: Optional[DictConfig] = None,
5653
env: Optional[Dict[str, str]] = None,
5754
**kwargs):

0 commit comments

Comments
 (0)