mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
refine code
This commit is contained in:
parent
2bcce1d593
commit
b16315f6c7
2 changed files with 4 additions and 16 deletions
|
|
@ -11,14 +11,12 @@
|
|||
|
||||
import re
|
||||
|
||||
import aiofiles
|
||||
|
||||
from metagpt.actions import UserRequirement
|
||||
from metagpt.actions.write_teaching_plan import TeachingPlanBlock, WriteTeachingPlanPart
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles import Role
|
||||
from metagpt.schema import Message
|
||||
from metagpt.utils.common import any_to_str
|
||||
from metagpt.utils.common import any_to_str, awrite
|
||||
|
||||
|
||||
class Teacher(Role):
|
||||
|
|
@ -83,11 +81,7 @@ class Teacher(Role):
|
|||
pathname = self.config.workspace.path / "teaching_plan"
|
||||
pathname.mkdir(exist_ok=True)
|
||||
pathname = pathname / filename
|
||||
try:
|
||||
async with aiofiles.open(str(pathname), mode="w", encoding="utf-8") as writer:
|
||||
await writer.write(content)
|
||||
except Exception as e:
|
||||
logger.error(f"Save failed:{e}")
|
||||
await awrite(pathname, content)
|
||||
logger.info(f"Save to:{pathname}")
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -4,15 +4,9 @@
|
|||
|
||||
import pytest
|
||||
|
||||
from metagpt.config import CONFIG
|
||||
from metagpt.config2 import config
|
||||
from metagpt.provider.spark_api import GetMessageFromWeb, SparkLLM
|
||||
|
||||
CONFIG.spark_appid = "xxx"
|
||||
CONFIG.spark_api_secret = "xxx"
|
||||
CONFIG.spark_api_key = "xxx"
|
||||
CONFIG.domain = "xxxxxx"
|
||||
CONFIG.spark_url = "xxxx"
|
||||
|
||||
prompt_msg = "who are you"
|
||||
resp_content = "I'm Spark"
|
||||
|
||||
|
|
@ -28,7 +22,7 @@ class MockWebSocketApp(object):
|
|||
def test_get_msg_from_web(mocker):
|
||||
mocker.patch("websocket.WebSocketApp", MockWebSocketApp)
|
||||
|
||||
get_msg_from_web = GetMessageFromWeb(text=prompt_msg)
|
||||
get_msg_from_web = GetMessageFromWeb(prompt_msg, config)
|
||||
assert get_msg_from_web.gen_params()["parameter"]["chat"]["domain"] == "xxxxxx"
|
||||
|
||||
ret = get_msg_from_web.run()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue