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

Gemini的流式返回存在问题 #1408

Open
5 tasks done
manjieqi opened this issue May 4, 2024 · 8 comments · May be fixed by #1477
Open
5 tasks done

Gemini的流式返回存在问题 #1408

manjieqi opened this issue May 4, 2024 · 8 comments · May be fixed by #1477
Labels
bug Something isn't working

Comments

@manjieqi
Copy link
Contributor

manjieqi commented May 4, 2024

例行检查

  • 我已确认目前没有类似 issue
  • 我已确认我已升级到最新版本
  • 我已完整查看过项目 README,尤其是常见问题部分
  • 我理解并愿意跟进此 issue,协助测试和提供反馈
  • 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

问题描述
Gemini仅返回几个字,因为它们把"finish_reason":"stop"作为回答停止的信号
如果openai的返回格式是标准的,那Gemini的流式还需要改一下

Gemini的回答,可以看见每一个部分都有stop
Snipaste_2024-05-04_13-13-19

GPT的回答,仅最后的一个部分有stop
Snipaste_2024-05-04_13-14-14

@manjieqi manjieqi added the bug Something isn't working label May 4, 2024
@RexWzh
Copy link

RexWzh commented May 14, 2024

+1 似乎是最新版引入的问题,我之前使用是正常的

data: {"id":"","object":"chat.completion.chunk","created":0,"model":"gemini","choices":[{"index":0,"delta":{"content":"我是 Gemini,一个由 Google 开发的多模态 AI 模型。作为一个大型语言"},"finish_reason":"stop"}]}

data: {"id":"","object":"chat.completion.chunk","created":0,"model":"gemini","choices":[{"index":0,"delta":{"content":"模型,我接受了大量文本数据的训练,能够理解和生成人类语言、回答问题并提供信息。我不断学习和完善,致力于提供全面"},"finish_reason":"stop"}]}

data: {"id":"","object":"chat.completion.chunk","created":0,"model":"gemini","choices":[{"index":0,"delta":{"content":"且有帮助的响应。"},"finish_reason":"stop"}]}

data: [DONE]

@SLF-Heisenberg
Copy link

我也遇到了 同样的问题 每一次的 调用结果 都是 "finish_reason": "stop" 但是 只有 最后一个包分发完毕的 才是 "stop"
image

@youjin-git
Copy link

这个bug还没修复吗?

@SLF-Heisenberg
Copy link

看样子还没有解决,bug状态是open

@RexWzh
Copy link

RexWzh commented May 26, 2024

看样子还没有解决,bug状态是open

回退到 v0.6.6-alpha 可以,但会少一些近期更新的东西。项目维护的人好像很少,更新功能的同时,可能会引入一些 bug。

要么另外开个稳定的 one-api 来过渡,或者接入 litellmAI-Gateway

@SLF-Heisenberg
Copy link

ok 非常感谢~

@mxdlzg
Copy link
Contributor

mxdlzg commented May 28, 2024

早期的版本应该没有返回FinishReason?所以流不会被截断。
但是在v0.6.7左右的版本修复stream流问题时这部分被修正了https://github.com/songquanpeng/one-api/pull/1382,引入了FinishReason字段。涉及问题https://github.com/songquanpeng/one-api/issues/1345、
https://github.com/songquanpeng/one-api/pull/1328。
但是有个比较尴尬的地方在于,实际上Gemini的API本身就在每个流message中返回STOP(看起来跟早期的Gemini的表现不太一致,不知道为什么会出现这个问题)。

因为是流式返回,没法准确预知哪个是最后一条message,只能暂时去掉FinishReason字段了。#1477

@SLF-Heisenberg
Copy link

早期的版本应该没有返回FinishReason?所以流不会被截断。 但是在v0.6.7左右的版本修复stream流问题时这部分被修正了https://github.com/songquanpeng/one-api/pull/1382,引入了FinishReason字段。涉及问题https://github.com/songquanpeng/one-api/issues/1345、 https://github.com/songquanpeng/one-api/pull/1328。 但是有个比较尴尬的地方在于,实际上Gemini的API本身就在每个流message中返回STOP(看起来跟早期的Gemini的表现不太一致,不知道为什么会出现这个问题)。

因为是流式返回,没法准确预知哪个是最后一条message,只能暂时去掉FinishReason字段了。#1477

您的描述 很有意义,我在尝试把这个 问题 返回给谷歌 ~ 希望会有所答复~

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

Successfully merging a pull request may close this issue.

5 participants