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

[callback,agent] enable_no_stream_callback 永远不会触发,因为RolePlay返回的response永远是生成器 #585

Open
3 tasks done
Yimi81 opened this issue Aug 31, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Yimi81
Copy link
Contributor

Yimi81 commented Aug 31, 2024

Initial Checks

  • I have searched GitHub for a duplicate issue and I'm sure this is something new
  • I have read and followed the docs & demos and still think this is a bug
  • I am confident that the issue is with modelscope-agent (not my code, or another library in the ecosystem)

What happened + What you expected to happen

image 如图所示,尽管我设置RolePlay非stream, 但是当触发run方法,执行的回调还是enable_stream_callback,RolePlay不论是stream还是non-stream 返回的永远是generator, 因为_run方法中使用了yield语句,无论是否启用流模式,只要函数体内包含 yield 语句,Python 就会将这个函数视为一个生成器。正确方法应该分开处理stream与non-stream,将像BaseChatModel的chat方法,其enable_llm_callback是正确的。

Versions / Dependencies

最新版

Reproduction script

如上

Issue Severity

None

@Yimi81 Yimi81 added the bug Something isn't working label Aug 31, 2024
@Yimi81
Copy link
Contributor Author

Yimi81 commented Aug 31, 2024

  • 是否应该仿照BaseChatModel的chat方法,在Agent基类将run方法分为_run_stream,_run_no_stream. 这样所有agent似乎都要改动
  • 还是仅仅在roleplay这个agent下区分
  • 亦或者有什么更优雅的方法解决这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants