mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-05 14:55:18 +02:00
sk agent
This commit is contained in:
parent
d9f64363c3
commit
751c6a877c
4 changed files with 63 additions and 15296 deletions
|
|
@ -6,6 +6,13 @@
|
|||
@File : sk_agent.py
|
||||
"""
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
import semantic_kernel
|
||||
from semantic_kernel.core_skills import FileIOSkill, MathSkill, TextSkill, TimeSkill
|
||||
|
||||
# from semantic_kernel.planning import SequentialPlanner
|
||||
from semantic_kernel.planning.action_planner.action_planner import ActionPlanner
|
||||
|
||||
from metagpt.actions import BossRequirement
|
||||
from metagpt.roles.sk_agent import SkAgent
|
||||
|
|
@ -17,12 +24,36 @@ async def main():
|
|||
Tomorrow is Valentine's day. I need to come up with a few date ideas. She speaks French so write it in French.
|
||||
Convert the text to uppercase"""
|
||||
role = SkAgent()
|
||||
|
||||
# Get the directory of the current file
|
||||
current_file_directory = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# Construct the skills_directory by joining the parent directory and "skillss"
|
||||
skills_directory = os.path.join(current_file_directory, "..", "metagpt", "skills")
|
||||
|
||||
# Normalize the path to ensure it's in the correct format
|
||||
skills_directory = os.path.normpath(skills_directory)
|
||||
|
||||
# let's give the agent some skills
|
||||
role.import_semantic_skill_from_directory(skills_directory, "SummarizeSkill")
|
||||
role.import_semantic_skill_from_directory(skills_directory, "WriterSkill")
|
||||
role.import_skill(semantic_kernel.core_skills.TextSkill(), "TextSkill")
|
||||
|
||||
# using BasicPlanner
|
||||
await role.run(Message(content=task, cause_by=BossRequirement))
|
||||
|
||||
# from semantic_kernel.planning import SequentialPlanner
|
||||
# role.planner = SequentialPlanner(role.kernel)
|
||||
# #using SequentialPlanner
|
||||
# role = SkAgent(planner_cls=SequentialPlanner)
|
||||
# await role.run(Message(content=task, cause_by=BossRequirement))
|
||||
# %%
|
||||
role = SkAgent(planner_cls=ActionPlanner)
|
||||
# let's give the agent 4 skills
|
||||
role.import_skill(MathSkill(), "math")
|
||||
role.import_skill(FileIOSkill(), "fileIO")
|
||||
role.import_skill(TimeSkill(), "time")
|
||||
role.import_skill(TextSkill(), "text")
|
||||
|
||||
task = "What is the sum of 110 and 990?"
|
||||
await role.run(Message(content=task, cause_by=BossRequirement)) # it will choose mathskill.Add
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue