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

feat: support gpt-4o-audio #2032

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Laisky
Copy link
Contributor

@Laisky Laisky commented Jan 14, 2025

功能

close #2022

支持 gpt-4o-audio 系列的 chat completetions

暂时没搞懂 stream 的计费模式,所以只支持了 stream==false

合并前可以使用 https://github.com/Laisky/one-api 来体验这个功能。

依赖

本提交也包含了 #2022

自测

CleanShot 2025-01-14 at 14 36 32@2x

CleanShot 2025-01-14 at 14 36 10@2x

@Laisky Laisky changed the title Patch/gpt 4o audio feat: support gpt-4o-audio Jan 14, 2025
@Laisky Laisky changed the title feat: support gpt-4o-audio [WIP]feat: support gpt-4o-audio Jan 14, 2025
@Laisky Laisky changed the title [WIP]feat: support gpt-4o-audio feat: support gpt-4o-audio Jan 14, 2025
@WqyJh
Copy link
Contributor

WqyJh commented Jan 17, 2025

对于 stream 请求,请求体中加入 include_usage 参数,返回的其中一条消息会包含 usage。建议

  • fastpath: 直接修改请求体,强制插入这个参数,然后记录返回的 usage。
  • slowpath: 自己算
"stream_options": {
  "include_usage": true
},
data: {"id":"chatcmpl-AqcNUZRReOSzmK4Bqntp7s5KwzaMR","object":"chat.completion.chunk","created":1737103944,"model":"gpt-4o-audio-preview-2024-12-17","service_tier":"default","system_fingerprint":"fp_58887f9c5a","choices":[],"usage":{"prompt_tokens":17,"completion_tokens":488,"total_tokens":505,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":409,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}

- Refactor model name handling across multiple controllers to improve clarity and maintainability.
- Enhance error logging and handling for better debugging and request processing robustness.
- Update pricing models in accordance with new calculations, ensuring accuracy in the billing logic.
@@ -82,6 +83,27 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.G
}
request.StreamOptions.IncludeUsage = true
}

// o1/o1-mini/o1-preview do not support system prompt and max_tokens
if strings.HasPrefix(request.Model, "o1") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是没有必要?用户既然在调用 o1,就应该遵循 OpenAI 的规则

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

主要是减轻前端的负担,因为很多时候前端都是套了一层 chat ui,用户会随意在各个 models 间切换,如果除了 model 外还有太多其他限制的话,前端的实现会复杂很多。

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

Successfully merging this pull request may close these issues.

3 participants