From e04cdd9f076b011d22a8ad0b5edb7cf41cf3883f Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Fri, 13 Sep 2024 23:28:45 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20o1=20model=20list?= =?UTF-8?q?=20(#3957)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/libs/agent-runtime/openai/index.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 5b9d86202f8f..e0ed22c35080 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/libs/agent-runtime/openai/index.ts b/src/libs/agent-runtime/openai/index.ts index 61ca33aeb03f..d4d718df4b49 100644 --- a/src/libs/agent-runtime/openai/index.ts +++ b/src/libs/agent-runtime/openai/index.ts @@ -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) => ({ @@ -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 };