mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-02 14:45:17 +02:00
feat: +software company test pass
This commit is contained in:
parent
e5cabbe3cd
commit
cc3567a4a1
5 changed files with 15 additions and 9 deletions
|
|
@ -11,7 +11,7 @@ requirement = (
|
|||
|
||||
|
||||
async def main(requirement: str = ""):
|
||||
mgx = MGX(ususe_intent=True)
|
||||
mgx = MGX(use_intent=True)
|
||||
await mgx.run(requirement)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import asyncio
|
||||
from typing import Dict, List
|
||||
|
||||
from metagpt.actions.intent_detect import IntentDetect
|
||||
from metagpt.actions.intent_detect import LightIntentDetect
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles.di.data_interpreter import DataInterpreter
|
||||
from metagpt.schema import Message
|
||||
|
|
@ -15,7 +15,7 @@ class MGX(DataInterpreter):
|
|||
intents: Dict = {}
|
||||
|
||||
async def _intent_detect(self, user_msgs: List[Message] = None, **kwargs):
|
||||
todo = IntentDetect(context=self.context)
|
||||
todo = LightIntentDetect(context=self.context)
|
||||
await todo.run(user_msgs)
|
||||
logger.info(f"intent_desp is {todo.result.model_dump_json()}")
|
||||
|
||||
|
|
@ -27,8 +27,14 @@ class MGX(DataInterpreter):
|
|||
intention_ref = "\n".join(i.intention.refs)
|
||||
self.intents[intention_ref] = i.sop.sop
|
||||
logger.debug(f"refs: {intention_ref}, sop: {i.sop.sop}")
|
||||
sop_str = "\n".join(i.sop.sop)
|
||||
return f"{intention_ref}\n---\n{sop_str}"
|
||||
sop_str = "\n".join([f"- {i}" for i in i.sop.sop])
|
||||
markdown = (
|
||||
f"### User Requirement Detail\n```text\n{intention_ref}\n````\n"
|
||||
f"### Knowledge\nTo meet user requirements, the following standard operating procedure(SOP)"
|
||||
f" must be used:\n"
|
||||
f"{sop_str}"
|
||||
)
|
||||
return markdown
|
||||
return intention_ref
|
||||
|
||||
async def _plan_and_act(self) -> Message:
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class ToolRecommender(BaseModel):
|
|||
available_tools=available_tools,
|
||||
topk=topk,
|
||||
)
|
||||
rsp = await LLM().aask(prompt)
|
||||
rsp = await LLM().aask(prompt, stream=False)
|
||||
rsp = CodeParser.parse_code(block=None, text=rsp)
|
||||
ranked_tools = json.loads(rsp)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import sys
|
|||
import traceback
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, List, Literal, Tuple, Union
|
||||
from typing import Any, Callable, List, Literal, Optional, Tuple, Union
|
||||
from urllib.parse import quote, unquote
|
||||
|
||||
import aiofiles
|
||||
|
|
@ -271,7 +271,7 @@ class CodeParser:
|
|||
return block_dict
|
||||
|
||||
@classmethod
|
||||
def parse_code(cls, block: str, text: str, lang: str = "") -> str:
|
||||
def parse_code(cls, block: Optional[str], text: str, lang: str = "") -> str:
|
||||
if block:
|
||||
text = cls.parse_block(block, text)
|
||||
pattern = rf"```{lang}.*?\s+(.*?)```"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from tests.metagpt.actions.test_intent_detect import DEMO_CONTENT
|
|||
@pytest.mark.parametrize("user_messages", [[Message.model_validate(i) for i in DEMO_CONTENT if i["role"] == "user"]])
|
||||
async def test_mgx(user_messages: List[Message]):
|
||||
ctx = Context()
|
||||
mgx = MGX(context=ctx)
|
||||
mgx = MGX(context=ctx, tools=["<all>"])
|
||||
|
||||
for i in user_messages:
|
||||
await mgx.run(i)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue