mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
fixbug: call skill in api
This commit is contained in:
parent
6d3f2acddb
commit
5a03ff20ce
2 changed files with 11 additions and 3 deletions
|
|
@ -98,14 +98,15 @@ class Assistant(Role):
|
|||
async def skill_handler(self, text, **kwargs) -> bool:
|
||||
last_talk = kwargs.get("last_talk")
|
||||
skill = self.skills.get_skill(text)
|
||||
logger.info(f"skill not found: {text}")
|
||||
if not skill:
|
||||
logger.info(f"skill not found: {text}")
|
||||
return await self.talk_handler(text=last_talk, **kwargs)
|
||||
action = ArgumentsParingAction(options=self.options, skill=skill, llm=self._llm, **kwargs)
|
||||
await action.run(**kwargs)
|
||||
if action.args is None:
|
||||
return await self.talk_handler(text=last_talk, **kwargs)
|
||||
action = SkillAction(options=self.options, skill=skill, args=action.args, llm=self._llm)
|
||||
action = SkillAction(options=self.options, skill=skill, args=action.args, llm=self._llm, name=skill.name,
|
||||
desc=skill.description)
|
||||
self.add_to_do(action)
|
||||
return True
|
||||
|
||||
|
|
|
|||
|
|
@ -260,9 +260,16 @@ def parse_recipient(text):
|
|||
return recipient.group(1) if recipient else ""
|
||||
|
||||
|
||||
def initialize_environment():
|
||||
def initialize_environment(options=None):
|
||||
"""Load `config/config.yaml` to `os.environ`"""
|
||||
if options:
|
||||
for k, v in options.items():
|
||||
os.environ[k] = str(v)
|
||||
return
|
||||
|
||||
yaml_file_path = Path(__file__).resolve().parent.parent.parent / "config/config.yaml"
|
||||
if not yaml_file_path.exists():
|
||||
return
|
||||
with open(str(yaml_file_path), "r") as yaml_file:
|
||||
data = yaml.safe_load(yaml_file)
|
||||
for k, v in data.items():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue