QwenLM / Qwen-Agent

Agent framework and applications built upon Qwen2, featuring Function Calling, Code Interpreter, RAG, and Chrome extension.
https://pypi.org/project/qwen-agent/
Other
2.51k stars 249 forks source link

关于sse返回结构, 这两种流式返回方式有区别吗? #185

Open leavegee opened 3 weeks ago

leavegee commented 3 weeks ago

我看一般的响应方式是这样的: 每次都返回一个单独的token,并不会累加. image 但是qwen-agent返回的却是累加的形式: image

请问qwen-agent能改变设置吗?

JianxinMa commented 3 weeks ago

LLM类的话,可以,配置下delta_stream=True这个参数:https://github.com/QwenLM/Qwen-Agent/blob/main/qwen_agent/llm/base.py#L55

Agent类的话,暂时不可以,因为会大幅增加代码的复杂度,同时我们评估后发现“累加并返回全部tokens”的方式能实现比“不累加只返回当前token”更多的功能(比如写一篇文章的时候能实现各个章节同时流式输出)。