test to test dir

This commit is contained in:
femto 2023-09-18 12:46:15 +08:00
parent cbfc62d7f3
commit 2cd4870592
5 changed files with 20 additions and 40 deletions

View file

@ -6,7 +6,6 @@
@File : sk_agent.py
"""
import asyncio
import os
from semantic_kernel.core_skills import FileIOSkill, MathSkill, TextSkill, TimeSkill
from semantic_kernel.planning import SequentialPlanner
@ -15,17 +14,11 @@ from semantic_kernel.planning import SequentialPlanner
from semantic_kernel.planning.action_planner.action_planner import ActionPlanner
from metagpt.actions import BossRequirement
from metagpt.const import SKILL_DIRECTORY
from metagpt.roles.sk_agent import SkAgent
from metagpt.schema import Message
from metagpt.tools.search_engine import SkSearchEngine
# 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)
async def main():
await basic_planner_example()
@ -42,8 +35,8 @@ async def basic_planner_example():
role = SkAgent()
# 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_semantic_skill_from_directory(SKILL_DIRECTORY, "SummarizeSkill")
role.import_semantic_skill_from_directory(SKILL_DIRECTORY, "WriterSkill")
role.import_skill(TextSkill(), "TextSkill")
# using BasicPlanner
await role.run(Message(content=task, cause_by=BossRequirement))
@ -56,8 +49,8 @@ async def sequential_planner_example():
role = SkAgent(planner_cls=SequentialPlanner)
# 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_semantic_skill_from_directory(SKILL_DIRECTORY, "SummarizeSkill")
role.import_semantic_skill_from_directory(SKILL_DIRECTORY, "WriterSkill")
role.import_skill(TextSkill(), "TextSkill")
# using BasicPlanner
await role.run(Message(content=task, cause_by=BossRequirement))

View file

@ -12,9 +12,11 @@ def get_project_root():
"""Search upwards to find the project root directory."""
current_path = Path.cwd()
while True:
if (current_path / '.git').exists() or \
(current_path / '.project_root').exists() or \
(current_path / '.gitignore').exists():
if (
(current_path / ".git").exists()
or (current_path / ".project_root").exists()
or (current_path / ".gitignore").exists()
):
return current_path
parent_path = current_path.parent
if parent_path == current_path:
@ -23,16 +25,18 @@ def get_project_root():
PROJECT_ROOT = get_project_root()
DATA_PATH = PROJECT_ROOT / 'data'
WORKSPACE_ROOT = PROJECT_ROOT / 'workspace'
PROMPT_PATH = PROJECT_ROOT / 'metagpt/prompts'
UT_PATH = PROJECT_ROOT / 'data/ut'
DATA_PATH = PROJECT_ROOT / "data"
WORKSPACE_ROOT = PROJECT_ROOT / "workspace"
PROMPT_PATH = PROJECT_ROOT / "metagpt/prompts"
UT_PATH = PROJECT_ROOT / "data/ut"
SWAGGER_PATH = UT_PATH / "files/api/"
UT_PY_PATH = UT_PATH / "files/ut/"
API_QUESTIONS_PATH = UT_PATH / "files/question/"
YAPI_URL = "http://yapi.deepwisdomai.com/"
TMP = PROJECT_ROOT / 'tmp'
TMP = PROJECT_ROOT / "tmp"
RESEARCH_PATH = DATA_PATH / "research"
TUTORIAL_PATH = DATA_PATH / "tutorial_docx"
SKILL_DIRECTORY = PROJECT_ROOT / "metagpt/skills"
MEM_TTL = 24 * 30 * 3600

View file

@ -5,8 +5,6 @@
@Author : femto Zheng
@File : test_basic_planner.py
"""
import os
import pytest
from semantic_kernel.core_skills import FileIOSkill, MathSkill, TextSkill, TimeSkill
from semantic_kernel.planning.action_planner.action_planner import ActionPlanner
@ -15,13 +13,6 @@ from metagpt.actions import BossRequirement
from metagpt.roles.sk_agent import SkAgent
from metagpt.schema import Message
# 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, "..", "skills")
# Normalize the path to ensure it's in the correct format
skills_directory = os.path.normpath(skills_directory)
@pytest.mark.asyncio
async def test_action_planner():

View file

@ -5,22 +5,14 @@
@Author : femto Zheng
@File : test_basic_planner.py
"""
import os
import pytest
from semantic_kernel.core_skills import TextSkill
from metagpt.actions import BossRequirement
from metagpt.const import SKILL_DIRECTORY
from metagpt.roles.sk_agent import SkAgent
from metagpt.schema import Message
# 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, "..", "skills")
# Normalize the path to ensure it's in the correct format
skills_directory = os.path.normpath(skills_directory)
@pytest.mark.asyncio
async def test_basic_planner():
@ -30,8 +22,8 @@ async def test_basic_planner():
role = SkAgent()
# 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_semantic_skill_from_directory(SKILL_DIRECTORY, "SummarizeSkill")
role.import_semantic_skill_from_directory(SKILL_DIRECTORY, "WriterSkill")
role.import_skill(TextSkill(), "TextSkill")
# using BasicPlanner
role.recv(Message(content=task, cause_by=BossRequirement))