添加用户消息测试
This commit is contained in:
@@ -2,7 +2,7 @@ import os
|
||||
import asyncio
|
||||
|
||||
|
||||
from agentscope.agent import ReActAgent
|
||||
from agentscope.agent import ReActAgent, UserAgent
|
||||
from agentscope.formatter import OpenAIChatFormatter
|
||||
from agentscope.memory import InMemoryMemory
|
||||
from agentscope.model import OpenAIChatModel
|
||||
@@ -14,7 +14,7 @@ LLAMA_CPP_MODEL_NAME = os.getenv("LLAMA_CPP_MODEL_NAME", "Qwen3.5-35B-A3B-UD-Q8_
|
||||
LLAMA_CPP_API_KEY = os.getenv("LLAMA_CPP_API_KEY", "EMPTY")
|
||||
|
||||
|
||||
async def creating_react_agent() -> None:
|
||||
async def main():
|
||||
"""创建一个 ReAct 智能体并运行一个简单任务。"""
|
||||
# 准备工具
|
||||
toolkit = Toolkit()
|
||||
@@ -32,14 +32,16 @@ async def creating_react_agent() -> None:
|
||||
formatter=OpenAIChatFormatter(),
|
||||
toolkit=toolkit,
|
||||
)
|
||||
|
||||
user = UserAgent(name="user")
|
||||
|
||||
msg = await user()
|
||||
while True:
|
||||
msg = await yyp_bot(msg)
|
||||
msg = await user(msg)
|
||||
if msg.get_text_content() == "exit":
|
||||
break
|
||||
|
||||
msg = Msg(
|
||||
name="user",
|
||||
content="你好!yyp_bot,用 Python 运行 Hello World。",
|
||||
role="user",
|
||||
)
|
||||
|
||||
await yyp_bot(msg)
|
||||
asyncio.run(main())
|
||||
|
||||
|
||||
asyncio.run(creating_react_agent())
|
||||
Reference in New Issue
Block a user