mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-02 14:45:17 +02:00
feat: merge geekan:main
This commit is contained in:
parent
769dc8220d
commit
ec8c703c5a
14 changed files with 251 additions and 18 deletions
|
|
@ -49,6 +49,7 @@ class CreateAgent(Action):
|
|||
pattern = r"```python(.*)```"
|
||||
match = re.search(pattern, rsp, re.DOTALL)
|
||||
code_text = match.group(1) if match else ""
|
||||
CONFIG.workspace_path.mkdir(parents=True, exist_ok=True)
|
||||
with open(CONFIG.workspace_path / "agent_created_agent.py", "w") as f:
|
||||
f.write(code_text)
|
||||
return code_text
|
||||
|
|
|
|||
|
|
@ -5,17 +5,35 @@
|
|||
"""
|
||||
import asyncio
|
||||
|
||||
from metagpt.actions import Action
|
||||
from metagpt.const import DATA_PATH
|
||||
from metagpt.document_store import FaissStore
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles import Sales
|
||||
from metagpt.schema import Message
|
||||
|
||||
""" example.json, e.g.
|
||||
[
|
||||
{
|
||||
"source": "Which facial cleanser is good for oily skin?",
|
||||
"output": "ABC cleanser is preferred by many with oily skin."
|
||||
},
|
||||
{
|
||||
"source": "Is L'Oreal good to use?",
|
||||
"output": "L'Oreal is a popular brand with many positive reviews."
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
|
||||
async def search():
|
||||
store = FaissStore(DATA_PATH / "example.json")
|
||||
role = Sales(profile="Sales", store=store)
|
||||
|
||||
queries = ["Which facial cleanser is good for oily skin?", "Is L'Oreal good to use?"]
|
||||
role._watch({Action})
|
||||
queries = [
|
||||
Message("Which facial cleanser is good for oily skin?", cause_by=Action),
|
||||
Message("Is L'Oreal good to use?", cause_by=Action),
|
||||
]
|
||||
for query in queries:
|
||||
logger.info(f"User: {query}")
|
||||
result = await role.run(query)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue