mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
4.8.16 test (#3442)
* perf: simple app save * fix: notify config i18n * perf: service side props render * perf: model selector * update doc
This commit is contained in:
6
packages/global/core/ai/model.d.ts
vendored
6
packages/global/core/ai/model.d.ts
vendored
@@ -1,7 +1,10 @@
|
||||
import type { ModelProviderIdType } from './provider';
|
||||
|
||||
export type LLMModelItemType = {
|
||||
provider: ModelProviderIdType;
|
||||
model: string;
|
||||
name: string;
|
||||
avatar?: string;
|
||||
avatar?: string; // model icon, from provider
|
||||
maxContext: number;
|
||||
maxResponse: number;
|
||||
quoteMaxToken: number;
|
||||
@@ -31,6 +34,7 @@ export type LLMModelItemType = {
|
||||
};
|
||||
|
||||
export type VectorModelItemType = {
|
||||
provider: ModelProviderIdType;
|
||||
model: string; // model name
|
||||
name: string; // show name
|
||||
avatar?: string;
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import type { LLMModelItemType, VectorModelItemType } from './model.d';
|
||||
import { getModelProvider, ModelProviderIdType } from './provider';
|
||||
|
||||
export const defaultQAModels: LLMModelItemType[] = [
|
||||
{
|
||||
provider: 'OpenAI',
|
||||
model: 'gpt-4o-mini',
|
||||
name: 'gpt-4o-mini',
|
||||
maxContext: 16000,
|
||||
@@ -23,6 +25,7 @@ export const defaultQAModels: LLMModelItemType[] = [
|
||||
|
||||
export const defaultVectorModels: VectorModelItemType[] = [
|
||||
{
|
||||
provider: 'OpenAI',
|
||||
model: 'text-embedding-3-small',
|
||||
name: 'Embedding-2',
|
||||
charsPointsPrice: 0,
|
||||
@@ -31,3 +34,15 @@ export const defaultVectorModels: VectorModelItemType[] = [
|
||||
weight: 100
|
||||
}
|
||||
];
|
||||
|
||||
export const getModelFromList = (
|
||||
modelList: { provider: ModelProviderIdType; name: string; model: string }[],
|
||||
model: string
|
||||
) => {
|
||||
const modelData = modelList.find((item) => item.model === model) ?? modelList[0];
|
||||
const provider = getModelProvider(modelData.provider);
|
||||
return {
|
||||
...modelData,
|
||||
avatar: provider.avatar
|
||||
};
|
||||
};
|
||||
|
121
packages/global/core/ai/provider.ts
Normal file
121
packages/global/core/ai/provider.ts
Normal file
@@ -0,0 +1,121 @@
|
||||
import { i18nT } from '../../../web/i18n/utils';
|
||||
|
||||
export type ModelProviderIdType =
|
||||
| 'OpenAI'
|
||||
| 'Claude'
|
||||
| 'Gemini'
|
||||
| 'MistralAI'
|
||||
| 'Qwen'
|
||||
| 'Doubao'
|
||||
| 'ChatGLM'
|
||||
| 'DeepSeek'
|
||||
| 'Moonshot'
|
||||
| 'MiniMax'
|
||||
| 'SparkDesk'
|
||||
| 'Hunyuan'
|
||||
| 'Baichuan'
|
||||
| 'Yi'
|
||||
| 'Ernie'
|
||||
| 'Ollama'
|
||||
| 'Other';
|
||||
|
||||
export type ModelProviderType = {
|
||||
id: ModelProviderIdType;
|
||||
name: string;
|
||||
avatar: string;
|
||||
};
|
||||
|
||||
export const ModelProviderList: ModelProviderType[] = [
|
||||
{
|
||||
id: 'OpenAI',
|
||||
name: 'OpenAI',
|
||||
avatar: 'model/openai'
|
||||
},
|
||||
{
|
||||
id: 'Claude',
|
||||
name: 'Claude',
|
||||
avatar: 'model/claude'
|
||||
},
|
||||
{
|
||||
id: 'Gemini',
|
||||
name: 'Gemini',
|
||||
avatar: 'model/gemini'
|
||||
},
|
||||
{
|
||||
id: 'MistralAI',
|
||||
name: 'MistralAI',
|
||||
avatar: 'model/huggingface'
|
||||
},
|
||||
{
|
||||
id: 'Qwen',
|
||||
name: i18nT('common:model_qwen'),
|
||||
avatar: 'model/qwen'
|
||||
},
|
||||
{
|
||||
id: 'Doubao',
|
||||
name: i18nT('common:model_doubao'),
|
||||
avatar: 'model/doubao'
|
||||
},
|
||||
{
|
||||
id: 'ChatGLM',
|
||||
name: i18nT('common:model_chatglm'),
|
||||
avatar: 'model/chatglm'
|
||||
},
|
||||
{
|
||||
id: 'DeepSeek',
|
||||
name: 'DeepSeek',
|
||||
avatar: 'model/deepseek'
|
||||
},
|
||||
{
|
||||
id: 'Moonshot',
|
||||
name: i18nT('common:model_moonshot'),
|
||||
avatar: 'model/moonshot'
|
||||
},
|
||||
{
|
||||
id: 'MiniMax',
|
||||
name: 'MiniMax',
|
||||
avatar: 'model/minimax'
|
||||
},
|
||||
{
|
||||
id: 'SparkDesk',
|
||||
name: i18nT('common:model_sparkdesk'),
|
||||
avatar: 'model/sparkDesk'
|
||||
},
|
||||
{
|
||||
id: 'Hunyuan',
|
||||
name: i18nT('common:model_hunyuan'),
|
||||
avatar: 'model/hunyuan'
|
||||
},
|
||||
{
|
||||
id: 'Baichuan',
|
||||
name: i18nT('common:model_baichuan'),
|
||||
avatar: 'model/baichuan'
|
||||
},
|
||||
{
|
||||
id: 'Yi',
|
||||
name: i18nT('common:model_yi'),
|
||||
avatar: 'model/yi'
|
||||
},
|
||||
{
|
||||
id: 'Ernie',
|
||||
name: i18nT('common:model_ernie'),
|
||||
avatar: 'model/ernie'
|
||||
},
|
||||
{
|
||||
id: 'Ollama',
|
||||
name: 'Ollama',
|
||||
avatar: 'model/ollama'
|
||||
},
|
||||
{
|
||||
id: 'Other',
|
||||
name: i18nT('common:model_other'),
|
||||
avatar: 'model/huggingface'
|
||||
}
|
||||
];
|
||||
export const ModelProviderMap = Object.fromEntries(
|
||||
ModelProviderList.map((item) => [item.id, item])
|
||||
);
|
||||
|
||||
export const getModelProvider = (provider: ModelProviderIdType) => {
|
||||
return ModelProviderMap[provider] ?? ModelProviderMap.Other;
|
||||
};
|
Reference in New Issue
Block a user