-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
AgentScope is an open-source project. To involve a broader community, we recommend asking your questions in English.
Describe the bug
https://doc.agentscope.io/zh_CN/tutorial/workflow_conversation.html
根据这个文档中 消息共享 章节 的示例代码
多智能体在msghub 聊天 ,智能体记忆会包含其他智能体的思考过程,正常来说 某个智能体,但是不是稳定复现,有时候包含其他智能体的思考,有时候不包含
To Reproduce
Steps to reproduce the behavior:
import asyncio
import json
import os
import agentscope
from agentscope.agent import ReActAgent
from agentscope.formatter import DashScopeMultiAgentFormatter, DeepSeekChatFormatter, DeepSeekMultiAgentFormatter, \
OpenAIMultiAgentFormatter
from agentscope.message import Msg
from agentscope.model import DashScopeChatModel, OpenAIChatModel, AnthropicChatModel
from agentscope.pipeline import MsgHub
# agentscope.init(
# # ... other configurations like model_configs
# studio_url="http://localhost:3000",
# )
print("xx")
Qwen3 = OpenAIChatModel(
client_kwargs={"base_url": "https://api.scnet.cn/api/llm/v1"},
model_name="Qwen3-235B-A22B",
api_key="sk-xxx",
)
MiniMax = OpenAIChatModel(
client_kwargs={"base_url": "https://api.scnet.cn/api/llm/v1"},
model_name="MiniMax-M2.5",
api_key="sk-xxx",
)
DeepSeek = OpenAIChatModel(
client_kwargs={"base_url": "https://api.scnet.cn/api/llm/v1"},
model_name="DeepSeek-R1-0528",
api_key="sk-xxx",
)
kimi2 = OpenAIChatModel(
client_kwargs={"base_url": "https://apis.iflow.cn/v1"},
model_name="kimi-k2-0905",
api_key="sk-xxx",
)
formatter = DashScopeMultiAgentFormatter()
deepseekFormatter = DeepSeekMultiAgentFormatter()
openaiFormatter = OpenAIMultiAgentFormatter()
kimi2 = ReActAgent(
name="kimi2",
sys_prompt="你是一个名为 kimi2 的学生。",
model=kimi2,
formatter=openaiFormatter,
)
alice = ReActAgent(
name="Alice",
sys_prompt="你是一个名为 Alice 的学生。",
model=Qwen3,
formatter=openaiFormatter,
)
bob = ReActAgent(
name="Bob",
sys_prompt="你是一个名为 Bob 的学生。",
model=DeepSeek,
formatter=deepseekFormatter,
)
charlie = ReActAgent(
name="Charlie",
sys_prompt="你是一个名为 Charlie 的学生。",
model=MiniMax,
formatter=openaiFormatter,
)
async def example_msghub() -> None:
"""使用 MsgHub 进行多智能体对话的示例。"""
async with MsgHub(
[
kimi2,
alice,
bob,
charlie
],
# 进入 MsgHub 时的公告消息
announcement=Msg(
"system",
"现在大家互相认识一下,简单自我介绍。",
"system",
),
):
await kimi2()
print("=======================================================================================================")
await alice()
print("=======================================================================================================")
await bob()
print("=======================================================================================================")
await charlie()
asyncio.run(example_msghub())
async def example_memory() -> None:
"""打印 Alice 的记忆。"""
print("Alice 的记忆:")
# alice.memory.
for msg in await alice.memory.get_memory():
print(
f"{msg.name}: {json.dumps(msg.content, indent=4, ensure_ascii=False)}",
)
asyncio.run(example_memory())
Expected behavior
A clear and concise description of what you expected to happen.
Environment (please complete the following information):
- AgentScope Version: 1.0.17
- Python Version: 3.11
- OS: windows 11
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels