mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-25 08:46:48 +02:00
feat: +skill config
This commit is contained in:
parent
c5e16330a2
commit
2148e4e4f4
1 changed files with 14 additions and 2 deletions
|
|
@ -7,11 +7,13 @@
|
|||
@Desc : Skill YAML Configuration Loader.
|
||||
"""
|
||||
from pathlib import Path
|
||||
from typing import List, Dict, Optional
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
import yaml
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from metagpt.config import CONFIG
|
||||
|
||||
|
||||
class Example(BaseModel):
|
||||
ask: str
|
||||
|
|
@ -52,7 +54,7 @@ class SkillLoader:
|
|||
def __init__(self, skill_yaml_file_name: Path = None):
|
||||
if not skill_yaml_file_name:
|
||||
skill_yaml_file_name = Path(__file__).parent.parent.parent / ".well-known/skills.yaml"
|
||||
with open(str(skill_yaml_file_name), 'r') as file:
|
||||
with open(str(skill_yaml_file_name), "r") as file:
|
||||
skills = yaml.safe_load(file)
|
||||
self._skills = SkillsDeclaration(**skills)
|
||||
|
||||
|
|
@ -62,8 +64,18 @@ class SkillLoader:
|
|||
if not entity_skills:
|
||||
return {}
|
||||
|
||||
agent_skills = CONFIG.agent_skills
|
||||
if not agent_skills:
|
||||
return {}
|
||||
|
||||
class AgentSkill(BaseModel):
|
||||
name: str
|
||||
|
||||
names = [AgentSkill(**i).name for i in agent_skills]
|
||||
description_to_name_mappings = {}
|
||||
for s in entity_skills.skills:
|
||||
if s.name not in names:
|
||||
continue
|
||||
description_to_name_mappings[s.description] = s.name
|
||||
|
||||
return description_to_name_mappings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue