Skip to content

Commit

Permalink
🐛 fix: fix o1 model list (lobehub#3957)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx authored Sep 13, 2024
1 parent 1a1572b commit e04cdd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"@langchain/community": "^0.2.31",
"@lobehub/chat-plugin-sdk": "^1.32.4",
"@lobehub/chat-plugins-gateway": "^1.9.0",
"@lobehub/icons": "^1.33.3",
"@lobehub/icons": "^1.33.7",
"@lobehub/tts": "^1.24.3",
"@lobehub/ui": "^1.150.3",
"@neondatabase/serverless": "^0.9.4",
Expand Down
12 changes: 9 additions & 3 deletions src/libs/agent-runtime/openai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ import { ChatStreamPayload, ModelProvider, OpenAIChatMessage } from '../types';
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';

// TODO: 临时写法,后续要重构成 model card 展示配置
const o1Models = new Set(['o1-preview', 'o1-mini']);
const truneO1Payload = (payload: ChatStreamPayload) => ({
export const o1Models = new Set([
'o1-preview',
'o1-preview-2024-09-12',
'o1-mini',
'o1-mini-2024-09-12',
]);

export const pruneO1Payload = (payload: ChatStreamPayload) => ({
...payload,
frequency_penalty: 0,
messages: payload.messages.map((message: OpenAIChatMessage) => ({
Expand All @@ -23,7 +29,7 @@ export const LobeOpenAI = LobeOpenAICompatibleFactory({
const { model } = payload;

if (o1Models.has(model)) {
return truneO1Payload(payload) as any;
return pruneO1Payload(payload) as any;
}

return { ...payload, stream: payload.stream ?? true };
Expand Down

0 comments on commit e04cdd9

Please sign in to comment.