mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-18 17:51:24 +00:00
feat: ai proxy v1 (#3898)
* feat: ai proxy v1 * perf: ai proxy channel crud * feat: ai proxy logs * feat: channel test * doc * update lock
This commit is contained in:
128
projects/app/src/global/aiproxy/constants.ts
Normal file
128
projects/app/src/global/aiproxy/constants.ts
Normal file
@@ -0,0 +1,128 @@
|
||||
import { ModelProviderIdType } from '@fastgpt/global/core/ai/provider';
|
||||
import { ChannelInfoType } from './type';
|
||||
import { i18nT } from '@fastgpt/web/i18n/utils';
|
||||
|
||||
export enum ChannelStatusEnum {
|
||||
ChannelStatusUnknown = 0,
|
||||
ChannelStatusEnabled = 1,
|
||||
ChannelStatusDisabled = 2,
|
||||
ChannelStatusAutoDisabled = 3
|
||||
}
|
||||
export const ChannelStautsMap = {
|
||||
[ChannelStatusEnum.ChannelStatusUnknown]: {
|
||||
label: i18nT('account_model:channel_status_unknown'),
|
||||
colorSchema: 'gray'
|
||||
},
|
||||
[ChannelStatusEnum.ChannelStatusEnabled]: {
|
||||
label: i18nT('account_model:channel_status_enabled'),
|
||||
colorSchema: 'green'
|
||||
},
|
||||
[ChannelStatusEnum.ChannelStatusDisabled]: {
|
||||
label: i18nT('account_model:channel_status_disabled'),
|
||||
colorSchema: 'red'
|
||||
},
|
||||
[ChannelStatusEnum.ChannelStatusAutoDisabled]: {
|
||||
label: i18nT('account_model:channel_status_auto_disabled'),
|
||||
colorSchema: 'gray'
|
||||
}
|
||||
};
|
||||
|
||||
export const defaultChannel: ChannelInfoType = {
|
||||
id: 0,
|
||||
status: ChannelStatusEnum.ChannelStatusEnabled,
|
||||
type: 1,
|
||||
created_at: 0,
|
||||
models: [],
|
||||
model_mapping: {},
|
||||
key: '',
|
||||
name: '',
|
||||
base_url: '',
|
||||
priority: 0
|
||||
};
|
||||
|
||||
export const aiproxyIdMap: Record<number, { label: string; provider: ModelProviderIdType }> = {
|
||||
1: {
|
||||
label: 'OpenAI',
|
||||
provider: 'OpenAI'
|
||||
},
|
||||
3: {
|
||||
label: i18nT('account_model:azure'),
|
||||
provider: 'OpenAI'
|
||||
},
|
||||
14: {
|
||||
label: 'Anthropic',
|
||||
provider: 'Claude'
|
||||
},
|
||||
12: {
|
||||
label: 'Google Gemini(OpenAI)',
|
||||
provider: 'Gemini'
|
||||
},
|
||||
24: {
|
||||
label: 'Google Gemini',
|
||||
provider: 'Gemini'
|
||||
},
|
||||
28: {
|
||||
label: 'Mistral AI',
|
||||
provider: 'MistralAI'
|
||||
},
|
||||
29: {
|
||||
label: 'Groq',
|
||||
provider: 'Groq'
|
||||
},
|
||||
17: {
|
||||
label: '阿里云',
|
||||
provider: 'Qwen'
|
||||
},
|
||||
40: {
|
||||
label: '豆包',
|
||||
provider: 'Doubao'
|
||||
},
|
||||
36: {
|
||||
label: 'DeepSeek AI',
|
||||
provider: 'DeepSeek'
|
||||
},
|
||||
13: {
|
||||
label: '百度智能云 V2',
|
||||
provider: 'Ernie'
|
||||
},
|
||||
15: {
|
||||
label: '百度智能云',
|
||||
provider: 'Ernie'
|
||||
},
|
||||
16: {
|
||||
label: '智谱 AI',
|
||||
provider: 'ChatGLM'
|
||||
},
|
||||
18: {
|
||||
label: '讯飞星火',
|
||||
provider: 'SparkDesk'
|
||||
},
|
||||
25: {
|
||||
label: '月之暗面',
|
||||
provider: 'Moonshot'
|
||||
},
|
||||
26: {
|
||||
label: '百川智能',
|
||||
provider: 'Baichuan'
|
||||
},
|
||||
27: {
|
||||
label: 'MiniMax',
|
||||
provider: 'MiniMax'
|
||||
},
|
||||
31: {
|
||||
label: '零一万物',
|
||||
provider: 'Yi'
|
||||
},
|
||||
32: {
|
||||
label: '阶跃星辰',
|
||||
provider: 'StepFun'
|
||||
},
|
||||
43: {
|
||||
label: 'SiliconFlow',
|
||||
provider: 'Siliconflow'
|
||||
},
|
||||
30: {
|
||||
label: 'Ollama',
|
||||
provider: 'Ollama'
|
||||
}
|
||||
};
|
47
projects/app/src/global/aiproxy/type.d.ts
vendored
Normal file
47
projects/app/src/global/aiproxy/type.d.ts
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import { ChannelStatusEnum } from './constants';
|
||||
|
||||
export type ChannelInfoType = {
|
||||
model_mapping: Record<string, any>;
|
||||
key: string;
|
||||
name: string;
|
||||
base_url: string;
|
||||
models: any[];
|
||||
id: number;
|
||||
status: ChannelStatusEnum;
|
||||
type: number;
|
||||
created_at: number;
|
||||
priority: number;
|
||||
};
|
||||
|
||||
// Channel api
|
||||
export type ChannelListQueryType = {
|
||||
page: number;
|
||||
perPage: number;
|
||||
};
|
||||
export type ChannelListResponseType = ChannelInfoType[];
|
||||
|
||||
export type CreateChannelProps = {
|
||||
type: number;
|
||||
model_mapping: Record<string, any>;
|
||||
key?: string;
|
||||
name: string;
|
||||
base_url: string;
|
||||
models: string[];
|
||||
};
|
||||
|
||||
// Log
|
||||
export type ChannelLogListItemType = {
|
||||
token_name: string;
|
||||
model: string;
|
||||
request_id: string;
|
||||
id: number;
|
||||
channel: number;
|
||||
mode: number;
|
||||
created_at: number;
|
||||
request_at: number;
|
||||
code: number;
|
||||
prompt_tokens: number;
|
||||
completion_tokens: number;
|
||||
endpoint: string;
|
||||
content?: string;
|
||||
};
|
Reference in New Issue
Block a user