feat: add gpt-4o-mini in OpenAI Provider and set it as the default model (#3256)

*  feat: gpt-4o-mini to openai provider

* ♻️ refactor: move gpt-4o-mini as default model

*  test: fix test

* 🐛 fix: set gpt-4o-mini as default model

* chore: improve code

* chore: improve code

---------

Co-authored-by: arvinxx <arvinx@foxmail.com>
This commit is contained in:
Linghui Gong 2024-07-19 21:09:02 +08:00 committed by GitHub
parent 52d2b9d3f0
commit a84d8073e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 70 additions and 66 deletions

View file

@ -23,7 +23,7 @@ module.exports = defineConfig({
'vi-VN', 'vi-VN',
], ],
temperature: 0, temperature: 0,
modelName: 'gpt-3.5-turbo-0125', modelName: 'gpt-4o-mini',
splitToken: 2048, splitToken: 2048,
experimental: { experimental: {
jsonMode: true, jsonMode: true,

View file

@ -2,7 +2,7 @@ const { defineConfig } = require('@lobehub/seo-cli');
module.exports = defineConfig({ module.exports = defineConfig({
entry: ['./docs/**/*.mdx'], entry: ['./docs/**/*.mdx'],
modelName: 'gpt-3.5-turbo-0125', modelName: 'gpt-4o-mini',
experimental: { experimental: {
jsonMode: true, jsonMode: true,
}, },

View file

@ -4,48 +4,40 @@ import { ModelProviderCard } from '@/types/llm';
const OpenAI: ModelProviderCard = { const OpenAI: ModelProviderCard = {
chatModels: [ chatModels: [
{ {
description: 'GPT 3.5 Turbo适用于各种文本生成和理解任务', description: 'Currently points to gpt-4o-mini-2024-07-18',
displayName: 'GPT-3.5 Turbo', displayName: 'GPT-4o mini',
enabled: true, enabled: true,
functionCall: true, functionCall: true,
id: 'gpt-3.5-turbo', id: 'gpt-4o-mini',
tokens: 16_385, maxOutput: 16_385,
tokens: 128_000,
vision: true,
}, },
{ {
displayName: 'GPT-3.5 Turbo (0125)', description: 'Currently points to gpt-4o-2024-05-13',
displayName: 'GPT-4o',
enabled: true,
functionCall: true, functionCall: true,
id: 'gpt-3.5-turbo-0125', id: 'gpt-4o',
tokens: 16_385, tokens: 128_000,
vision: true,
}, },
{ {
displayName: 'GPT-3.5 Turbo (1106)', description: 'GPT-4 Turbo with Vision',
displayName: 'GPT-4 Turbo',
enabled: true,
functionCall: true, functionCall: true,
id: 'gpt-3.5-turbo-1106', id: 'gpt-4-turbo',
tokens: 16_385, tokens: 128_000,
vision: true,
}, },
{ {
displayName: 'GPT-3.5 Turbo Instruct', description: 'GPT-4 Turbo 视觉版 (240409)',
id: 'gpt-3.5-turbo-instruct', displayName: 'GPT-4 Turbo Vision (240409)',
tokens: 4096, functionCall: true,
}, id: 'gpt-4-turbo-2024-04-09',
{ tokens: 128_000,
description: 'Currently points to gpt-3.5-turbo-16k-0613', vision: true,
displayName: 'GPT-3.5 Turbo 16K',
id: 'gpt-3.5-turbo-16k',
legacy: true,
tokens: 16_385,
},
{
displayName: 'GPT-3.5 Turbo (0613)',
id: 'gpt-3.5-turbo-0613',
legacy: true,
tokens: 4096,
},
{
displayName: 'GPT-3.5 Turbo 16K (0613)',
id: 'gpt-3.5-turbo-16k-0613',
legacy: true,
tokens: 16_385,
}, },
{ {
description: 'Currently points to gpt-4-0125-preview', description: 'Currently points to gpt-4-0125-preview',
@ -106,33 +98,50 @@ const OpenAI: ModelProviderCard = {
tokens: 32_768, tokens: 32_768,
}, },
{ {
description: 'GPT-4 Turbo with Vision', description: 'GPT 3.5 Turbo适用于各种文本生成和理解任务',
displayName: 'GPT-4 Turbo', displayName: 'GPT-3.5 Turbo',
enabled: true,
functionCall: true, functionCall: true,
id: 'gpt-4-turbo', id: 'gpt-3.5-turbo',
tokens: 128_000, tokens: 16_385,
vision: true,
}, },
{ {
description: 'GPT-4 Turbo 视觉版 (240409)', displayName: 'GPT-3.5 Turbo (0125)',
displayName: 'GPT-4 Turbo Vision (240409)',
functionCall: true, functionCall: true,
id: 'gpt-4-turbo-2024-04-09', id: 'gpt-3.5-turbo-0125',
tokens: 128_000, tokens: 16_385,
vision: true,
}, },
{ {
description: 'Currently points to gpt-4o-2024-05-13', displayName: 'GPT-3.5 Turbo (1106)',
displayName: 'GPT-4o',
enabled: true,
functionCall: true, functionCall: true,
id: 'gpt-4o', id: 'gpt-3.5-turbo-1106',
tokens: 128_000, tokens: 16_385,
vision: true, },
{
displayName: 'GPT-3.5 Turbo Instruct',
id: 'gpt-3.5-turbo-instruct',
tokens: 4096,
},
{
description: 'Currently points to gpt-3.5-turbo-16k-0613',
displayName: 'GPT-3.5 Turbo 16K',
id: 'gpt-3.5-turbo-16k',
legacy: true,
tokens: 16_385,
},
{
displayName: 'GPT-3.5 Turbo (0613)',
id: 'gpt-3.5-turbo-0613',
legacy: true,
tokens: 4096,
},
{
displayName: 'GPT-3.5 Turbo 16K (0613)',
id: 'gpt-3.5-turbo-16k-0613',
legacy: true,
tokens: 16_385,
}, },
], ],
checkModel: 'gpt-3.5-turbo', checkModel: 'gpt-4o-mini',
enabled: true, enabled: true,
id: 'openai', id: 'openai',
modelList: { showModelFetcher: true }, modelList: { showModelFetcher: true },

View file

@ -1,4 +1,5 @@
import { DEFAULT_AGENT_META } from '@/const/meta'; import { DEFAULT_AGENT_META } from '@/const/meta';
import { DEFAULT_MODEL } from '@/const/settings/llm';
import { ModelProvider } from '@/libs/agent-runtime'; import { ModelProvider } from '@/libs/agent-runtime';
import { LobeAgentChatConfig, LobeAgentConfig, LobeAgentTTSConfig } from '@/types/agent'; import { LobeAgentChatConfig, LobeAgentConfig, LobeAgentTTSConfig } from '@/types/agent';
import { UserDefaultAgent } from '@/types/user/settings'; import { UserDefaultAgent } from '@/types/user/settings';
@ -21,7 +22,7 @@ export const DEFAULT_AGENT_CHAT_CONFIG: LobeAgentChatConfig = {
export const DEFAULT_AGENT_CONFIG: LobeAgentConfig = { export const DEFAULT_AGENT_CONFIG: LobeAgentConfig = {
chatConfig: DEFAULT_AGENT_CHAT_CONFIG, chatConfig: DEFAULT_AGENT_CHAT_CONFIG,
model: 'gpt-3.5-turbo', model: DEFAULT_MODEL,
params: { params: {
frequency_penalty: 0, frequency_penalty: 0,
presence_penalty: 0, presence_penalty: 0,

View file

@ -111,6 +111,6 @@ export const DEFAULT_LLM_CONFIG: UserModelProviderConfig = {
}, },
}; };
export const DEFAULT_MODEL = 'gpt-3.5-turbo'; export const DEFAULT_MODEL = 'gpt-4o-mini';
export const DEFAULT_PROVIDER = ModelProvider.OpenAI; export const DEFAULT_PROVIDER = ModelProvider.OpenAI;

View file

@ -1,5 +1,6 @@
import { z } from 'zod'; import { z } from 'zod';
import { DEFAULT_MODEL } from '@/const/settings';
import { AgentChatConfigSchema } from '@/types/agent'; import { AgentChatConfigSchema } from '@/types/agent';
import { LobeMetaDataSchema } from '@/types/meta'; import { LobeMetaDataSchema } from '@/types/meta';
@ -26,7 +27,7 @@ const ttsSchema = z.object({
export const AgentSchema = z.object({ export const AgentSchema = z.object({
chatConfig: AgentChatConfigSchema, chatConfig: AgentChatConfigSchema,
fewShots: fewShotsSchema.optional(), fewShots: fewShotsSchema.optional(),
model: z.string().default('gpt-3.5-turbo'), model: z.string().default(DEFAULT_MODEL),
params: z.object({ params: z.object({
frequency_penalty: z.number().default(0).optional(), frequency_penalty: z.number().default(0).optional(),
max_tokens: z.number().optional(), max_tokens: z.number().optional(),

View file

@ -5,7 +5,6 @@ exports[`LobeOpenAI > models > should get models 1`] = `
{ {
"description": "GPT 3.5 Turbo适用于各种文本生成和理解任务", "description": "GPT 3.5 Turbo适用于各种文本生成和理解任务",
"displayName": "GPT-3.5 Turbo", "displayName": "GPT-3.5 Turbo",
"enabled": true,
"functionCall": true, "functionCall": true,
"id": "gpt-3.5-turbo", "id": "gpt-3.5-turbo",
"tokens": 16385, "tokens": 16385,

View file

@ -33,7 +33,7 @@ This project is led by [qnguyen3](https://twitter.com/stablequan) and [teknium](
Updated by OpenAI to point to the [latest version of GPT-3.5](/models?q=openai/gpt-3.5). Training data up to Sep 2021.", Updated by OpenAI to point to the [latest version of GPT-3.5](/models?q=openai/gpt-3.5). Training data up to Sep 2021.",
"displayName": "OpenAI: GPT-3.5 Turbo", "displayName": "OpenAI: GPT-3.5 Turbo",
"enabled": true, "enabled": false,
"functionCall": false, "functionCall": false,
"id": "openai/gpt-3.5-turbo", "id": "openai/gpt-3.5-turbo",
"maxTokens": 4096, "maxTokens": 4096,

View file

@ -213,12 +213,6 @@ export default {
}, },
model: { model: {
desc: '{{provider}} 模型', desc: '{{provider}} 模型',
list: {
'gpt-3.5-turbo': 'GPT 3.5',
'gpt-3.5-turbo-16k': 'GPT 3.5 (16K)',
'gpt-4': 'GPT 4',
'gpt-4-32k': 'GPT 4 (32K)',
},
title: '模型', title: '模型',
}, },
presencePenalty: { presencePenalty: {

View file

@ -49,7 +49,7 @@ describe('modelProviderSelectors', () => {
const s = merge(initialState, {}) as unknown as UserStore; const s = merge(initialState, {}) as unknown as UserStore;
const result = modelProviderSelectors.getDefaultEnabledModelsById('openai')(s); const result = modelProviderSelectors.getDefaultEnabledModelsById('openai')(s);
expect(result).toEqual(['gpt-3.5-turbo', 'gpt-4-turbo', 'gpt-4o']); expect(result).toEqual(['gpt-4o-mini', 'gpt-4o', 'gpt-4-turbo']);
}); });
it('should return undefined for a non-existing provider', () => { it('should return undefined for a non-existing provider', () => {

View file

@ -49,7 +49,7 @@ export const getDefaultModeProviderById = (provider: string) => (s: UserStore) =
/** /**
* get the default enabled models for a provider * get the default enabled models for a provider
* it's a default enabled model list by Lobe Chat * it's a default enabled model list by Lobe Chat
* e.g. openai is ['gpt-3.5-turbo','gpt-4-turbo'] * e.g. openai is ['gpt-4o-mini','gpt-4o','gpt-4-turbo']
*/ */
const getDefaultEnabledModelsById = (provider: string) => (s: UserStore) => { const getDefaultEnabledModelsById = (provider: string) => (s: UserStore) => {
const modelProvider = getDefaultModeProviderById(provider)(s); const modelProvider = getDefaultModeProviderById(provider)(s);

View file

@ -20,7 +20,7 @@ export interface LobeAgentConfig {
fewShots?: FewShots; fewShots?: FewShots;
/** /**
* 使 * 使
* @default gpt-3.5-turbo * @default gpt-4o-mini
*/ */
model: string; model: string;
/** /**