Update skill_manager.py

This commit is contained in:
stellaHSR 2023-09-04 11:53:50 +08:00 committed by GitHub
parent dd18e05d59
commit 42ced10446
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,9 +15,7 @@ Skill = Action
class SkillManager:
"""用来管理所有技能
to manage all skills
"""
"""Used to manage all skills"""
def __init__(self):
self._llm = LLM()
@ -26,9 +24,8 @@ class SkillManager:
def add_skill(self, skill: Skill):
"""
增加技能将技能加入到技能池与可检索的存储中
Adding skills, adding skills to skill pools and retrievable storage
:param skill: 技能 Skill
Add a skill, add the skill to the skill pool and searchable storage
:param skill: Skill
:return:
"""
self._skills[skill.name] = skill
@ -36,9 +33,8 @@ class SkillManager:
def del_skill(self, skill_name: str):
"""
删除技能将技能从技能池与可检索的存储中移除
delete skill removes skill from skill pool and retrievable storage
:param skill_name: 技能名 skill name
Delete a skill, remove the skill from the skill pool and searchable storage
:param skill_name: Skill name
:return:
"""
self._skills.pop(skill_name)
@ -46,32 +42,31 @@ class SkillManager:
def get_skill(self, skill_name: str) -> Skill:
"""
通过技能名获得精确的技能
Get the exact skill by skill name
:param skill_name: 技能名 skill name
:return: 技能 Skill
Obtain a specific skill by skill name
:param skill_name: Skill name
:return: Skill
"""
return self._skills.get(skill_name)
def retrieve_skill(self, desc: str, n_results: int = 2) -> list[Skill]:
"""
通过检索引擎获得技能 Acquiring Skills Through Search Engines
:param desc: 技能描述 skill description
:return: 技能多个skill(s)
"""
Obtain skills through the search engine
:param desc: Skill description
:return: Multiple skills
"""
return self._store.search(desc, n_results=n_results)['ids'][0]
def retrieve_skill_scored(self, desc: str, n_results: int = 2) -> dict:
"""
通过检索引擎获得技能 Acquiring Skills Through Search Engines
:param desc: 技能描述 skill description
:return: 技能与分数组成的字典 A dictionary of skills and scores
Obtain skills through the search engine
:param desc: Skill description
:return: Dictionary consisting of skills and scores
"""
return self._store.search(desc, n_results=n_results)
def generate_skill_desc(self, skill: Skill) -> str:
"""
为每个技能生成对应的描述性文本 Generate corresponding descriptive text for each skill
Generate descriptive text for each skill
:param skill:
:return:
"""