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: add o3-mini support for OpenAI & GitHub Models #5657

Merged
merged 16 commits into from
Feb 3, 2025

Conversation

hezhijie0327
Copy link
Contributor

@hezhijie0327 hezhijie0327 commented Feb 2, 2025

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • 📝 docs
  • 🔨 chore

🔀 变更说明 | Description of Change

  1. 增加 o3-mini 模型
  2. 补齐数据库模式下 o1 模型丢失的问题
  3. 重命名 o1Models -> reasoningModels
  4. 重命名 pruneO1Payload -> pruneReasoningPayload
  5. GitHub Models 中 o3-mini 禁用流式输出
  6. 更新 o1-mini 价格,同 o3-mini
  7. 将 system role 从 user 改为 developer
  8. 增加 reasoning_effort 控制,可在 Agent 设置中启用(默认为禁用即不引入参数),启用后可选择 low medium high(默认为 medium
  9. 增加 Discover 中对 reasoning_effort 的描述,补齐文档

📝 补充信息 | Additional Information

功能 截图
对话 image
工具调用 image
System Prompt image
Reasoning Effort imageimage
Discover image

ref: https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages
image


close #5644
close #5649
close #5643
close #5690

Copy link

vercel bot commented Feb 2, 2025

@hezhijie0327 is attempting to deploy a commit to the LobeHub Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 2, 2025
@lobehubbot
Copy link
Member

👍 @hezhijie0327

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

@dosubot dosubot bot added the 💄 Design Design an style | 样式问题 label Feb 2, 2025
Copy link

gru-agent bot commented Feb 2, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail 96a1996 ✅ Finished

Files

File Pull Request
src/libs/agent-runtime/openai/index.ts ❌ Failure (I failed to write the unit tests for the file.)

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

Copy link

codecov bot commented Feb 2, 2025

Codecov Report

Attention: Patch coverage is 94.59459% with 4 lines in your changes missing coverage. Please review.

Project coverage is 92.12%. Comparing base (58a86fc) to head (e79fe29).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/libs/agent-runtime/openai/index.ts 71.42% 2 Missing ⚠️
src/libs/agent-runtime/github/index.ts 66.66% 1 Missing ⚠️
...store/chat/slices/aiChat/actions/generateAIChat.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #5657     +/-   ##
=========================================
  Coverage   92.11%   92.12%             
=========================================
  Files         647      647             
  Lines       57831    57888     +57     
  Branches     4270     2910   -1360     
=========================================
+ Hits        53272    53328     +56     
- Misses       4559     4560      +1     
Flag Coverage Δ
app 92.12% <94.59%> (+<0.01%) ⬆️
server 98.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Sen-CaPoo
Copy link

image

似乎還沒有對 調整思考時間(reasoning_effort) 參數進行處理,但可以確保 o3-mini 模型的基本運作(Defaults to medium)。
(o1 正式版,o3-mini 兩種模型支援此參數)

參考 #5643

@hezhijie0327
Copy link
Contributor Author

加了个 UI 设置,但是会让所有模型都加上 reasoning_effort 改动项会比较多,看看有没有其他解法
image
image

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Feb 2, 2025
@hezhijie0327
Copy link
Contributor Author

@Sen-CaPoo 已支持,默认禁用,启用后将引入 reasoning_effort 并提供下拉框选择推理强度

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@Sen-CaPoo has been supported and disabled by default. After use, it will be introduced to reasoning_effort and provide a drop-down box to select the reasoning strength

@Sen-CaPoo
Copy link

加了个 UI 设置,但是会让所有模型都加上 reasoning_effort 改动项会比较多,看看有没有其他解法 image image

image

暫時解決方案這樣似乎已經滿足,畢竟不太會每一次對話都調整思考時間的選項;最終理想可能會是遇到 OpenAI 的思考模型會在對話輸入框上方的工具列出現一個快速選擇思考時間的工具。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Add a UI settings, but it will add more models to Reasoning_effort to change more, see if there are other solutions! [Image] (https://private- user-githubusercontent.com/58100052 /408841484-82FBF33F-6715-4bb3-8C03-DB8A14200C75.png?jwt=eyjhbgcioiji1niisinr5cci6ikpxVCJ9..Hzzxc01bwituzx8yc8ai2VMGBHBHBH M_nzpkm5po)! [Image] (https://private- user-images.githubusercontent.com/58100052/408841513-3AFB0E96-0f46-4F33 -AD85-7D32A137DBF0.PNG? JWT = Eyjhbgcioijiu1niisinr5CCI6IKPXVCJ9..PSOM1NRUG3XHluskqnr6ehpov5twnxlz-PE_2M)

! [Image] (https://github.com/user-attachments/aSSETS/E3DB6262-1C6B-4352-9a62-1402795402B5))))))))

The temporary solution seems to be satisfied. After all, it is not very good to adjust the option of thinking time every time; in the end, the ideal may be that the thinking model of the OpenAI thinks will appear in the toolbar of the dialogue input box. Essence

@Sun-drenched
Copy link

加了个 UI 设置,但是会让所有模型都加上 reasoning_effort 改动项会比较多,看看有没有其他解法 image image

#5556 我评论下的讨论中,xu似乎说过他们有模型层面绑定参数的路线。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Add a UI settings, but it will add more models to Reasoning_effort to change more, see if there are other solutions! [Image] (https://private- user-githubusercontent.com/58100052 /408841484-82FBF33F-6715-4BB3 -8C03-DB8A14200C75.png?jwt=eyjhbgcioiji1niisinr5CCI6IKPXVCJ9-ku6l9Sgan99jdawl-Zu8fpy6n_ 5YOHFVGFQW)! [Image] (https://private- user-images.githubusercontent.com/58100052/408841513-3AFB0E96-0F46 -4F33-AD85-7D32A137DBF0.PNG? JWT = Eyjhbgcioijiu1niisinr5CCI6IKPXVCJ9..Zmqc41ceigz-EMXXFPUS1RDDDVELBETN82D9YPNMVYIA)

In the discussion under #5556, XU seemed to say that they had the route of binding parameters at the model level.

@Sun-drenched
Copy link

Sun-drenched commented Feb 2, 2025

似乎推理模型大多不接受temperature、top_p、presence_penalty、frequency_penalty等常规模型参数(比如R1),所以建议在这个PR中一并提供推理模型禁用上述参数设置(UI中也置于不可用)的路径
另外还有一些模型的temperature不推荐用户修改(比如腾讯混元“模型已有默认参数,不传值时使用各模型推荐值,不推荐用户修改”),建议一并给出不传temperature参数的设置

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It seems that most of the reasoning models do not accept conventional model parameters such as Temperature, TOP_P, Presence_Penalty, Frequency_Penalty (such as R1). Therefore

@hezhijie0327
Copy link
Contributor Author

hezhijie0327 commented Feb 2, 2025

似乎推理模型大多不接受temperature、top_p、presence_penalty、frequency_penalty等常规模型参数(比如R1),所以建议在这个PR中一并提供推理模型禁用上述参数设置(UI中也置于不可用)的路径

我看了下 R1 和 o1 目前的策略一致,在使用推理模型时直接忽略这些参数,UI 如何设置都不影响后续传参

return {
...payload,
model,
...(model === 'deepseek-reasoner'
? {
frequency_penalty: undefined,
messages: filteredMessages,
presence_penalty: undefined,
temperature: undefined,
top_p: undefined,
}
: {
frequency_penalty,
messages,
presence_penalty,
temperature,
top_p,
}),
} as OpenAI.ChatCompletionCreateParamsStreaming;

export const pruneO1Payload = (payload: ChatStreamPayload) => ({
...payload,
frequency_penalty: 0,
messages: payload.messages.map((message: OpenAIChatMessage) => ({
...message,
role: message.role === 'system' ? 'user' : message.role,
})),
presence_penalty: 0,
temperature: 1,
top_p: 1,
});

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It seems that most of the derived models do not accept conventional model parameters such as TEMPERATURE, TOP_P, Presence_Penalty, Frequency_Penalty (such as R1), so it is recommended to provide a path for the above parameters (in the UI is not available) in this PR.

I looked at the current strategies of R1 and O1. When using the reasoning model, I ignored these parameters directly. How to set up UI will not affect subsequent pass parameters.

@Sun-drenched
Copy link

似乎推理模型大多不接受temperature、top_p、presence_penalty、frequency_penalty等常规模型参数(比如R1),所以建议在这个PR中一并提供推理模型禁用上述参数设置(UI中也置于不可用)的路径

我看了下 R1 和 o1 目前的策略一致,在使用推理模型时直接忽略这些参数,UI 如何设置都不影响后续传参

return {
...payload,
model,
...(model === 'deepseek-reasoner'
? {
frequency_penalty: undefined,
messages: filteredMessages,
presence_penalty: undefined,
temperature: undefined,
top_p: undefined,
}
: {
frequency_penalty,
messages,
presence_penalty,
temperature,
top_p,
}),
} as OpenAI.ChatCompletionCreateParamsStreaming;

export const pruneO1Payload = (payload: ChatStreamPayload) => ({
...payload,
frequency_penalty: 0,
messages: payload.messages.map((message: OpenAIChatMessage) => ({
...message,
role: message.role === 'system' ? 'user' : message.role,
})),
presence_penalty: 0,
temperature: 1,
top_p: 1,
});

emmm,其实我的意思是在UI中给予参数不可用的提示,比如温度设置项直接置于不可点击等方式

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It seems that most of the derived models do not accept conventional model parameters such as Temperature, TOP_P, Presence_Penalty, Frequency_Penalty (such as R1).
"
I looked at the current strategies of R1 and O1. When using the reasoning model, they ignored these parameters directly. How to set up UI will not affect subsequent pass parameters.
"
https://github.com/lobehub/lobe- Chat/blob/2bec8766a5cb4F3223761756617C235B/Src/Libs/ager/deepseek/index.ts# L38-l56
"
https://github.com/lobehub/lobe- Chat/blob/2bec8766a5cb4F3223761756617C235B/SRC/Libs/ager/openai/index.ts#L14 -L24

EMMM, in fact, I mean that the parameters are not available in the UI, such as the temperature setting item is directly placed in the method of not clicking

@arvinxx
Copy link
Contributor

arvinxx commented Feb 3, 2025

ci 咋挂了

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Ci hung up

Copy link

vercel bot commented Feb 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lobe-chat-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 3, 2025 9:03am

@hezhijie0327
Copy link
Contributor Author

@arvinxx 重新拉了下主线就好了,看了下之前的报错好像是数据库测试超时
image

@arvinxx arvinxx changed the title 💄 style: add o3-mini support for OpenAI & GitHub Models ✨ feat: add o3-mini support for OpenAI & GitHub Models Feb 3, 2025
@arvinxx arvinxx merged commit 492cfd4 into lobehub:main Feb 3, 2025
7 of 8 checks passed
@lobehubbot
Copy link
Member

❤️ Great PR @hezhijie0327 ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
项目的成长离不开用户反馈和贡献,感谢您的贡献! 如果您对 LobeHub 开发者社区感兴趣,请加入我们的 discord,然后私信 @arvinxx@canisminor1990。他们会邀请您加入我们的私密开发者频道。我们将会讨论关于 Lobe Chat 的开发,分享和讨论全球范围内的 AI 消息。

@hezhijie0327 hezhijie0327 deleted the o3 branch February 3, 2025 09:46
github-actions bot pushed a commit that referenced this pull request Feb 3, 2025
## [Version&nbsp;1.50.0](v1.49.16...v1.50.0)
<sup>Released on **2025-02-03**</sup>

#### ✨ Features

- **misc**: Add `o3-mini` support for OpenAI & GitHub Models.

#### 🐛 Bug Fixes

- **misc**: Fix parse of deepseek r1 in siliconflow provider.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Add `o3-mini` support for OpenAI & GitHub Models, closes [#5657](#5657) ([492cfd4](492cfd4))

#### What's fixed

* **misc**: Fix parse of deepseek r1 in siliconflow provider, closes [#5687](#5687) ([44e81e2](44e81e2))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Member

🎉 This PR is included in version 1.50.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@SAnBlog
Copy link

SAnBlog commented Feb 3, 2025

v1.50.0 数据库版本镜像构建失败了

@hezhijie0327
Copy link
Contributor Author

emmm 得点下重新构建

#27 343.8 Segmentation fault (core dumped)

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


EMMM has to be restarted down

` #27 343.8 segmentation fault (core dumped) `

github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Feb 3, 2025
## [Version&nbsp;1.92.0](v1.91.6...v1.92.0)
<sup>Released on **2025-02-03**</sup>

#### ✨ Features

- **misc**: Add `o3-mini` support for OpenAI & GitHub Models.

#### 🐛 Bug Fixes

- **misc**: Fix parse of deepseek r1 in siliconflow provider, fix provider update issue, Optimize requests without historical messages.

#### 💄 Styles

- **misc**: Update Fireworks check model and fix check error, Update perplexity models.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Add `o3-mini` support for OpenAI & GitHub Models, closes [lobehub#5657](https://github.com/bentwnghk/lobe-chat/issues/5657) ([492cfd4](492cfd4))

#### What's fixed

* **misc**: Fix parse of deepseek r1 in siliconflow provider, closes [lobehub#5687](https://github.com/bentwnghk/lobe-chat/issues/5687) ([44e81e2](44e81e2))
* **misc**: Fix provider update issue, closes [lobehub#5676](https://github.com/bentwnghk/lobe-chat/issues/5676) ([e5d81ea](e5d81ea))
* **misc**: Optimize requests without historical messages, closes [lobehub#5174](https://github.com/bentwnghk/lobe-chat/issues/5174) ([182f8d9](182f8d9))

#### Styles

* **misc**: Update Fireworks check model and fix check error, closes [lobehub#5680](https://github.com/bentwnghk/lobe-chat/issues/5680) ([64ea539](64ea539))
* **misc**: Update perplexity models, closes [lobehub#5624](https://github.com/bentwnghk/lobe-chat/issues/5624) ([58a86fc](58a86fc))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💄 Design Design an style | 样式问题 released size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
6 participants