Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file:/Users/puzzle/PycharmProjects/ai-manage/AutoGenV04Test/BasicTest/6_RunTeamDeepSeek.py #5748

Open
y26s4824k264 opened this issue Feb 28, 2025 · 2 comments

Comments

@y26s4824k264
Copy link

What happened?

/Users/puzzle/PycharmProjects/ai-manage/.venv/bin/python /Users/puzzle/PycharmProjects/ai-manage/AutoGenV04Test/BasicTest/6_RunTeamDeepSeek.py
---------- user ----------
写一首关于秋季的短诗
---------- primary ----------
《秋日手记》

枫叶在晨光中舒展锈色
风的手指蘸取露水
给每根草茎镀上银质签名

稻穗垂首
大地正在称量金属的叹息
候鸟剪开云层时
天空的伤口渗出琥珀

所有等待都蜷成种籽
在年轮深处
刻下尚未愈合的纹路
/Users/puzzle/PycharmProjects/ai-manage/.venv/lib/python3.11/site-packages/autogen_ext/models/openai/_openai_client.py:855: UserWarning: Could not find .. field in model response content. No thought was extracted.
thought, content = parse_r1_content(content)

Which packages was the bug in?

Python AgentChat (autogen-agentchat>=0.4.0)

AutoGen library version.

Python 0.4.7

Other library version.

No response

Model used

deepseek-r1

Model provider

DeepSeek (Hosted)

Other model provider

tongyi qwen

Python version

3.11

.NET version

None

Operating system

MacOS

@y26s4824k264
Copy link
Author

import os
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.conditions import MaxMessageTermination, TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_agentchat.ui import Console
from autogen_core.models import UserMessage, ModelFamily

os.environ["OPENAI_BASE_URL"] = "https://dashscope.aliyuncs.com/compatible-mode/v1"
os.environ["OPENAI_API_KEY"] = ""

定义LLM

model_client = OpenAIChatCompletionClient(
model="deepseek-r1",
model_info={
"function_calling": False,
"json_output": False,
"vision": False,
"family": ModelFamily.R1,
}
)

async def main() -> None:
# 定义Agent
primary_agent = AssistantAgent(
name="primary",
model_client=model_client,
system_message="你是一个乐于助人的AI智能助手。",
model_client_stream=True
)

# 定义Agent
critic_agent = AssistantAgent(
    name="critic",
    model_client=model_client,
    system_message="提供建设性反馈意见。记住只有当你的反馈意见得到处理后再允许回复 “南哥AGI研习社”。",
    model_client_stream=True

)

# 定义终止条件  如果提到特定文本则终止对话
text_termination = TextMentionTermination("南哥AGI研习社")
# 定义终止条件,在5条信息后停止任务
max_message_termination = MaxMessageTermination(5)
# 使用`|` 运算符组合终止条件,在满足任一条件时停止任务
termination = text_termination | max_message_termination

# 定义Team Team的类型选择为RoundRobinGroupChat
reflection_team = RoundRobinGroupChat(participants=[primary_agent, critic_agent], termination_condition=termination,
                                      max_turns=None)

# 1、运行team并使用官方提供的Console工具以适当的格式输出
stream = reflection_team.run_stream(task="写一首关于秋季的短诗")
await Console(stream)

# # 2、运行team并使用流式输出,自己处理消息并将其流到前端
# async for message in reflection_team.run_stream(task="写一首关于秋季的短诗"):
#     print(message)

if name == 'main':
# 运行main
asyncio.run(main())

my code

@ekzhu
Copy link
Collaborator

ekzhu commented Feb 28, 2025

Looks like it's working as expected. What's the bug? The output doesn't contain so there is a warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants