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

[Bug]仓库中引用的 openai 库,在某些模型服务中会导致 SSE 返回异常 #98

Open
sunhailin-Leo opened this issue Feb 18, 2025 · 5 comments
Assignees
Labels
C-bug This is a bug-report. Bug-fix PRs use `C-enhancement` instead.

Comments

@sunhailin-Leo
Copy link

先说结论

  • 建议替换 libs/acl/openai 中的 openai api 使用库从 sashabaranov/go-openaiopenai 官方的 sdk
  • 关联 issue 和 pull-request:pull-request, issue

原因

  • sashabaranov/go-openai 没有妥善处理 SSE 返回 data 的两种情况 data:data: (⚠️注意:区别在在冒号后面的空格)
  • SSE 文档 根据文档其实并没有严格要求返回结构,因此存在某些模型服务下会无法正确返回流式推理结果。
@sunhailin-Leo sunhailin-Leo changed the title 仓库中引用的 openai 库,在某些模型服务中会导致 SSE 返回异常 [Bug]仓库中引用的 openai 库,在某些模型服务中会导致 SSE 返回异常 Feb 18, 2025
@meguminnnnnnnnn
Copy link
Contributor

meguminnnnnnnnn commented Feb 18, 2025

官方sdk还在alpha版本,切换成本可能会出乎意料的高,所以我们暂时没有切换到官方sdk,等官方sdk稳定后我们会尽快切换。
短期解决方案可能是sashabaranov/go-openai修复后我们更新下依赖版本。
临时解决方案你可以在你的项目go.mod里replace sashabaranov/go-openai库到你的开发分支上,类似于添加:
replace github.com/sashabaranov/go-openai => github.com/yournamespace/go-openai

@sunhailin-Leo
Copy link
Author

官方sdk还在alpha版本,切换成本可能会出乎意料的高,所以我们暂时没有切换到官方sdk。 短期解决方案可能是sashabaranov/go-openai修复后我们更新下依赖版本。 临时解决方案你可以在你的项目里replace sashabaranov/go-openai库到你的开发分支上

  • 切换成本这个的确是挺高的 😭,现阶段只能用 fork 修改后的代码去 replace go.mod 解决了。
  • sashabaranov/go-openai 那边的 pr 都被 hold 住两周了,感觉那边似乎不是很重视这个 bug 😭

@meguminnnnnnnnn
Copy link
Contributor

暂时只能这样了😂,顺便问下你是已经确认了官方sdk里没有这个问题嘛

@sunhailin-Leo
Copy link
Author

暂时只能这样了😂,顺便问下你是已经确认了官方sdk里没有这个问题嘛

  • 我只测过流式这块的官方的确是没有问题。
  • 本质还是因为 sashabaranov/go-openai 这边 SSE 解析实现的实在是太 hard code 了...当时翻到它源码我都震惊了...

@hi-pender hi-pender added the C-bug This is a bug-report. Bug-fix PRs use `C-enhancement` instead. label Feb 18, 2025
@meguminnnnnnnnn meguminnnnnnnnn self-assigned this Feb 28, 2025
@meguminnnnnnnnn
Copy link
Contributor

meguminnnnnnnnn commented Feb 28, 2025

同步下进展,最近开始尝试切换到openai官方sdk,但是测试中发现有个bug(https://github.com/openai/openai-go/issues/239),等解决后再切。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug This is a bug-report. Bug-fix PRs use `C-enhancement` instead.
Development

No branches or pull requests

3 participants