V4.8.20 feature (#3686)
* Aiproxy (#3649) * model config * feat: model config ui * perf: rename variable * feat: custom request url * perf: model buffer * perf: init model * feat: json model config * auto login * fix: ts * update packages * package * fix: dockerfile * feat: usage filter & export & dashbord (#3538) * feat: usage filter & export & dashbord * adjust ui * fix tmb scroll * fix code & selecte all * merge * perf: usages list;perf: move components (#3654) * perf: usages list * team sub plan load * perf: usage dashboard code * perf: dashboard ui * perf: move components * add default model config (#3653) * 4.8.20 test (#3656) * provider * perf: model config * model perf (#3657) * fix: model * dataset quote * perf: model config * model tag * doubao model config * perf: config model * feat: model test * fix: POST 500 error on dingtalk bot (#3655) * feat: default model (#3662) * move model config * feat: default model * fix: false triggerd org selection (#3661) * export usage csv i18n (#3660) * export usage csv i18n * fix build * feat: markdown extension (#3663) * feat: markdown extension * media cros * rerank test * default price * perf: default model * fix: cannot custom provider * fix: default model select * update bg * perf: default model selector * fix: usage export * i18n * fix: rerank * update init extension * perf: ip limit check * doubao model order * web default modle * perf: tts selector * perf: tts error * qrcode package * reload buffer (#3665) * reload buffer * reload buffer * tts selector * fix: err tip (#3666) * fix: err tip * perf: training queue * doc * fix interactive edge (#3659) * fix interactive edge * fix * comment * add gemini model * fix: chat model select * perf: supplement assistant empty response (#3669) * perf: supplement assistant empty response * check array * perf: max_token count;feat: support resoner output;fix: member scroll (#3681) * perf: supplement assistant empty response * check array * perf: max_token count * feat: support resoner output * member scroll * update provider order * i18n * fix: stream response (#3682) * perf: supplement assistant empty response * check array * fix: stream response * fix: model config cannot set to null * fix: reasoning response (#3684) * perf: supplement assistant empty response * check array * fix: reasoning response * fix: reasoning response * doc (#3685) * perf: supplement assistant empty response * check array * doc * lock * animation * update doc * update compose * doc * doc --------- Co-authored-by: heheer <heheer@sealos.io> Co-authored-by: a.e. <49438478+I-Info@users.noreply.github.com>
@@ -2,12 +2,22 @@ import { ErrType } from '../errorCode';
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* team: 503000 */
|
||||
export enum UserErrEnum {
|
||||
notUser = 'notUser',
|
||||
userExist = 'userExist',
|
||||
unAuthRole = 'unAuthRole',
|
||||
account_psw_error = 'account_psw_error',
|
||||
balanceNotEnough = 'balanceNotEnough',
|
||||
unAuthSso = 'unAuthSso'
|
||||
}
|
||||
const errList = [
|
||||
{
|
||||
statusText: UserErrEnum.notUser,
|
||||
message: i18nT('common:code_error.account_not_found')
|
||||
},
|
||||
{
|
||||
statusText: UserErrEnum.userExist,
|
||||
message: i18nT('common:code_error.account_exist')
|
||||
},
|
||||
{
|
||||
statusText: UserErrEnum.account_psw_error,
|
||||
message: i18nT('common:code_error.account_error')
|
||||
|
||||
14
packages/global/common/system/types/index.d.ts
vendored
@@ -3,7 +3,7 @@ import type {
|
||||
ChatModelItemType,
|
||||
FunctionModelItemType,
|
||||
LLMModelItemType,
|
||||
VectorModelItemType,
|
||||
EmbeddingModelItemType,
|
||||
AudioSpeechModels,
|
||||
STTModelType,
|
||||
ReRankModelItemType
|
||||
@@ -31,11 +31,13 @@ export type FastGPTConfigFileType = {
|
||||
feConfigs: FastGPTFeConfigsType;
|
||||
systemEnv: SystemEnvType;
|
||||
subPlans?: SubPlanType;
|
||||
llmModels: ChatModelItemType[];
|
||||
vectorModels: VectorModelItemType[];
|
||||
reRankModels: ReRankModelItemType[];
|
||||
audioSpeechModels: AudioSpeechModelType[];
|
||||
whisperModel: STTModelType;
|
||||
|
||||
// Abandon
|
||||
llmModels?: ChatModelItemType[];
|
||||
vectorModels?: EmbeddingModelItemType[];
|
||||
reRankModels?: ReRankModelItemType[];
|
||||
audioSpeechModels?: TTSModelType[];
|
||||
whisperModel?: STTModelType;
|
||||
};
|
||||
|
||||
export type FastGPTFeConfigsType = {
|
||||
|
||||
@@ -15,15 +15,13 @@ export enum LLMModelTypeEnum {
|
||||
all = 'all',
|
||||
classify = 'classify',
|
||||
extractFields = 'extractFields',
|
||||
toolCall = 'toolCall',
|
||||
queryExtension = 'queryExtension'
|
||||
toolCall = 'toolCall'
|
||||
}
|
||||
export const llmModelTypeFilterMap = {
|
||||
[LLMModelTypeEnum.all]: 'model',
|
||||
[LLMModelTypeEnum.classify]: 'usedInClassify',
|
||||
[LLMModelTypeEnum.extractFields]: 'usedInExtractFields',
|
||||
[LLMModelTypeEnum.toolCall]: 'usedInToolCall',
|
||||
[LLMModelTypeEnum.queryExtension]: 'usedInQueryExtension'
|
||||
[LLMModelTypeEnum.toolCall]: 'usedInToolCall'
|
||||
};
|
||||
|
||||
export enum EmbeddingTypeEnm {
|
||||
|
||||
115
packages/global/core/ai/model.d.ts
vendored
@@ -1,3 +1,4 @@
|
||||
import { ModelTypeEnum } from './model';
|
||||
import type { ModelProviderIdType } from './provider';
|
||||
|
||||
type PriceType = {
|
||||
@@ -7,68 +8,74 @@ type PriceType = {
|
||||
inputPrice?: number; // 1k tokens=n points
|
||||
outputPrice?: number; // 1k tokens=n points
|
||||
};
|
||||
export type LLMModelItemType = PriceType & {
|
||||
type BaseModelItemType = {
|
||||
provider: ModelProviderIdType;
|
||||
model: string;
|
||||
name: string;
|
||||
avatar?: string; // model icon, from provider
|
||||
maxContext: number;
|
||||
maxResponse: number;
|
||||
quoteMaxToken: number;
|
||||
maxTemperature: number;
|
||||
|
||||
censor?: boolean;
|
||||
vision?: boolean;
|
||||
isActive?: boolean;
|
||||
isCustom?: boolean;
|
||||
isDefault?: boolean;
|
||||
|
||||
// diff function model
|
||||
datasetProcess?: boolean; // dataset
|
||||
usedInClassify?: boolean; // classify
|
||||
usedInExtractFields?: boolean; // extract fields
|
||||
usedInToolCall?: boolean; // tool call
|
||||
usedInQueryExtension?: boolean; // query extension
|
||||
|
||||
functionCall: boolean;
|
||||
toolChoice: boolean;
|
||||
|
||||
customCQPrompt: string;
|
||||
customExtractPrompt: string;
|
||||
|
||||
defaultSystemChatPrompt?: string;
|
||||
defaultConfig?: Record<string, any>;
|
||||
fieldMap?: Record<string, string>;
|
||||
// If has requestUrl, it will request the model directly
|
||||
requestUrl?: string;
|
||||
requestAuth?: string;
|
||||
};
|
||||
|
||||
export type VectorModelItemType = PriceType & {
|
||||
provider: ModelProviderIdType;
|
||||
model: string; // model name
|
||||
name: string; // show name
|
||||
avatar?: string;
|
||||
defaultToken: number; // split text default token
|
||||
maxToken: number; // model max token
|
||||
weight: number; // training weight
|
||||
hidden?: boolean; // Disallow creation
|
||||
defaultConfig?: Record<string, any>; // post request config
|
||||
dbConfig?: Record<string, any>; // Custom parameters for storage
|
||||
queryConfig?: Record<string, any>; // Custom parameters for query
|
||||
};
|
||||
export type LLMModelItemType = PriceType &
|
||||
BaseModelItemType & {
|
||||
type: ModelTypeEnum.llm;
|
||||
maxContext: number;
|
||||
maxResponse: number;
|
||||
quoteMaxToken: number;
|
||||
maxTemperature?: number;
|
||||
|
||||
export type ReRankModelItemType = PriceType & {
|
||||
provider: ModelProviderIdType;
|
||||
model: string;
|
||||
name: string;
|
||||
requestUrl: string;
|
||||
requestAuth: string;
|
||||
};
|
||||
censor?: boolean;
|
||||
vision?: boolean;
|
||||
reasoning?: boolean;
|
||||
|
||||
export type AudioSpeechModelType = PriceType & {
|
||||
provider: ModelProviderIdType;
|
||||
model: string;
|
||||
name: string;
|
||||
voices: { label: string; value: string; bufferId: string }[];
|
||||
};
|
||||
// diff function model
|
||||
datasetProcess?: boolean; // dataset
|
||||
usedInClassify?: boolean; // classify
|
||||
usedInExtractFields?: boolean; // extract fields
|
||||
usedInToolCall?: boolean; // tool call
|
||||
|
||||
export type STTModelType = PriceType & {
|
||||
provider: ModelProviderIdType;
|
||||
model: string;
|
||||
name: string;
|
||||
};
|
||||
functionCall: boolean;
|
||||
toolChoice: boolean;
|
||||
|
||||
customCQPrompt: string;
|
||||
customExtractPrompt: string;
|
||||
|
||||
defaultSystemChatPrompt?: string;
|
||||
defaultConfig?: Record<string, any>;
|
||||
fieldMap?: Record<string, string>;
|
||||
};
|
||||
|
||||
export type EmbeddingModelItemType = PriceType &
|
||||
BaseModelItemType & {
|
||||
type: ModelTypeEnum.embedding;
|
||||
defaultToken: number; // split text default token
|
||||
maxToken: number; // model max token
|
||||
weight: number; // training weight
|
||||
hidden?: boolean; // Disallow creation
|
||||
defaultConfig?: Record<string, any>; // post request config
|
||||
dbConfig?: Record<string, any>; // Custom parameters for storage
|
||||
queryConfig?: Record<string, any>; // Custom parameters for query
|
||||
};
|
||||
|
||||
export type ReRankModelItemType = PriceType &
|
||||
BaseModelItemType & {
|
||||
type: ModelTypeEnum.rerank;
|
||||
};
|
||||
|
||||
export type TTSModelType = PriceType &
|
||||
BaseModelItemType & {
|
||||
type: ModelTypeEnum.tts;
|
||||
voices: { label: string; value: string }[];
|
||||
};
|
||||
|
||||
export type STTModelType = PriceType &
|
||||
BaseModelItemType & {
|
||||
type: ModelTypeEnum.stt;
|
||||
};
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
import { i18nT } from '../../../web/i18n/utils';
|
||||
import type { LLMModelItemType, STTModelType, VectorModelItemType } from './model.d';
|
||||
import type { LLMModelItemType, STTModelType, EmbeddingModelItemType } from './model.d';
|
||||
import { getModelProvider, ModelProviderIdType } from './provider';
|
||||
|
||||
export enum ModelTypeEnum {
|
||||
llm = 'llm',
|
||||
embedding = 'embedding',
|
||||
tts = 'tts',
|
||||
stt = 'stt',
|
||||
rerank = 'rerank'
|
||||
}
|
||||
|
||||
export const defaultQAModels: LLMModelItemType[] = [
|
||||
{
|
||||
type: ModelTypeEnum.llm,
|
||||
provider: 'OpenAI',
|
||||
model: 'gpt-4o-mini',
|
||||
name: 'gpt-4o-mini',
|
||||
@@ -24,8 +33,9 @@ export const defaultQAModels: LLMModelItemType[] = [
|
||||
}
|
||||
];
|
||||
|
||||
export const defaultVectorModels: VectorModelItemType[] = [
|
||||
export const defaultVectorModels: EmbeddingModelItemType[] = [
|
||||
{
|
||||
type: ModelTypeEnum.embedding,
|
||||
provider: 'OpenAI',
|
||||
model: 'text-embedding-3-small',
|
||||
name: 'Embedding-2',
|
||||
@@ -36,12 +46,15 @@ export const defaultVectorModels: VectorModelItemType[] = [
|
||||
}
|
||||
];
|
||||
|
||||
export const defaultWhisperModel: STTModelType = {
|
||||
provider: 'OpenAI',
|
||||
model: 'whisper-1',
|
||||
name: 'whisper-1',
|
||||
charsPointsPrice: 0
|
||||
};
|
||||
export const defaultSTTModels: STTModelType[] = [
|
||||
{
|
||||
type: ModelTypeEnum.stt,
|
||||
provider: 'OpenAI',
|
||||
model: 'whisper-1',
|
||||
name: 'whisper-1',
|
||||
charsPointsPrice: 0
|
||||
}
|
||||
];
|
||||
|
||||
export const getModelFromList = (
|
||||
modelList: { provider: ModelProviderIdType; name: string; model: string }[],
|
||||
@@ -55,15 +68,10 @@ export const getModelFromList = (
|
||||
};
|
||||
};
|
||||
|
||||
export enum ModelTypeEnum {
|
||||
chat = 'chat',
|
||||
embedding = 'embedding',
|
||||
tts = 'tts',
|
||||
stt = 'stt'
|
||||
}
|
||||
export const modelTypeList = [
|
||||
{ label: i18nT('common:model.type.chat'), value: ModelTypeEnum.chat },
|
||||
{ label: i18nT('common:model.type.chat'), value: ModelTypeEnum.llm },
|
||||
{ label: i18nT('common:model.type.embedding'), value: ModelTypeEnum.embedding },
|
||||
{ label: i18nT('common:model.type.tts'), value: ModelTypeEnum.tts },
|
||||
{ label: i18nT('common:model.type.stt'), value: ModelTypeEnum.stt }
|
||||
{ label: i18nT('common:model.type.stt'), value: ModelTypeEnum.stt },
|
||||
{ label: i18nT('common:model.type.reRank'), value: ModelTypeEnum.rerank }
|
||||
];
|
||||
|
||||
@@ -7,11 +7,12 @@ export type ModelProviderIdType =
|
||||
| 'Meta'
|
||||
| 'MistralAI'
|
||||
| 'Groq'
|
||||
| 'Grok'
|
||||
| 'AliCloud'
|
||||
| 'Qwen'
|
||||
| 'Doubao'
|
||||
| 'ChatGLM'
|
||||
| 'DeepSeek'
|
||||
| 'ChatGLM'
|
||||
| 'Ernie'
|
||||
| 'Moonshot'
|
||||
| 'MiniMax'
|
||||
@@ -20,6 +21,7 @@ export type ModelProviderIdType =
|
||||
| 'Baichuan'
|
||||
| 'StepFun'
|
||||
| 'Yi'
|
||||
| 'Siliconflow'
|
||||
| 'Ollama'
|
||||
| 'BAAI'
|
||||
| 'FishAudio'
|
||||
@@ -29,7 +31,7 @@ export type ModelProviderIdType =
|
||||
|
||||
export type ModelProviderType = {
|
||||
id: ModelProviderIdType;
|
||||
name: string;
|
||||
name: any;
|
||||
avatar: string;
|
||||
};
|
||||
|
||||
@@ -59,6 +61,11 @@ export const ModelProviderList: ModelProviderType[] = [
|
||||
name: 'MistralAI',
|
||||
avatar: 'model/mistral'
|
||||
},
|
||||
{
|
||||
id: 'Grok',
|
||||
name: 'Grok',
|
||||
avatar: 'model/grok'
|
||||
},
|
||||
{
|
||||
id: 'Groq',
|
||||
name: 'Groq',
|
||||
@@ -155,6 +162,11 @@ export const ModelProviderList: ModelProviderType[] = [
|
||||
name: i18nT('common:model_moka'),
|
||||
avatar: 'model/moka'
|
||||
},
|
||||
{
|
||||
id: 'Siliconflow',
|
||||
name: i18nT('common:model_siliconflow'),
|
||||
avatar: 'model/siliconflow'
|
||||
},
|
||||
{
|
||||
id: 'Other',
|
||||
name: i18nT('common:model_other'),
|
||||
@@ -165,6 +177,7 @@ export const ModelProviderMap = Object.fromEntries(
|
||||
ModelProviderList.map((item, index) => [item.id, { ...item, order: index }])
|
||||
);
|
||||
|
||||
export const getModelProvider = (provider: ModelProviderIdType) => {
|
||||
export const getModelProvider = (provider?: ModelProviderIdType) => {
|
||||
if (!provider) return ModelProviderMap.Other;
|
||||
return ModelProviderMap[provider] ?? ModelProviderMap.Other;
|
||||
};
|
||||
|
||||
2
packages/global/core/app/type.d.ts
vendored
@@ -80,6 +80,7 @@ export type AppSimpleEditFormType = {
|
||||
maxToken?: number;
|
||||
isResponseAnswerText: boolean;
|
||||
maxHistories: number;
|
||||
[NodeInputKeyEnum.aiChatReasoning]?: boolean;
|
||||
};
|
||||
dataset: {
|
||||
datasets: SelectedDatasetType;
|
||||
@@ -117,6 +118,7 @@ export type SettingAIDataType = {
|
||||
isResponseAnswerText?: boolean;
|
||||
maxHistories?: number;
|
||||
[NodeInputKeyEnum.aiChatVision]?: boolean; // Is open vision mode
|
||||
[NodeInputKeyEnum.aiChatReasoning]?: boolean; // Is open reasoning mode
|
||||
};
|
||||
|
||||
// variable
|
||||
|
||||
@@ -16,7 +16,8 @@ export const getDefaultAppForm = (): AppSimpleEditFormType => {
|
||||
temperature: 0,
|
||||
isResponseAnswerText: true,
|
||||
maxHistories: 6,
|
||||
maxToken: 4000
|
||||
maxToken: 4000,
|
||||
aiChatReasoning: true
|
||||
},
|
||||
dataset: {
|
||||
datasets: [],
|
||||
|
||||
@@ -25,7 +25,8 @@ export enum ChatItemValueTypeEnum {
|
||||
text = 'text',
|
||||
file = 'file',
|
||||
tool = 'tool',
|
||||
interactive = 'interactive'
|
||||
interactive = 'interactive',
|
||||
reasoning = 'reasoning'
|
||||
}
|
||||
|
||||
export enum ChatSourceEnum {
|
||||
@@ -75,5 +76,3 @@ export enum ChatStatusEnum {
|
||||
running = 'running',
|
||||
finish = 'finish'
|
||||
}
|
||||
|
||||
export const MARKDOWN_QUOTE_SIGN = 'QUOTE SIGN';
|
||||
|
||||
11
packages/global/core/chat/type.d.ts
vendored
@@ -70,14 +70,23 @@ export type SystemChatItemType = {
|
||||
obj: ChatRoleEnum.System;
|
||||
value: SystemChatItemValueItemType[];
|
||||
};
|
||||
|
||||
export type AIChatItemValueItemType = {
|
||||
type: ChatItemValueTypeEnum.text | ChatItemValueTypeEnum.tool | ChatItemValueTypeEnum.interactive;
|
||||
type:
|
||||
| ChatItemValueTypeEnum.text
|
||||
| ChatItemValueTypeEnum.reasoning
|
||||
| ChatItemValueTypeEnum.tool
|
||||
| ChatItemValueTypeEnum.interactive;
|
||||
text?: {
|
||||
content: string;
|
||||
};
|
||||
reasoning?: {
|
||||
content: string;
|
||||
};
|
||||
tools?: ToolModuleResponseItemType[];
|
||||
interactive?: WorkflowInteractiveResponseType;
|
||||
};
|
||||
|
||||
export type AIChatItemType = {
|
||||
obj: ChatRoleEnum.AI;
|
||||
value: AIChatItemValueItemType[];
|
||||
|
||||
8
packages/global/core/dataset/type.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import type { LLMModelItemType, VectorModelItemType } from '../../core/ai/model.d';
|
||||
import type { LLMModelItemType, EmbeddingModelItemType } from '../../core/ai/model.d';
|
||||
import { PermissionTypeEnum } from '../../support/permission/constant';
|
||||
import { PushDatasetDataChunkProps } from './api';
|
||||
import {
|
||||
@@ -152,7 +152,7 @@ export type DatasetSimpleItemType = {
|
||||
_id: string;
|
||||
avatar: string;
|
||||
name: string;
|
||||
vectorModel: VectorModelItemType;
|
||||
vectorModel: EmbeddingModelItemType;
|
||||
};
|
||||
export type DatasetListItemType = {
|
||||
_id: string;
|
||||
@@ -163,14 +163,14 @@ export type DatasetListItemType = {
|
||||
intro: string;
|
||||
type: `${DatasetTypeEnum}`;
|
||||
permission: DatasetPermission;
|
||||
vectorModel: VectorModelItemType;
|
||||
vectorModel: EmbeddingModelItemType;
|
||||
inheritPermission: boolean;
|
||||
private?: boolean;
|
||||
sourceMember?: SourceMemberType;
|
||||
};
|
||||
|
||||
export type DatasetItemType = Omit<DatasetSchemaType, 'vectorModel' | 'agentModel'> & {
|
||||
vectorModel: VectorModelItemType;
|
||||
vectorModel: EmbeddingModelItemType;
|
||||
agentModel: LLMModelItemType;
|
||||
permission: DatasetPermission;
|
||||
};
|
||||
|
||||
2
packages/global/core/workflow/api.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { VectorModelItemType } from '../ai/model.d';
|
||||
import { EmbeddingModelItemType } from '../ai/model.d';
|
||||
import { NodeInputKeyEnum } from './constants';
|
||||
|
||||
export type SelectedDatasetType = { datasetId: string }[];
|
||||
|
||||
@@ -141,6 +141,7 @@ export enum NodeInputKeyEnum {
|
||||
aiChatDatasetQuote = 'quoteQA',
|
||||
aiChatVision = 'aiChatVision',
|
||||
stringQuoteText = 'stringQuoteText',
|
||||
aiChatReasoning = 'aiChatReasoning',
|
||||
|
||||
// dataset
|
||||
datasetSelectList = 'datasets',
|
||||
@@ -220,7 +221,8 @@ export enum NodeOutputKeyEnum {
|
||||
// common
|
||||
userChatInput = 'userChatInput',
|
||||
history = 'history',
|
||||
answerText = 'answerText', // module answer. the value will be show and save to history
|
||||
answerText = 'answerText', // node answer. the value will be show and save to history
|
||||
reasoningText = 'reasoningText', // node reasoning. the value will be show but not save to history
|
||||
success = 'success',
|
||||
failed = 'failed',
|
||||
error = 'error',
|
||||
|
||||
@@ -220,6 +220,7 @@ export type AIChatNodeProps = {
|
||||
[NodeInputKeyEnum.aiChatMaxToken]?: number;
|
||||
[NodeInputKeyEnum.aiChatIsResponseText]: boolean;
|
||||
[NodeInputKeyEnum.aiChatVision]?: boolean;
|
||||
[NodeInputKeyEnum.aiChatReasoning]?: boolean;
|
||||
|
||||
[NodeInputKeyEnum.aiChatQuoteRole]?: AiChatQuoteRoleType;
|
||||
[NodeInputKeyEnum.aiChatQuoteTemplate]?: string;
|
||||
|
||||
@@ -176,6 +176,7 @@ export const checkNodeRunStatus = ({
|
||||
}
|
||||
visited.add(edge.source);
|
||||
|
||||
// 递归检测后面的 edge,如果有其中一个成环,则返回 true
|
||||
const nextEdges = allEdges.filter((item) => item.target === edge.source);
|
||||
return nextEdges.some((nextEdge) => checkIsCircular(nextEdge, new Set(visited)));
|
||||
};
|
||||
@@ -207,7 +208,23 @@ export const checkNodeRunStatus = ({
|
||||
currentNode: node
|
||||
});
|
||||
|
||||
// check skip(其中一组边,全 skip)
|
||||
// check active(其中一组边,至少有一个 active,且没有 waiting 即可运行)
|
||||
if (
|
||||
commonEdges.length > 0 &&
|
||||
commonEdges.some((item) => item.status === 'active') &&
|
||||
commonEdges.every((item) => item.status !== 'waiting')
|
||||
) {
|
||||
return 'run';
|
||||
}
|
||||
if (
|
||||
recursiveEdges.length > 0 &&
|
||||
recursiveEdges.some((item) => item.status === 'active') &&
|
||||
recursiveEdges.every((item) => item.status !== 'waiting')
|
||||
) {
|
||||
return 'run';
|
||||
}
|
||||
|
||||
// check skip(其中一组边,全是 skiped 则跳过运行)
|
||||
if (commonEdges.length > 0 && commonEdges.every((item) => item.status === 'skipped')) {
|
||||
return 'skip';
|
||||
}
|
||||
@@ -215,14 +232,6 @@ export const checkNodeRunStatus = ({
|
||||
return 'skip';
|
||||
}
|
||||
|
||||
// check active(有一类边,不全是 wait 即可运行)
|
||||
if (commonEdges.length > 0 && commonEdges.every((item) => item.status !== 'waiting')) {
|
||||
return 'run';
|
||||
}
|
||||
if (recursiveEdges.length > 0 && recursiveEdges.every((item) => item.status !== 'waiting')) {
|
||||
return 'run';
|
||||
}
|
||||
|
||||
return 'wait';
|
||||
};
|
||||
|
||||
@@ -355,12 +364,14 @@ export function replaceEditorVariable({
|
||||
|
||||
export const textAdaptGptResponse = ({
|
||||
text,
|
||||
reasoning_content,
|
||||
model = '',
|
||||
finish_reason = null,
|
||||
extraData = {}
|
||||
}: {
|
||||
model?: string;
|
||||
text: string | null;
|
||||
text?: string | null;
|
||||
reasoning_content?: string | null;
|
||||
finish_reason?: null | 'stop';
|
||||
extraData?: Object;
|
||||
}) => {
|
||||
@@ -372,10 +383,11 @@ export const textAdaptGptResponse = ({
|
||||
model,
|
||||
choices: [
|
||||
{
|
||||
delta:
|
||||
text === null
|
||||
? {}
|
||||
: { role: ChatCompletionRequestMessageRoleEnum.Assistant, content: text },
|
||||
delta: {
|
||||
role: ChatCompletionRequestMessageRoleEnum.Assistant,
|
||||
content: text,
|
||||
...(reasoning_content && { reasoning_content })
|
||||
},
|
||||
index: 0,
|
||||
finish_reason
|
||||
}
|
||||
|
||||
@@ -63,14 +63,14 @@ export const AiChatModule: FlowNodeTemplateType = {
|
||||
key: NodeInputKeyEnum.aiChatTemperature,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
||||
label: '',
|
||||
value: 0,
|
||||
value: undefined,
|
||||
valueType: WorkflowIOValueTypeEnum.number
|
||||
},
|
||||
{
|
||||
key: NodeInputKeyEnum.aiChatMaxToken,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
||||
label: '',
|
||||
value: 2000,
|
||||
value: undefined,
|
||||
valueType: WorkflowIOValueTypeEnum.number
|
||||
},
|
||||
|
||||
@@ -91,6 +91,13 @@ export const AiChatModule: FlowNodeTemplateType = {
|
||||
valueType: WorkflowIOValueTypeEnum.boolean,
|
||||
value: true
|
||||
},
|
||||
{
|
||||
key: NodeInputKeyEnum.aiChatReasoning,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden],
|
||||
label: '',
|
||||
valueType: WorkflowIOValueTypeEnum.boolean,
|
||||
value: true
|
||||
},
|
||||
// settings modal ---
|
||||
{
|
||||
...Input_Template_System_Prompt,
|
||||
|
||||
@@ -31,10 +31,7 @@ export const AiQueryExtension: FlowNodeTemplateType = {
|
||||
showStatus: true,
|
||||
version: '481',
|
||||
inputs: [
|
||||
{
|
||||
...Input_Template_SelectAIModel,
|
||||
llmModelType: LLMModelTypeEnum.queryExtension
|
||||
},
|
||||
Input_Template_SelectAIModel,
|
||||
{
|
||||
key: NodeInputKeyEnum.aiSystemPrompt,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.textarea, FlowNodeInputTypeEnum.reference],
|
||||
|
||||
@@ -43,14 +43,14 @@ export const ToolModule: FlowNodeTemplateType = {
|
||||
key: NodeInputKeyEnum.aiChatTemperature,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
||||
label: '',
|
||||
value: 0,
|
||||
value: undefined,
|
||||
valueType: WorkflowIOValueTypeEnum.number
|
||||
},
|
||||
{
|
||||
key: NodeInputKeyEnum.aiChatMaxToken,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
||||
label: '',
|
||||
value: 2000,
|
||||
value: undefined,
|
||||
valueType: WorkflowIOValueTypeEnum.number
|
||||
},
|
||||
{
|
||||
|
||||
16
packages/global/support/wallet/usage/api.d.ts
vendored
@@ -6,6 +6,22 @@ export type CreateTrainingUsageProps = {
|
||||
datasetId: string;
|
||||
};
|
||||
|
||||
export type GetUsageProps = {
|
||||
dateStart: Date;
|
||||
dateEnd: Date;
|
||||
sources?: UsageSourceEnum[];
|
||||
teamMemberIds?: string[];
|
||||
projectName?: string;
|
||||
};
|
||||
|
||||
export type GetUsageDashboardProps = GetUsageProps & {
|
||||
unit: 'day' | 'month';
|
||||
};
|
||||
export type GetUsageDashboardResponseItem = {
|
||||
date: Date;
|
||||
totalPoints: number;
|
||||
};
|
||||
|
||||
export type ConcatUsageProps = UsageListItemCountType & {
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
|
||||
@@ -18,30 +18,30 @@ export const UsageSourceMap = {
|
||||
label: i18nT('common:core.chat.logs.online')
|
||||
},
|
||||
[UsageSourceEnum.api]: {
|
||||
label: 'Api'
|
||||
label: 'API'
|
||||
},
|
||||
[UsageSourceEnum.shareLink]: {
|
||||
label: i18nT('common:core.chat.logs.free_login')
|
||||
},
|
||||
[UsageSourceEnum.training]: {
|
||||
label: 'dataset.Training Name'
|
||||
label: i18nT('common:dataset.Training Name')
|
||||
},
|
||||
[UsageSourceEnum.cronJob]: {
|
||||
label: i18nT('common:cron_job_run_app')
|
||||
},
|
||||
[UsageSourceEnum.feishu]: {
|
||||
label: i18nT('user:usage.feishu')
|
||||
label: i18nT('account_usage:feishu')
|
||||
},
|
||||
[UsageSourceEnum.official_account]: {
|
||||
label: i18nT('user:usage.official_account')
|
||||
label: i18nT('account_usage:official_account')
|
||||
},
|
||||
[UsageSourceEnum.share]: {
|
||||
label: i18nT('user:usage.share')
|
||||
label: i18nT('account_usage:share')
|
||||
},
|
||||
[UsageSourceEnum.wecom]: {
|
||||
label: i18nT('user:usage.wecom')
|
||||
label: i18nT('account_usage:wecom')
|
||||
},
|
||||
[UsageSourceEnum.dingtalk]: {
|
||||
label: i18nT('user:usage.dingtalk')
|
||||
label: i18nT('account_usage:dingtalk')
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SourceMemberType } from '../../../support/user/type';
|
||||
import { CreateUsageProps } from './api';
|
||||
import { UsageSourceEnum } from './constants';
|
||||
|
||||
@@ -10,6 +11,7 @@ export type UsageListItemCountType = {
|
||||
// deprecated
|
||||
tokens?: number;
|
||||
};
|
||||
|
||||
export type UsageListItemType = UsageListItemCountType & {
|
||||
moduleName: string;
|
||||
amount: number;
|
||||
@@ -28,4 +30,5 @@ export type UsageItemType = {
|
||||
source: UsageSchemaType['source'];
|
||||
totalPoints: number;
|
||||
list: UsageSchemaType['list'];
|
||||
sourceMember: SourceMemberType;
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@ export async function uploadMongoImg({
|
||||
expiredTime: forever ? undefined : addHours(new Date(), 1)
|
||||
});
|
||||
|
||||
return `${process.env.FE_DOMAIN || ''}${process.env.NEXT_PUBLIC_BASE_URL || ''}${imageBaseUrl}${String(_id)}.${extension}`;
|
||||
return `${process.env.NEXT_PUBLIC_BASE_URL || ''}${imageBaseUrl}${String(_id)}.${extension}`;
|
||||
}
|
||||
|
||||
const getIdFromPath = (path?: string) => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ApiRequestProps } from '../../type/next';
|
||||
import requestIp from 'request-ip';
|
||||
import { ERROR_ENUM } from '@fastgpt/global/common/error/errorCode';
|
||||
import { authFrequencyLimit } from '../system/frequencyLimit/utils';
|
||||
import { addSeconds } from 'date-fns';
|
||||
import { NextApiResponse } from 'next';
|
||||
@@ -9,7 +8,17 @@ import { jsonRes } from '../response';
|
||||
// unit: times/s
|
||||
// how to use?
|
||||
// export default NextAPI(useQPSLimit(10), handler); // limit 10 times per second for a ip
|
||||
export function useReqFrequencyLimit(seconds: number, limit: number, force = false) {
|
||||
export function useIPFrequencyLimit({
|
||||
id,
|
||||
seconds,
|
||||
limit,
|
||||
force = false
|
||||
}: {
|
||||
id: string;
|
||||
seconds: number;
|
||||
limit: number;
|
||||
force?: boolean;
|
||||
}) {
|
||||
return async (req: ApiRequestProps, res: NextApiResponse) => {
|
||||
const ip = requestIp.getClientIp(req);
|
||||
if (!ip || (process.env.USE_IP_LIMIT !== 'true' && !force)) {
|
||||
@@ -17,14 +26,14 @@ export function useReqFrequencyLimit(seconds: number, limit: number, force = fal
|
||||
}
|
||||
try {
|
||||
await authFrequencyLimit({
|
||||
eventId: 'ip-qps-limit' + ip,
|
||||
eventId: `ip-qps-limit-${id}-` + ip,
|
||||
maxAmount: limit,
|
||||
expiredTime: addSeconds(new Date(), seconds)
|
||||
});
|
||||
} catch (_) {
|
||||
jsonRes(res, {
|
||||
code: 429,
|
||||
error: ERROR_ENUM.tooManyRequest
|
||||
error: `Too many request, request ${limit} times every ${seconds} seconds`
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -33,7 +33,15 @@ export const jsonRes = <T = any>(
|
||||
|
||||
addLog.error(`Api response error: ${url}`, ERROR_RESPONSE[errResponseKey]);
|
||||
|
||||
return res.status(code).json(ERROR_RESPONSE[errResponseKey]);
|
||||
res.status(code);
|
||||
|
||||
if (message) {
|
||||
res.send(message);
|
||||
} else {
|
||||
res.json(ERROR_RESPONSE[errResponseKey]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// another error
|
||||
|
||||
@@ -6,8 +6,7 @@ import { FastGPTProUrl } from '../constants';
|
||||
export const getFastGPTConfigFromDB = async () => {
|
||||
if (!FastGPTProUrl) {
|
||||
return {
|
||||
config: {} as FastGPTConfigFileType,
|
||||
configId: undefined
|
||||
config: {} as FastGPTConfigFileType
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,9 +17,35 @@ export const getFastGPTConfigFromDB = async () => {
|
||||
});
|
||||
|
||||
const config = res?.value || {};
|
||||
// 利用配置文件的创建时间(更新时间)来做缓存,如果前端命中缓存,则不需要再返回配置文件
|
||||
global.systemInitBufferId = res ? res.createTime.getTime().toString() : undefined;
|
||||
|
||||
return {
|
||||
configId: res ? String(res._id) : undefined,
|
||||
config: config as FastGPTConfigFileType
|
||||
};
|
||||
};
|
||||
|
||||
export const updateFastGPTConfigBuffer = async () => {
|
||||
const res = await MongoSystemConfigs.findOne({
|
||||
type: SystemConfigsTypeEnum.fastgpt
|
||||
}).sort({
|
||||
createTime: -1
|
||||
});
|
||||
|
||||
if (!res) return;
|
||||
|
||||
res.createTime = new Date();
|
||||
await res.save();
|
||||
|
||||
global.systemInitBufferId = res.createTime.getTime().toString();
|
||||
};
|
||||
|
||||
export const reloadFastGPTConfigBuffer = async () => {
|
||||
const res = await MongoSystemConfigs.findOne({
|
||||
type: SystemConfigsTypeEnum.fastgpt
|
||||
}).sort({
|
||||
createTime: -1
|
||||
});
|
||||
if (!res) return;
|
||||
global.systemInitBufferId = res.createTime.getTime().toString();
|
||||
};
|
||||
|
||||
@@ -13,15 +13,6 @@ export const initFastGPTConfig = (config?: FastGPTConfigFileType) => {
|
||||
global.feConfigs = config.feConfigs;
|
||||
global.systemEnv = config.systemEnv;
|
||||
global.subPlans = config.subPlans;
|
||||
|
||||
global.llmModels = config.llmModels;
|
||||
global.llmModelPriceType = global.llmModels.some((item) => typeof item.inputPrice === 'number')
|
||||
? 'IO'
|
||||
: 'Tokens';
|
||||
global.vectorModels = config.vectorModels;
|
||||
global.audioSpeechModels = config.audioSpeechModels;
|
||||
global.whisperModel = config.whisperModel;
|
||||
global.reRankModels = config.reRankModels;
|
||||
};
|
||||
|
||||
export const systemStartCb = () => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { PgVectorCtrl } from './pg/class';
|
||||
import { getVectorsByText } from '../../core/ai/embedding';
|
||||
import { InsertVectorProps } from './controller.d';
|
||||
import { VectorModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { EmbeddingModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { MILVUS_ADDRESS, PG_ADDRESS } from './constants';
|
||||
import { MilvusCtrl } from './milvus/class';
|
||||
|
||||
@@ -28,7 +28,7 @@ export const insertDatasetDataVector = async ({
|
||||
...props
|
||||
}: InsertVectorProps & {
|
||||
query: string;
|
||||
model: VectorModelItemType;
|
||||
model: EmbeddingModelItemType;
|
||||
}) => {
|
||||
const { vectors, tokens } = await getVectorsByText({
|
||||
model,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { NextApiResponse } from 'next';
|
||||
import { getAIApi } from '../config';
|
||||
import { getTTSModel } from '../model';
|
||||
|
||||
export async function text2Speech({
|
||||
res,
|
||||
@@ -18,15 +19,26 @@ export async function text2Speech({
|
||||
voice: string;
|
||||
speed?: number;
|
||||
}) {
|
||||
const modelData = getTTSModel(model)!;
|
||||
const ai = getAIApi();
|
||||
const response = await ai.audio.speech.create({
|
||||
model,
|
||||
// @ts-ignore
|
||||
voice,
|
||||
input,
|
||||
response_format: 'mp3',
|
||||
speed
|
||||
});
|
||||
const response = await ai.audio.speech.create(
|
||||
{
|
||||
model,
|
||||
// @ts-ignore
|
||||
voice,
|
||||
input,
|
||||
response_format: 'mp3',
|
||||
speed
|
||||
},
|
||||
modelData.requestUrl && modelData.requestAuth
|
||||
? {
|
||||
path: modelData.requestUrl,
|
||||
headers: {
|
||||
Authorization: `Bearer ${modelData.requestAuth}`
|
||||
}
|
||||
}
|
||||
: {}
|
||||
);
|
||||
|
||||
const readableStream = response.body as unknown as NodeJS.ReadableStream;
|
||||
readableStream.pipe(res);
|
||||
|
||||
@@ -2,6 +2,7 @@ import fs from 'fs';
|
||||
import { getAxiosConfig } from '../config';
|
||||
import axios from 'axios';
|
||||
import FormData from 'form-data';
|
||||
import { getSTTModel } from '../model';
|
||||
|
||||
export const aiTranscriptions = async ({
|
||||
model,
|
||||
@@ -14,13 +15,21 @@ export const aiTranscriptions = async ({
|
||||
data.append('model', model);
|
||||
data.append('file', fileStream);
|
||||
|
||||
const modelData = getSTTModel(model);
|
||||
const aiAxiosConfig = getAxiosConfig();
|
||||
|
||||
const { data: result } = await axios<{ text: string }>({
|
||||
method: 'post',
|
||||
baseURL: aiAxiosConfig.baseUrl,
|
||||
url: '/audio/transcriptions',
|
||||
...(modelData.requestUrl
|
||||
? { url: modelData.requestUrl }
|
||||
: {
|
||||
baseURL: aiAxiosConfig.baseUrl,
|
||||
url: modelData.requestUrl || '/audio/transcriptions'
|
||||
}),
|
||||
headers: {
|
||||
Authorization: aiAxiosConfig.authorization,
|
||||
Authorization: modelData.requestAuth
|
||||
? `Bearer ${modelData.requestAuth}`
|
||||
: aiAxiosConfig.authorization,
|
||||
...data.getHeaders()
|
||||
},
|
||||
data: data
|
||||
|
||||
@@ -7,14 +7,14 @@ import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { addLog } from '../../common/system/log';
|
||||
import { i18nT } from '../../../web/i18n/utils';
|
||||
import { OpenaiAccountType } from '@fastgpt/global/support/user/team/type';
|
||||
import { getLLMModel } from './model';
|
||||
|
||||
export const openaiBaseUrl = process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1';
|
||||
|
||||
export const getAIApi = (props?: { userKey?: OpenaiAccountType; timeout?: number }) => {
|
||||
const { userKey, timeout } = props || {};
|
||||
|
||||
const baseUrl =
|
||||
userKey?.baseUrl || global?.systemEnv?.oneapiUrl || process.env.ONEAPI_URL || openaiBaseUrl;
|
||||
const baseUrl = userKey?.baseUrl || global?.systemEnv?.oneapiUrl || openaiBaseUrl;
|
||||
const apiKey = userKey?.key || global?.systemEnv?.chatApiKey || process.env.CHAT_API_KEY || '';
|
||||
|
||||
return new OpenAI({
|
||||
@@ -29,8 +29,7 @@ export const getAIApi = (props?: { userKey?: OpenaiAccountType; timeout?: number
|
||||
export const getAxiosConfig = (props?: { userKey?: OpenaiAccountType }) => {
|
||||
const { userKey } = props || {};
|
||||
|
||||
const baseUrl =
|
||||
userKey?.baseUrl || global?.systemEnv?.oneapiUrl || process.env.ONEAPI_URL || openaiBaseUrl;
|
||||
const baseUrl = userKey?.baseUrl || global?.systemEnv?.oneapiUrl || openaiBaseUrl;
|
||||
const apiKey = userKey?.key || global?.systemEnv?.chatApiKey || process.env.CHAT_API_KEY || '';
|
||||
|
||||
return {
|
||||
@@ -63,12 +62,23 @@ export const createChatCompletion = async <T extends CompletionsBodyType>({
|
||||
getEmptyResponseTip: () => string;
|
||||
}> => {
|
||||
try {
|
||||
const modelConstantsData = getLLMModel(body.model);
|
||||
|
||||
const formatTimeout = timeout ? timeout : body.stream ? 60000 : 600000;
|
||||
const ai = getAIApi({
|
||||
userKey,
|
||||
timeout: formatTimeout
|
||||
});
|
||||
const response = await ai.chat.completions.create(body, options);
|
||||
const response = await ai.chat.completions.create(body, {
|
||||
...options,
|
||||
...(modelConstantsData.requestUrl ? { path: modelConstantsData.requestUrl } : {}),
|
||||
headers: {
|
||||
...options?.headers,
|
||||
...(modelConstantsData.requestAuth
|
||||
? { Authorization: `Bearer ${modelConstantsData.requestAuth}` }
|
||||
: {})
|
||||
}
|
||||
});
|
||||
|
||||
const isStreamResponse =
|
||||
typeof response === 'object' &&
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"provider": "OpenAI",
|
||||
"model": "text-embedding-ada-002",
|
||||
"name": "text-embedding-ada-002",
|
||||
|
||||
"defaultToken": 512, // 默认分块 token
|
||||
"maxToken": 3000, // 最大分块 token
|
||||
"weight": 0, // 权重
|
||||
|
||||
"charsPointsPrice": 0 // 积分/1k token
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"provider": "OpenAI",
|
||||
"model": "gpt-4o-mini",
|
||||
"name": "GPT-4o-mini", // alias
|
||||
|
||||
"maxContext": 125000, // 最大上下文
|
||||
"maxResponse": 16000, // 最大回复
|
||||
"quoteMaxToken": 60000, // 最大引用
|
||||
"maxTemperature": 1.2, // 最大温度
|
||||
"presencePenaltyRange": [-2, 2], // 惩罚系数范围
|
||||
"frequencyPenaltyRange": [-2, 2], // 频率惩罚系数范围
|
||||
"responseFormatList": ["text", "json_object", "json_schema"], // 响应格式
|
||||
"showStopSign": true, // 是否显示停止符号
|
||||
|
||||
"vision": true, // 是否支持图片识别
|
||||
"toolChoice": true, // 是否支持工具调用
|
||||
"functionCall": false, // 是否支持函数调用(一般都可以 false 了,基本不用了)
|
||||
"defaultSystemChatPrompt": "", // 默认系统提示
|
||||
|
||||
"datasetProcess": true, // 用于知识库文本处理
|
||||
"usedInClassify": true, // 用于问题分类
|
||||
"customCQPrompt": "", // 自定义问题分类提示
|
||||
"usedInExtractFields": true, // 用于提取字段
|
||||
"customExtractPrompt": "", // 自定义提取提示
|
||||
"usedInToolCall": true, // 用于工具调用
|
||||
"usedInQueryExtension": true, // 用于问题优化
|
||||
|
||||
"defaultConfig": {}, // 额外的自定义 body
|
||||
"fieldMap": {}, // body 字段映射
|
||||
|
||||
"censor": false, // 是否开启敏感词过滤
|
||||
"charsPointsPrice": 0 // n 积分/1k token
|
||||
}
|
||||
4
packages/service/core/ai/config/provider/AliCloud.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"provider": "AliCloud",
|
||||
"list": []
|
||||
}
|
||||
17
packages/service/core/ai/config/provider/BAAI.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"provider": "BAAI",
|
||||
"list": [
|
||||
{
|
||||
"model": "bge-m3",
|
||||
"name": "bge-m3",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 8000,
|
||||
"type": "embedding"
|
||||
},
|
||||
{
|
||||
"model": "bge-reranker-v2-m3",
|
||||
"name": "bge-reranker-v2-m3",
|
||||
"type": "rerank"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
packages/service/core/ai/config/provider/Baichuan.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"provider": "Baichuan",
|
||||
"list": []
|
||||
}
|
||||
147
packages/service/core/ai/config/provider/ChatGLM.json
Normal file
@@ -0,0 +1,147 @@
|
||||
{
|
||||
"provider": "ChatGLM",
|
||||
"list": [
|
||||
{
|
||||
"model": "glm-4-air",
|
||||
"name": "glm-4-air",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": 0.99,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "glm-4-flash",
|
||||
"name": "glm-4-flash",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": 0.99,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "glm-4-long",
|
||||
"name": "glm-4-long",
|
||||
"maxContext": 1000000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 900000,
|
||||
"maxTemperature": 0.99,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "glm-4-plus",
|
||||
"name": "GLM-4-plus",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": 0.99,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "glm-4v-flash",
|
||||
"name": "glm-4v-flash",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 1000,
|
||||
"quoteMaxToken": 6000,
|
||||
"maxTemperature": 0.99,
|
||||
"vision": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "glm-4v-plus",
|
||||
"name": "GLM-4v-plus",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 1000,
|
||||
"quoteMaxToken": 6000,
|
||||
"maxTemperature": 0.99,
|
||||
"vision": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "embedding-3",
|
||||
"name": "embedding-3",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 8000,
|
||||
"defaultConfig": {
|
||||
"dimensions": 1024
|
||||
},
|
||||
"type": "embedding"
|
||||
}
|
||||
]
|
||||
}
|
||||
93
packages/service/core/ai/config/provider/Claude.json
Normal file
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"provider": "Claude",
|
||||
"list": [
|
||||
{
|
||||
"model": "claude-3-5-haiku-20241022",
|
||||
"name": "claude-3-5-haiku-20241022",
|
||||
"maxContext": 200000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 100000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"name": "Claude-3-5-sonnet-20240620",
|
||||
"maxContext": 200000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 100000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "claude-3-5-sonnet-20241022",
|
||||
"name": "Claude-3-5-sonnet-20241022",
|
||||
"maxContext": 200000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 100000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "claude-3-opus-20240229",
|
||||
"name": "claude-3-opus-20240229",
|
||||
"maxContext": 200000,
|
||||
"maxResponse": 4096,
|
||||
"quoteMaxToken": 100000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
}
|
||||
]
|
||||
}
|
||||
48
packages/service/core/ai/config/provider/DeepSeek.json
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"provider": "DeepSeek",
|
||||
"list": [
|
||||
{
|
||||
"model": "deepseek-chat",
|
||||
"name": "Deepseek-chat",
|
||||
"maxContext": 64000,
|
||||
"maxResponse": 4096,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1.5,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "deepseek-reasoner",
|
||||
"name": "Deepseek-reasoner",
|
||||
"maxContext": 64000,
|
||||
"maxResponse": 4096,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": null,
|
||||
"vision": false,
|
||||
"reasoning": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
}
|
||||
]
|
||||
}
|
||||
195
packages/service/core/ai/config/provider/Doubao.json
Normal file
@@ -0,0 +1,195 @@
|
||||
{
|
||||
"provider": "Doubao",
|
||||
"list": [
|
||||
{
|
||||
"model": "Doubao-lite-4k",
|
||||
"name": "Doubao-lite-4k",
|
||||
"maxContext": 4000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "Doubao-lite-32k",
|
||||
"name": "Doubao-lite-32k",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "Doubao-lite-128k",
|
||||
"name": "Doubao-lite-128k",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "Doubao-vision-lite-32k",
|
||||
"name": "Doubao-vision-lite-32k",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "Doubao-pro-4k",
|
||||
"name": "Doubao-pro-4k",
|
||||
"maxContext": 4000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "Doubao-pro-32k",
|
||||
"name": "Doubao-pro-32k",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "Doubao-pro-128k",
|
||||
"name": "Doubao-pro-128k",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "Doubao-vision-pro-32k",
|
||||
"name": "Doubao-vision-pro-32k",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "Doubao-embedding-large",
|
||||
"name": "Doubao-embedding-large",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 4096,
|
||||
"type": "embedding"
|
||||
},
|
||||
{
|
||||
"model": "Doubao-embedding",
|
||||
"name": "Doubao-embedding",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 4096,
|
||||
"type": "embedding"
|
||||
}
|
||||
]
|
||||
}
|
||||
107
packages/service/core/ai/config/provider/Ernie.json
Normal file
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"provider": "Ernie",
|
||||
"list": [
|
||||
{
|
||||
"model": "ERNIE-4.0-8K",
|
||||
"name": "ERNIE-4.0-8K",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 2048,
|
||||
"quoteMaxToken": 5000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "ERNIE-4.0-Turbo-8K",
|
||||
"name": "ERNIE-4.0-Turbo-8K",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 2048,
|
||||
"quoteMaxToken": 5000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "ERNIE-Lite-8K",
|
||||
"name": "ERNIE-lite-8k",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 2048,
|
||||
"quoteMaxToken": 6000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "ERNIE-Speed-128K",
|
||||
"name": "ERNIE-Speed-128K",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4096,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "Embedding-V1",
|
||||
"name": "Embedding-V1",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 1000,
|
||||
"type": "embedding"
|
||||
},
|
||||
{
|
||||
"model": "tao-8k",
|
||||
"name": "tao-8k",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 8000,
|
||||
"type": "embedding"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
packages/service/core/ai/config/provider/FishAudio.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"provider": "FishAudio",
|
||||
"list": []
|
||||
}
|
||||
144
packages/service/core/ai/config/provider/Gemini.json
Normal file
@@ -0,0 +1,144 @@
|
||||
{
|
||||
"provider": "Gemini",
|
||||
"list": [
|
||||
{
|
||||
"model": "gemini-1.5-flash",
|
||||
"name": "gemini-1.5-flash",
|
||||
"maxContext": 1000000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "gemini-1.5-pro",
|
||||
"name": "gemini-1.5-pro",
|
||||
"maxContext": 2000000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "gemini-2.0-flash-exp",
|
||||
"name": "gemini-2.0-flash-exp",
|
||||
"maxContext": 1000000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "gemini-2.0-flash-thinking-exp-1219",
|
||||
"name": "gemini-2.0-flash-thinking-exp-1219",
|
||||
"maxContext": 1000000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "gemini-2.0-flash-thinking-exp-01-21",
|
||||
"name": "gemini-2.0-flash-thinking-exp-01-21",
|
||||
"maxContext": 1000000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "gemini-exp-1206",
|
||||
"name": "gemini-exp-1206",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "text-embedding-004",
|
||||
"name": "text-embedding-004",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 2000,
|
||||
"type": "embedding"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
packages/service/core/ai/config/provider/Grok.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"provider": "Grok",
|
||||
"list": []
|
||||
}
|
||||
47
packages/service/core/ai/config/provider/Groq.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"provider": "Groq",
|
||||
"list": [
|
||||
{
|
||||
"model": "llama-3.1-8b-instant",
|
||||
"name": "Groq-llama-3.1-8b-instant",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "llama-3.3-70b-versatile",
|
||||
"name": "Groq-llama-3.3-70b-versatile",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"type": "llm"
|
||||
}
|
||||
]
|
||||
}
|
||||
166
packages/service/core/ai/config/provider/Hunyuan.json
Normal file
@@ -0,0 +1,166 @@
|
||||
{
|
||||
"provider": "Hunyuan",
|
||||
"list": [
|
||||
{
|
||||
"model": "hunyuan-large",
|
||||
"name": "hunyuan-large",
|
||||
"maxContext": 28000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 20000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "hunyuan-lite",
|
||||
"name": "hunyuan-lite",
|
||||
"maxContext": 250000,
|
||||
"maxResponse": 6000,
|
||||
"quoteMaxToken": 100000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "hunyuan-pro",
|
||||
"name": "hunyuan-pro",
|
||||
"maxContext": 28000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 28000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "hunyuan-standard",
|
||||
"name": "hunyuan-standard",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 2000,
|
||||
"quoteMaxToken": 20000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "hunyuan-turbo-vision",
|
||||
"name": "hunyuan-turbo-vision",
|
||||
"maxContext": 6000,
|
||||
"maxResponse": 2000,
|
||||
"quoteMaxToken": 6000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "hunyuan-turbo",
|
||||
"name": "hunyuan-turbo",
|
||||
"maxContext": 28000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 20000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "hunyuan-vision",
|
||||
"name": "hunyuan-vision",
|
||||
"maxContext": 6000,
|
||||
"maxResponse": 2000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "hunyuan-embedding",
|
||||
"name": "hunyuan-embedding",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 1024,
|
||||
"type": "embedding"
|
||||
}
|
||||
]
|
||||
}
|
||||
49
packages/service/core/ai/config/provider/Intern.json
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"provider": "Intern",
|
||||
"list": [
|
||||
{
|
||||
"model": "internlm2-pro-chat",
|
||||
"name": "internlm2-pro-chat",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "internlm3-8b-instruct",
|
||||
"name": "internlm3-8b-instruct",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
packages/service/core/ai/config/provider/Meta.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"provider": "Meta",
|
||||
"list": []
|
||||
}
|
||||
240
packages/service/core/ai/config/provider/MiniMax.json
Normal file
@@ -0,0 +1,240 @@
|
||||
{
|
||||
"provider": "MiniMax",
|
||||
"list": [
|
||||
{
|
||||
"model": "MiniMax-Text-01",
|
||||
"name": "MiniMax-Text-01",
|
||||
"maxContext": 1000000,
|
||||
"maxResponse": 1000000,
|
||||
"quoteMaxToken": 100000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "abab6.5s-chat",
|
||||
"name": "MiniMax-abab6.5s",
|
||||
"maxContext": 245000,
|
||||
"maxResponse": 10000,
|
||||
"quoteMaxToken": 240000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "speech-01-turbo",
|
||||
"name": "speech-01-turbo",
|
||||
"voices": [
|
||||
{
|
||||
"label": "male-qn-qingse",
|
||||
"value": "male-qn-qingse"
|
||||
},
|
||||
{
|
||||
"label": "male-qn-jingying",
|
||||
"value": "male-qn-jingying"
|
||||
},
|
||||
{
|
||||
"label": "male-qn-badao",
|
||||
"value": "male-qn-badao"
|
||||
},
|
||||
{
|
||||
"label": "male-qn-daxuesheng",
|
||||
"value": "male-qn-daxuesheng"
|
||||
},
|
||||
{
|
||||
"label": "female-shaonv",
|
||||
"value": "female-shaonv"
|
||||
},
|
||||
{
|
||||
"label": "female-yujie",
|
||||
"value": "female-yujie"
|
||||
},
|
||||
{
|
||||
"label": "female-chengshu",
|
||||
"value": "female-chengshu"
|
||||
},
|
||||
{
|
||||
"label": "female-tianmei",
|
||||
"value": "female-tianmei"
|
||||
},
|
||||
{
|
||||
"label": "presenter_male",
|
||||
"value": "presenter_male"
|
||||
},
|
||||
{
|
||||
"label": "presenter_female",
|
||||
"value": "presenter_female"
|
||||
},
|
||||
{
|
||||
"label": "audiobook_male_1",
|
||||
"value": "audiobook_male_1"
|
||||
},
|
||||
{
|
||||
"label": "audiobook_male_2",
|
||||
"value": "audiobook_male_2"
|
||||
},
|
||||
{
|
||||
"label": "audiobook_female_1",
|
||||
"value": "audiobook_female_1"
|
||||
},
|
||||
{
|
||||
"label": "audiobook_female_2",
|
||||
"value": "audiobook_female_2"
|
||||
},
|
||||
{
|
||||
"label": "male-qn-qingse-jingpin",
|
||||
"value": "male-qn-qingse-jingpin"
|
||||
},
|
||||
{
|
||||
"label": "male-qn-jingying-jingpin",
|
||||
"value": "male-qn-jingying-jingpin"
|
||||
},
|
||||
{
|
||||
"label": "male-qn-badao-jingpin",
|
||||
"value": "male-qn-badao-jingpin"
|
||||
},
|
||||
{
|
||||
"label": "male-qn-daxuesheng-jingpin",
|
||||
"value": "male-qn-daxuesheng-jingpin"
|
||||
},
|
||||
{
|
||||
"label": "female-shaonv-jingpin",
|
||||
"value": "female-shaonv-jingpin"
|
||||
},
|
||||
{
|
||||
"label": "female-yujie-jingpin",
|
||||
"value": "female-yujie-jingpin"
|
||||
},
|
||||
{
|
||||
"label": "female-chengshu-jingpin",
|
||||
"value": "female-chengshu-jingpin"
|
||||
},
|
||||
{
|
||||
"label": "female-tianmei-jingpin",
|
||||
"value": "female-tianmei-jingpin"
|
||||
},
|
||||
{
|
||||
"label": "clever_boy",
|
||||
"value": "clever_boy"
|
||||
},
|
||||
{
|
||||
"label": "cute_boy",
|
||||
"value": "cute_boy"
|
||||
},
|
||||
{
|
||||
"label": "lovely_girl",
|
||||
"value": "lovely_girl"
|
||||
},
|
||||
{
|
||||
"label": "cartoon_pig",
|
||||
"value": "cartoon_pig"
|
||||
},
|
||||
{
|
||||
"label": "bingjiao_didi",
|
||||
"value": "bingjiao_didi"
|
||||
},
|
||||
{
|
||||
"label": "junlang_nanyou",
|
||||
"value": "junlang_nanyou"
|
||||
},
|
||||
{
|
||||
"label": "chunzhen_xuedi",
|
||||
"value": "chunzhen_xuedi"
|
||||
},
|
||||
{
|
||||
"label": "lengdan_xiongzhang",
|
||||
"value": "lengdan_xiongzhang"
|
||||
},
|
||||
{
|
||||
"label": "badao_shaoye",
|
||||
"value": "badao_shaoye"
|
||||
},
|
||||
{
|
||||
"label": "tianxin_xiaoling",
|
||||
"value": "tianxin_xiaoling"
|
||||
},
|
||||
{
|
||||
"label": "qiaopi_mengmei",
|
||||
"value": "qiaopi_mengmei"
|
||||
},
|
||||
{
|
||||
"label": "wumei_yujie",
|
||||
"value": "wumei_yujie"
|
||||
},
|
||||
{
|
||||
"label": "diadia_xuemei",
|
||||
"value": "diadia_xuemei"
|
||||
},
|
||||
{
|
||||
"label": "danya_xuejie",
|
||||
"value": "danya_xuejie"
|
||||
},
|
||||
{
|
||||
"label": "Santa_Claus",
|
||||
"value": "Santa_Claus"
|
||||
},
|
||||
{
|
||||
"label": "Grinch",
|
||||
"value": "Grinch"
|
||||
},
|
||||
{
|
||||
"label": "Rudolph",
|
||||
"value": "Rudolph"
|
||||
},
|
||||
{
|
||||
"label": "Arnold",
|
||||
"value": "Arnold"
|
||||
},
|
||||
{
|
||||
"label": "Charming_Santa",
|
||||
"value": "Charming_Santa"
|
||||
},
|
||||
{
|
||||
"label": "Charming_Lady",
|
||||
"value": "Charming_Lady"
|
||||
},
|
||||
{
|
||||
"label": "Sweet_Girl",
|
||||
"value": "Sweet_Girl"
|
||||
},
|
||||
{
|
||||
"label": "Cute_Elf",
|
||||
"value": "Cute_Elf"
|
||||
},
|
||||
{
|
||||
"label": "Attractive_Girl",
|
||||
"value": "Attractive_Girl"
|
||||
},
|
||||
{
|
||||
"label": "Serene_Woman",
|
||||
"value": "Serene_Woman"
|
||||
}
|
||||
],
|
||||
"type": "tts"
|
||||
}
|
||||
]
|
||||
}
|
||||
93
packages/service/core/ai/config/provider/MistralAI.json
Normal file
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"provider": "MistralAI",
|
||||
"list": [
|
||||
{
|
||||
"model": "ministral-3b-latest",
|
||||
"name": "Ministral-3b-latest",
|
||||
"maxContext": 130000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "ministral-8b-latest",
|
||||
"name": "Ministral-8b-latest",
|
||||
"maxContext": 130000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "mistral-large-latest",
|
||||
"name": "Mistral-large-latest",
|
||||
"maxContext": 130000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "mistral-small-latest",
|
||||
"name": "Mistral-small-latest",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
packages/service/core/ai/config/provider/Moka.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"provider": "Moka",
|
||||
"list": []
|
||||
}
|
||||
71
packages/service/core/ai/config/provider/Moonshot.json
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"provider": "Moonshot",
|
||||
"list": [
|
||||
{
|
||||
"model": "moonshot-v1-8k",
|
||||
"name": "moonshot-v1-8k",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 6000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "moonshot-v1-32k",
|
||||
"name": "moonshot-v1-32k",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "moonshot-v1-128k",
|
||||
"name": "moonshot-v1-128k",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
packages/service/core/ai/config/provider/Ollama.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"provider": "Ollama",
|
||||
"list": []
|
||||
}
|
||||
252
packages/service/core/ai/config/provider/OpenAI.json
Normal file
@@ -0,0 +1,252 @@
|
||||
{
|
||||
"provider": "OpenAI",
|
||||
"list": [
|
||||
{
|
||||
"model": "gpt-4o-mini",
|
||||
"name": "GPT-4o-mini",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 16000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": true,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "gpt-4o",
|
||||
"name": "GPT-4o",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": true,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "o3-mini",
|
||||
"name": "o3-mini",
|
||||
"maxContext": 200000,
|
||||
"maxResponse": 100000,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": null,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {
|
||||
"stream": false
|
||||
},
|
||||
"fieldMap": {
|
||||
"max_tokens": "max_completion_tokens"
|
||||
},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "o1-mini",
|
||||
"name": "o1-mini",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": null,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {
|
||||
"stream": false
|
||||
},
|
||||
"fieldMap": {
|
||||
"max_tokens": "max_completion_tokens"
|
||||
},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "o1",
|
||||
"name": "o1",
|
||||
"maxContext": 195000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": null,
|
||||
"vision": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {
|
||||
"stream": false
|
||||
},
|
||||
"fieldMap": {
|
||||
"max_tokens": "max_completion_tokens"
|
||||
},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "o1-preview",
|
||||
"name": "o1-preview",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 120000,
|
||||
"maxTemperature": null,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {
|
||||
"stream": false
|
||||
},
|
||||
"fieldMap": {
|
||||
"max_tokens": "max_completion_tokens"
|
||||
},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "gpt-3.5-turbo",
|
||||
"name": "gpt-3.5-turbo",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 13000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": true,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "gpt-4-turbo",
|
||||
"name": "gpt-4-turbo",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": true,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "text-embedding-3-large",
|
||||
"name": "text-embedding-3-large",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 8000,
|
||||
"defaultConfig": {
|
||||
"dimensions": 1024
|
||||
},
|
||||
"type": "embedding"
|
||||
},
|
||||
{
|
||||
"model": "text-embedding-3-small",
|
||||
"name": "text-embedding-3-small",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 8000,
|
||||
"type": "embedding"
|
||||
},
|
||||
{
|
||||
"model": "text-embedding-ada-002",
|
||||
"name": "text-embedding-ada-002",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 8000,
|
||||
"type": "embedding"
|
||||
},
|
||||
{
|
||||
"model": "tts-1",
|
||||
"name": "TTS1",
|
||||
"voices": [
|
||||
{
|
||||
"label": "Alloy",
|
||||
"value": "alloy"
|
||||
},
|
||||
{
|
||||
"label": "Echo",
|
||||
"value": "echo"
|
||||
},
|
||||
{
|
||||
"label": "Fable",
|
||||
"value": "fable"
|
||||
},
|
||||
{
|
||||
"label": "Onyx",
|
||||
"value": "onyx"
|
||||
},
|
||||
{
|
||||
"label": "Nova",
|
||||
"value": "nova"
|
||||
},
|
||||
{
|
||||
"label": "Shimmer",
|
||||
"value": "shimmer"
|
||||
}
|
||||
],
|
||||
"type": "tts"
|
||||
},
|
||||
{
|
||||
"model": "whisper-1",
|
||||
"name": "whisper-1",
|
||||
"type": "stt"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
packages/service/core/ai/config/provider/Other.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"provider": "Other",
|
||||
"list": []
|
||||
}
|
||||
223
packages/service/core/ai/config/provider/Qwen.json
Normal file
@@ -0,0 +1,223 @@
|
||||
{
|
||||
"provider": "Qwen",
|
||||
"list": [
|
||||
{
|
||||
"model": "qwen-turbo",
|
||||
"name": "Qwen-turbo",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 100000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "qwen-plus",
|
||||
"name": "Qwen-plus",
|
||||
"maxContext": 64000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 60000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "qwen-vl-plus",
|
||||
"name": "qwen-vl-plus",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 2000,
|
||||
"quoteMaxToken": 20000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "qwen-max",
|
||||
"name": "Qwen-max",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 6000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "qwen-vl-max",
|
||||
"name": "qwen-vl-max",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 2000,
|
||||
"quoteMaxToken": 20000,
|
||||
"maxTemperature": 1.2,
|
||||
"vision": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "qwen-coder-turbo",
|
||||
"name": "qwen-coder-turbo",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 50000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "qwen2.5-7b-instruct",
|
||||
"name": "qwen2.5-7b-instruct",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 50000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "qwen2.5-14b-instruct",
|
||||
"name": "qwen2.5-14b-instruct",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 50000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "qwen2.5-32b-instruct",
|
||||
"name": "qwen2.5-32b-instruct",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 50000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "qwen2.5-72b-instruct",
|
||||
"name": "Qwen2.5-72B-instruct",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 50000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
}
|
||||
]
|
||||
}
|
||||
204
packages/service/core/ai/config/provider/Siliconflow.json
Normal file
@@ -0,0 +1,204 @@
|
||||
{
|
||||
"provider": "Siliconflow",
|
||||
"list": [
|
||||
{
|
||||
"model": "Qwen/Qwen2.5-72B-Instruct",
|
||||
"name": "Qwen/Qwen2.5-72B-Instruct",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 50000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "Qwen/Qwen2-VL-72B-Instruct",
|
||||
"name": "Qwen/Qwen2-VL-72B-Instruct",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"censor": false,
|
||||
"vision": true,
|
||||
"datasetProcess": false,
|
||||
"usedInClassify": false,
|
||||
"usedInExtractFields": false,
|
||||
"usedInToolCall": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"defaultConfig": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "deepseek-ai/DeepSeek-V2.5",
|
||||
"name": "deepseek-ai/DeepSeek-V2.5",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "BAAI/bge-m3",
|
||||
"name": "BAAI/bge-m3",
|
||||
"defaultToken": 512,
|
||||
"maxToken": 8000,
|
||||
"type": "embedding"
|
||||
},
|
||||
{
|
||||
"model": "FunAudioLLM/CosyVoice2-0.5B",
|
||||
"name": "FunAudioLLM/CosyVoice2-0.5B",
|
||||
"voices": [
|
||||
{
|
||||
"label": "alex",
|
||||
"value": "FunAudioLLM/CosyVoice2-0.5B:alex"
|
||||
},
|
||||
{
|
||||
"label": "anna",
|
||||
"value": "FunAudioLLM/CosyVoice2-0.5B:anna"
|
||||
},
|
||||
{
|
||||
"label": "bella",
|
||||
"value": "FunAudioLLM/CosyVoice2-0.5B:bella"
|
||||
},
|
||||
{
|
||||
"label": "benjamin",
|
||||
"value": "FunAudioLLM/CosyVoice2-0.5B:benjamin"
|
||||
},
|
||||
{
|
||||
"label": "charles",
|
||||
"value": "FunAudioLLM/CosyVoice2-0.5B:charles"
|
||||
},
|
||||
{
|
||||
"label": "claire",
|
||||
"value": "FunAudioLLM/CosyVoice2-0.5B:claire"
|
||||
},
|
||||
{
|
||||
"label": "david",
|
||||
"value": "FunAudioLLM/CosyVoice2-0.5B:david"
|
||||
},
|
||||
{
|
||||
"label": "diana",
|
||||
"value": "FunAudioLLM/CosyVoice2-0.5B:diana"
|
||||
}
|
||||
],
|
||||
"type": "tts"
|
||||
},
|
||||
{
|
||||
"model": "RVC-Boss/GPT-SoVITS",
|
||||
"name": "RVC-Boss/GPT-SoVITS",
|
||||
"voices": [
|
||||
{
|
||||
"label": "alex",
|
||||
"value": "RVC-Boss/GPT-SoVITS:alex"
|
||||
},
|
||||
{
|
||||
"label": "anna",
|
||||
"value": "RVC-Boss/GPT-SoVITS:anna"
|
||||
},
|
||||
{
|
||||
"label": "bella",
|
||||
"value": "RVC-Boss/GPT-SoVITS:bella"
|
||||
},
|
||||
{
|
||||
"label": "benjamin",
|
||||
"value": "RVC-Boss/GPT-SoVITS:benjamin"
|
||||
},
|
||||
{
|
||||
"label": "charles",
|
||||
"value": "RVC-Boss/GPT-SoVITS:charles"
|
||||
},
|
||||
{
|
||||
"label": "claire",
|
||||
"value": "RVC-Boss/GPT-SoVITS:claire"
|
||||
},
|
||||
{
|
||||
"label": "david",
|
||||
"value": "RVC-Boss/GPT-SoVITS:david"
|
||||
},
|
||||
{
|
||||
"label": "diana",
|
||||
"value": "RVC-Boss/GPT-SoVITS:diana"
|
||||
}
|
||||
],
|
||||
"type": "tts"
|
||||
},
|
||||
{
|
||||
"model": "fishaudio/fish-speech-1.5",
|
||||
"name": "fish-speech-1.5",
|
||||
"voices": [
|
||||
{
|
||||
"label": "alex",
|
||||
"value": "fishaudio/fish-speech-1.5:alex"
|
||||
},
|
||||
{
|
||||
"label": "anna",
|
||||
"value": "fishaudio/fish-speech-1.5:anna"
|
||||
},
|
||||
{
|
||||
"label": "bella",
|
||||
"value": "fishaudio/fish-speech-1.5:bella"
|
||||
},
|
||||
{
|
||||
"label": "benjamin",
|
||||
"value": "fishaudio/fish-speech-1.5:benjamin"
|
||||
},
|
||||
{
|
||||
"label": "charles",
|
||||
"value": "fishaudio/fish-speech-1.5:charles"
|
||||
},
|
||||
{
|
||||
"label": "claire",
|
||||
"value": "fishaudio/fish-speech-1.5:claire"
|
||||
},
|
||||
{
|
||||
"label": "david",
|
||||
"value": "fishaudio/fish-speech-1.5:david"
|
||||
},
|
||||
{
|
||||
"label": "diana",
|
||||
"value": "fishaudio/fish-speech-1.5:diana"
|
||||
}
|
||||
],
|
||||
"type": "tts"
|
||||
},
|
||||
{
|
||||
"model": "FunAudioLLM/SenseVoiceSmall",
|
||||
"name": "FunAudioLLM/SenseVoiceSmall",
|
||||
"type": "stt"
|
||||
},
|
||||
{
|
||||
"model": "BAAI/bge-reranker-v2-m3",
|
||||
"name": "BAAI/bge-reranker-v2-m3",
|
||||
"type": "rerank"
|
||||
}
|
||||
]
|
||||
}
|
||||
129
packages/service/core/ai/config/provider/SparkDesk.json
Normal file
@@ -0,0 +1,129 @@
|
||||
{
|
||||
"provider": "SparkDesk",
|
||||
"list": [
|
||||
{
|
||||
"model": "lite",
|
||||
"name": "SparkDesk-lite",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "generalv3",
|
||||
"name": "SparkDesk-Pro",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "pro-128k",
|
||||
"name": "SparkDesk-Pro-128k",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 128000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "generalv3.5",
|
||||
"name": "SparkDesk-max",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "max-32k",
|
||||
"name": "SparkDesk-max-32k",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "4.0Ultra",
|
||||
"name": "SparkDesk-v4.0 Ultra",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
}
|
||||
]
|
||||
}
|
||||
308
packages/service/core/ai/config/provider/StepFun.json
Normal file
@@ -0,0 +1,308 @@
|
||||
{
|
||||
"provider": "StepFun",
|
||||
"list": [
|
||||
{
|
||||
"model": "step-1-flash",
|
||||
"name": "step-1-flash",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 6000,
|
||||
"maxTemperature": 2,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-1-8k",
|
||||
"name": "step-1-8k",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 2,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-1-32k",
|
||||
"name": "step-1-32k",
|
||||
"maxContext": 32000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxTemperature": 2,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-1-128k",
|
||||
"name": "step-1-128k",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 128000,
|
||||
"maxTemperature": 2,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-1-256k",
|
||||
"name": "step-1-256k",
|
||||
"maxContext": 256000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 256000,
|
||||
"maxTemperature": 2,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-1o-vision-32k",
|
||||
"name": "step-1o-vision-32k",
|
||||
"maxContext": 32000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxResponse": 8000,
|
||||
"maxTemperature": 2,
|
||||
"vision": true,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-1v-8k",
|
||||
"name": "step-1v-8k",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 8000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 2,
|
||||
"vision": true,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-1v-32k",
|
||||
"name": "step-1v-32k",
|
||||
"maxContext": 32000,
|
||||
"quoteMaxToken": 32000,
|
||||
"maxResponse": 8000,
|
||||
"maxTemperature": 2,
|
||||
"vision": true,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-2-mini",
|
||||
"name": "step-2-mini",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 6000,
|
||||
"maxTemperature": 2,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-2-16k",
|
||||
"name": "step-2-16k",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 2,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-2-16k-exp",
|
||||
"name": "step-2-16k-exp",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 2,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"usedInExtractFields": true,
|
||||
"usedInToolCall": true,
|
||||
"usedInQueryExtension": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "step-tts-mini",
|
||||
"name": "step-tts-mini",
|
||||
"voices": [
|
||||
{
|
||||
"label": "cixingnansheng",
|
||||
"value": "cixingnansheng"
|
||||
},
|
||||
{
|
||||
"label": "zhengpaiqingnian",
|
||||
"value": "zhengpaiqingnian"
|
||||
},
|
||||
{
|
||||
"label": "yuanqinansheng",
|
||||
"value": "yuanqinansheng"
|
||||
},
|
||||
{
|
||||
"label": "qingniandaxuesheng",
|
||||
"value": "qingniandaxuesheng"
|
||||
},
|
||||
{
|
||||
"label": "boyinnansheng",
|
||||
"value": "boyinnansheng"
|
||||
},
|
||||
{
|
||||
"label": "ruyananshi",
|
||||
"value": "ruyananshi"
|
||||
},
|
||||
{
|
||||
"label": "shenchennanyin",
|
||||
"value": "shenchennanyin"
|
||||
},
|
||||
{
|
||||
"label": "qinqienvsheng",
|
||||
"value": "qinqienvsheng"
|
||||
},
|
||||
{
|
||||
"label": "wenrounvsheng",
|
||||
"value": "wenrounvsheng"
|
||||
},
|
||||
{
|
||||
"label": "jilingshaonv",
|
||||
"value": "jilingshaonv"
|
||||
},
|
||||
{
|
||||
"label": "yuanqishaonv",
|
||||
"value": "yuanqishaonv"
|
||||
},
|
||||
{
|
||||
"label": "ruanmengnvsheng",
|
||||
"value": "ruanmengnvsheng"
|
||||
},
|
||||
{
|
||||
"label": "youyanvsheng",
|
||||
"value": "youyanvsheng"
|
||||
},
|
||||
{
|
||||
"label": "lengyanyujie",
|
||||
"value": "lengyanyujie"
|
||||
},
|
||||
{
|
||||
"label": "shuangkuaijiejie",
|
||||
"value": "shuangkuaijiejie"
|
||||
},
|
||||
{
|
||||
"label": "wenjingxuejie",
|
||||
"value": "wenjingxuejie"
|
||||
},
|
||||
{
|
||||
"label": "linjiajiejie",
|
||||
"value": "linjiajiejie"
|
||||
},
|
||||
{
|
||||
"label": "linjiameimei",
|
||||
"value": "linjiameimei"
|
||||
},
|
||||
{
|
||||
"label": "zhixingjiejie",
|
||||
"value": "zhixingjiejie"
|
||||
}
|
||||
],
|
||||
"type": "tts"
|
||||
}
|
||||
]
|
||||
}
|
||||
49
packages/service/core/ai/config/provider/Yi.json
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"provider": "Yi",
|
||||
"list": [
|
||||
{
|
||||
"model": "yi-lightning",
|
||||
"name": "yi-lightning",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 12000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
},
|
||||
{
|
||||
"model": "yi-vision-v2",
|
||||
"name": "yi-vision-v2",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 12000,
|
||||
"maxTemperature": 1,
|
||||
"vision": true,
|
||||
"toolChoice": false,
|
||||
"functionCall": false,
|
||||
"defaultSystemChatPrompt": "",
|
||||
"datasetProcess": true,
|
||||
"usedInClassify": true,
|
||||
"customCQPrompt": "",
|
||||
"usedInExtractFields": true,
|
||||
"usedInQueryExtension": true,
|
||||
"customExtractPrompt": "",
|
||||
"usedInToolCall": true,
|
||||
"defaultConfig": {},
|
||||
"fieldMap": {},
|
||||
"type": "llm"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"provider": "BAAI",
|
||||
"model": "bge-reranker-v2-m3",
|
||||
"name": "bge-reranker-v2-m3",
|
||||
"charsPointsPrice": 0
|
||||
}
|
||||
21
packages/service/core/ai/config/schema.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { connectionMongo, getMongoModel } from '../../../common/mongo';
|
||||
const { Schema } = connectionMongo;
|
||||
import type { SystemModelSchemaType } from '../type';
|
||||
|
||||
const SystemModelSchema = new Schema({
|
||||
model: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true
|
||||
},
|
||||
metadata: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: {}
|
||||
}
|
||||
});
|
||||
|
||||
export const MongoSystemModel = getMongoModel<SystemModelSchemaType>(
|
||||
'system_models',
|
||||
SystemModelSchema
|
||||
);
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"provider": "OpenAI",
|
||||
"model": "whisper-1",
|
||||
"name": "whisper-1",
|
||||
"charsPointsPrice": 0
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"provider": "OpenAI",
|
||||
"model": "tts-1",
|
||||
"name": "TTS1",
|
||||
"charsPointsPrice": 0,
|
||||
"voices": [
|
||||
{
|
||||
"label": "Alloy",
|
||||
"value": "alloy"
|
||||
},
|
||||
{
|
||||
"label": "Echo",
|
||||
"value": "echo"
|
||||
},
|
||||
{
|
||||
"label": "Fable",
|
||||
"value": "fable"
|
||||
},
|
||||
{
|
||||
"label": "Onyx",
|
||||
"value": "onyx"
|
||||
},
|
||||
{
|
||||
"label": "Nova",
|
||||
"value": "nova"
|
||||
},
|
||||
{
|
||||
"label": "Shimmer",
|
||||
"value": "shimmer"
|
||||
}
|
||||
]
|
||||
}
|
||||
195
packages/service/core/ai/config/utils.ts
Normal file
@@ -0,0 +1,195 @@
|
||||
import path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { SystemModelItemType } from '../type';
|
||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||
import { MongoSystemModel } from './schema';
|
||||
import {
|
||||
LLMModelItemType,
|
||||
EmbeddingModelItemType,
|
||||
TTSModelType,
|
||||
STTModelType,
|
||||
ReRankModelItemType
|
||||
} from '@fastgpt/global/core/ai/model.d';
|
||||
import { debounce } from 'lodash';
|
||||
import { ModelProviderType } from '@fastgpt/global/core/ai/provider';
|
||||
import { findModelFromAlldata } from '../model';
|
||||
import {
|
||||
reloadFastGPTConfigBuffer,
|
||||
updateFastGPTConfigBuffer
|
||||
} from '../../../common/system/config/controller';
|
||||
import { delay } from '@fastgpt/global/common/system/utils';
|
||||
|
||||
/*
|
||||
TODO: 分优先级读取:
|
||||
1. 有外部挂载目录,则读取外部的
|
||||
2. 没有外部挂载目录,则读取本地的。然后试图拉取云端的进行覆盖。
|
||||
*/
|
||||
export const loadSystemModels = async (init = false) => {
|
||||
const getProviderList = () => {
|
||||
const currentFileUrl = new URL(import.meta.url);
|
||||
const modelsPath = path.join(path.dirname(currentFileUrl.pathname), 'provider');
|
||||
|
||||
return fs.readdirSync(modelsPath) as string[];
|
||||
};
|
||||
const pushModel = (model: SystemModelItemType) => {
|
||||
global.systemModelList.push(model);
|
||||
|
||||
if (model.isActive) {
|
||||
global.systemActiveModelList.push(model);
|
||||
|
||||
if (model.type === ModelTypeEnum.llm) {
|
||||
global.llmModelMap.set(model.model, model);
|
||||
global.llmModelMap.set(model.name, model);
|
||||
if (model.isDefault) {
|
||||
global.systemDefaultModel.llm = model;
|
||||
}
|
||||
} else if (model.type === ModelTypeEnum.embedding) {
|
||||
global.embeddingModelMap.set(model.model, model);
|
||||
global.embeddingModelMap.set(model.name, model);
|
||||
if (model.isDefault) {
|
||||
global.systemDefaultModel.embedding = model;
|
||||
}
|
||||
} else if (model.type === ModelTypeEnum.tts) {
|
||||
global.ttsModelMap.set(model.model, model);
|
||||
global.ttsModelMap.set(model.name, model);
|
||||
if (model.isDefault) {
|
||||
global.systemDefaultModel.tts = model;
|
||||
}
|
||||
} else if (model.type === ModelTypeEnum.stt) {
|
||||
global.sttModelMap.set(model.model, model);
|
||||
global.sttModelMap.set(model.name, model);
|
||||
if (model.isDefault) {
|
||||
global.systemDefaultModel.stt = model;
|
||||
}
|
||||
} else if (model.type === ModelTypeEnum.rerank) {
|
||||
global.reRankModelMap.set(model.model, model);
|
||||
global.reRankModelMap.set(model.name, model);
|
||||
if (model.isDefault) {
|
||||
global.systemDefaultModel.rerank = model;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (!init && global.systemModelList) return;
|
||||
|
||||
global.systemModelList = [];
|
||||
global.systemActiveModelList = [];
|
||||
global.llmModelMap = new Map<string, LLMModelItemType>();
|
||||
global.embeddingModelMap = new Map<string, EmbeddingModelItemType>();
|
||||
global.ttsModelMap = new Map<string, TTSModelType>();
|
||||
global.sttModelMap = new Map<string, STTModelType>();
|
||||
global.reRankModelMap = new Map<string, ReRankModelItemType>();
|
||||
// @ts-ignore
|
||||
global.systemDefaultModel = {};
|
||||
|
||||
try {
|
||||
const dbModels = await MongoSystemModel.find({}).lean();
|
||||
const providerList = getProviderList();
|
||||
|
||||
// System model
|
||||
await Promise.all(
|
||||
providerList.map(async (name) => {
|
||||
const fileContent = (await import(`./provider/${name}`))?.default as {
|
||||
provider: ModelProviderType;
|
||||
list: SystemModelItemType[];
|
||||
};
|
||||
|
||||
fileContent.list.forEach((fileModel) => {
|
||||
const dbModel = dbModels.find((item) => item.model === fileModel.model);
|
||||
|
||||
const modelData: any = {
|
||||
...fileModel,
|
||||
...dbModel?.metadata,
|
||||
provider: dbModel?.metadata?.provider || fileContent.provider,
|
||||
type: dbModel?.metadata?.type || fileModel.type,
|
||||
isCustom: false
|
||||
};
|
||||
|
||||
pushModel(modelData);
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
// Custom model
|
||||
dbModels.forEach((dbModel) => {
|
||||
if (global.systemModelList.find((item) => item.model === dbModel.model)) return;
|
||||
|
||||
pushModel({
|
||||
...dbModel.metadata,
|
||||
isCustom: true
|
||||
});
|
||||
});
|
||||
|
||||
// Default model check
|
||||
if (!global.systemDefaultModel.llm) {
|
||||
global.systemDefaultModel.llm = Array.from(global.llmModelMap.values())[0];
|
||||
}
|
||||
if (!global.systemDefaultModel.embedding) {
|
||||
global.systemDefaultModel.embedding = Array.from(global.embeddingModelMap.values())[0];
|
||||
}
|
||||
if (!global.systemDefaultModel.tts) {
|
||||
global.systemDefaultModel.tts = Array.from(global.ttsModelMap.values())[0];
|
||||
}
|
||||
if (!global.systemDefaultModel.stt) {
|
||||
global.systemDefaultModel.stt = Array.from(global.sttModelMap.values())[0];
|
||||
}
|
||||
if (!global.systemDefaultModel.rerank) {
|
||||
global.systemDefaultModel.rerank = Array.from(global.reRankModelMap.values())[0];
|
||||
}
|
||||
|
||||
console.log('Load models success', JSON.stringify(global.systemActiveModelList, null, 2));
|
||||
} catch (error) {
|
||||
console.error('Load models error', error);
|
||||
// @ts-ignore
|
||||
global.systemModelList = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
export const getSystemModelConfig = async (model: string): Promise<SystemModelItemType> => {
|
||||
const modelData = findModelFromAlldata(model);
|
||||
if (!modelData) return Promise.reject('Model is not found');
|
||||
if (modelData.isCustom) return Promise.reject('Custom model not data');
|
||||
|
||||
// Read file
|
||||
const fileContent = (await import(`./provider/${modelData.provider}`))?.default as {
|
||||
provider: ModelProviderType;
|
||||
list: SystemModelItemType[];
|
||||
};
|
||||
|
||||
const config = fileContent.list.find((item) => item.model === model);
|
||||
|
||||
if (!config) return Promise.reject('Model config is not found');
|
||||
|
||||
return {
|
||||
...config,
|
||||
provider: modelData.provider,
|
||||
isCustom: false
|
||||
};
|
||||
};
|
||||
|
||||
export const watchSystemModelUpdate = () => {
|
||||
const changeStream = MongoSystemModel.watch();
|
||||
|
||||
changeStream.on(
|
||||
'change',
|
||||
debounce(async () => {
|
||||
try {
|
||||
// Main node will reload twice
|
||||
await loadSystemModels(true);
|
||||
// All node reaload buffer
|
||||
await reloadFastGPTConfigBuffer();
|
||||
} catch (error) {}
|
||||
}, 500)
|
||||
);
|
||||
};
|
||||
|
||||
// 更新完模型后,需要重载缓存
|
||||
export const updatedReloadSystemModel = async () => {
|
||||
// 1. 更新模型(所有节点都会触发)
|
||||
await loadSystemModels(true);
|
||||
// 2. 更新缓存(仅主节点触发)
|
||||
await updateFastGPTConfigBuffer();
|
||||
// 3. 延迟1秒,等待其他节点刷新
|
||||
await delay(1000);
|
||||
};
|
||||
@@ -1,11 +1,11 @@
|
||||
import { VectorModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { EmbeddingModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { getAIApi } from '../config';
|
||||
import { countPromptTokens } from '../../../common/string/tiktoken/index';
|
||||
import { EmbeddingTypeEnm } from '@fastgpt/global/core/ai/constants';
|
||||
import { addLog } from '../../../common/system/log';
|
||||
|
||||
type GetVectorProps = {
|
||||
model: VectorModelItemType;
|
||||
model: EmbeddingModelItemType;
|
||||
input: string;
|
||||
type?: `${EmbeddingTypeEnm}`;
|
||||
};
|
||||
@@ -24,13 +24,23 @@ export async function getVectorsByText({ model, input, type }: GetVectorProps) {
|
||||
|
||||
// input text to vector
|
||||
const result = await ai.embeddings
|
||||
.create({
|
||||
...model.defaultConfig,
|
||||
...(type === EmbeddingTypeEnm.db && model.dbConfig),
|
||||
...(type === EmbeddingTypeEnm.query && model.queryConfig),
|
||||
model: model.model,
|
||||
input: [input]
|
||||
})
|
||||
.create(
|
||||
{
|
||||
...model.defaultConfig,
|
||||
...(type === EmbeddingTypeEnm.db && model.dbConfig),
|
||||
...(type === EmbeddingTypeEnm.query && model.queryConfig),
|
||||
model: model.model,
|
||||
input: [input]
|
||||
},
|
||||
model.requestUrl && model.requestAuth
|
||||
? {
|
||||
path: model.requestUrl,
|
||||
headers: {
|
||||
Authorization: `Bearer ${model.requestAuth}`
|
||||
}
|
||||
}
|
||||
: {}
|
||||
)
|
||||
.then(async (res) => {
|
||||
if (!res.data) {
|
||||
addLog.error('Embedding API is not responding', res);
|
||||
|
||||
@@ -2,10 +2,12 @@ import { replaceVariable } from '@fastgpt/global/common/string/tools';
|
||||
import { createChatCompletion } from '../config';
|
||||
import { ChatItemType } from '@fastgpt/global/core/chat/type';
|
||||
import { countGptMessagesTokens, countPromptTokens } from '../../../common/string/tiktoken/index';
|
||||
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';
|
||||
import { chats2GPTMessages } from '@fastgpt/global/core/chat/adapt';
|
||||
import { getLLMModel } from '../model';
|
||||
import { llmCompletionsBodyFormat } from '../utils';
|
||||
import { addLog } from '../../../common/system/log';
|
||||
import { filterGPTMessageByMaxContext } from '../../chat/utils';
|
||||
import json5 from 'json5';
|
||||
|
||||
/*
|
||||
query extension - 问题扩展
|
||||
@@ -13,72 +15,73 @@ import { addLog } from '../../../common/system/log';
|
||||
*/
|
||||
|
||||
const title = global.feConfigs?.systemTitle || 'FastAI';
|
||||
const defaultPrompt = `作为一个向量检索助手,你的任务是结合历史记录,从不同角度,为“原问题”生成个不同版本的“检索词”,从而提高向量检索的语义丰富度,提高向量检索的精度。
|
||||
const defaultPrompt = `## 你的任务
|
||||
你作为一个向量检索助手,你的任务是结合历史记录,从不同角度,为“原问题”生成个不同版本的“检索词”,从而提高向量检索的语义丰富度,提高向量检索的精度。
|
||||
生成的问题要求指向对象清晰明确,并与“原问题语言相同”。
|
||||
|
||||
参考 <Example></Example> 标中的示例来完成任务。
|
||||
## 参考示例
|
||||
|
||||
<Example>
|
||||
历史记录:
|
||||
"""
|
||||
null
|
||||
"""
|
||||
原问题: 介绍下剧情。
|
||||
检索词: ["介绍下故事的背景。","故事的主题是什么?","介绍下故事的主要人物。"]
|
||||
----------------
|
||||
历史记录:
|
||||
"""
|
||||
Q: 对话背景。
|
||||
A: 当前对话是关于 Nginx 的介绍和使用等。
|
||||
user: 对话背景。
|
||||
assistant: 当前对话是关于 Nginx 的介绍和使用等。
|
||||
"""
|
||||
原问题: 怎么下载
|
||||
检索词: ["Nginx 如何下载?","下载 Nginx 需要什么条件?","有哪些渠道可以下载 Nginx?"]
|
||||
----------------
|
||||
历史记录:
|
||||
"""
|
||||
Q: 对话背景。
|
||||
A: 当前对话是关于 Nginx 的介绍和使用等。
|
||||
Q: 报错 "no connection"
|
||||
A: 报错"no connection"可能是因为……
|
||||
user: 对话背景。
|
||||
assistant: 当前对话是关于 Nginx 的介绍和使用等。
|
||||
user: 报错 "no connection"
|
||||
assistant: 报错"no connection"可能是因为……
|
||||
"""
|
||||
原问题: 怎么解决
|
||||
检索词: ["Nginx报错"no connection"如何解决?","造成'no connection'报错的原因。","Nginx提示'no connection',要怎么办?"]
|
||||
----------------
|
||||
历史记录:
|
||||
"""
|
||||
Q: 护产假多少天?
|
||||
A: 护产假的天数根据员工所在的城市而定。请提供您所在的城市,以便我回答您的问题。
|
||||
user: How long is the maternity leave?
|
||||
assistant: The number of days of maternity leave depends on the city in which the employee is located. Please provide your city so that I can answer your questions.
|
||||
"""
|
||||
原问题: 沈阳
|
||||
检索词: ["沈阳的护产假多少天?","沈阳的护产假政策。","沈阳的护产假标准。"]
|
||||
原问题: ShenYang
|
||||
检索词: ["How many days is maternity leave in Shenyang?","Shenyang's maternity leave policy.","The standard of maternity leave in Shenyang."]
|
||||
----------------
|
||||
历史记录:
|
||||
"""
|
||||
Q: 作者是谁?
|
||||
A: ${title} 的作者是 labring。
|
||||
user: 作者是谁?
|
||||
assistant: ${title} 的作者是 labring。
|
||||
"""
|
||||
原问题: Tell me about him
|
||||
检索词: ["Introduce labring, the author of ${title}." ," Background information on author labring." "," Why does labring do ${title}?"]
|
||||
----------------
|
||||
历史记录:
|
||||
"""
|
||||
Q: 对话背景。
|
||||
A: 关于 ${title} 的介绍和使用等问题。
|
||||
user: 对话背景。
|
||||
assistant: 关于 ${title} 的介绍和使用等问题。
|
||||
"""
|
||||
原问题: 你好。
|
||||
检索词: ["你好"]
|
||||
----------------
|
||||
历史记录:
|
||||
"""
|
||||
Q: ${title} 如何收费?
|
||||
A: ${title} 收费可以参考……
|
||||
user: ${title} 如何收费?
|
||||
assistant: ${title} 收费可以参考……
|
||||
"""
|
||||
原问题: 你知道 laf 么?
|
||||
检索词: ["laf 的官网地址是多少?","laf 的使用教程。","laf 有什么特点和优势。"]
|
||||
----------------
|
||||
历史记录:
|
||||
"""
|
||||
Q: ${title} 的优势
|
||||
A: 1. 开源
|
||||
user: ${title} 的优势
|
||||
assistant: 1. 开源
|
||||
2. 简便
|
||||
3. 扩展性强
|
||||
"""
|
||||
@@ -87,18 +90,20 @@ A: 1. 开源
|
||||
----------------
|
||||
历史记录:
|
||||
"""
|
||||
Q: 什么是 ${title}?
|
||||
A: ${title} 是一个 RAG 平台。
|
||||
Q: 什么是 Laf?
|
||||
A: Laf 是一个云函数开发平台。
|
||||
user: 什么是 ${title}?
|
||||
assistant: ${title} 是一个 RAG 平台。
|
||||
user: 什么是 Laf?
|
||||
assistant: Laf 是一个云函数开发平台。
|
||||
"""
|
||||
原问题: 它们有什么关系?
|
||||
检索词: ["${title}和Laf有什么关系?","介绍下${title}","介绍下Laf"]
|
||||
</Example>
|
||||
|
||||
-----
|
||||
## 输出要求
|
||||
|
||||
下面是正式的任务:
|
||||
1. 输出格式为 JSON 数组,数组中每个元素为字符串。无需对输出进行任何解释。
|
||||
2. 输出语言与原问题相同。原问题为中文则输出中文;原问题为英文则输出英文。
|
||||
|
||||
## 开始任务
|
||||
|
||||
历史记录:
|
||||
"""
|
||||
@@ -125,26 +130,39 @@ export const queryExtension = async ({
|
||||
outputTokens: number;
|
||||
}> => {
|
||||
const systemFewShot = chatBg
|
||||
? `Q: 对话背景。
|
||||
A: ${chatBg}
|
||||
? `user: 对话背景。
|
||||
assistant: ${chatBg}
|
||||
`
|
||||
: '';
|
||||
const historyFewShot = histories
|
||||
.map((item) => {
|
||||
const role = item.obj === 'Human' ? 'Q' : 'A';
|
||||
return `${role}: ${chatValue2RuntimePrompt(item.value).text}`;
|
||||
})
|
||||
.join('\n');
|
||||
const concatFewShot = `${systemFewShot}${historyFewShot}`.trim();
|
||||
|
||||
const modelData = getLLMModel(model);
|
||||
const filterHistories = await filterGPTMessageByMaxContext({
|
||||
messages: chats2GPTMessages({ messages: histories, reserveId: false }),
|
||||
maxContext: modelData.maxContext - 1000
|
||||
});
|
||||
|
||||
const historyFewShot = filterHistories
|
||||
.map((item) => {
|
||||
const role = item.role;
|
||||
const content = item.content;
|
||||
if ((role === 'user' || role === 'assistant') && content) {
|
||||
if (typeof content === 'string') {
|
||||
return `${role}: ${content}`;
|
||||
} else {
|
||||
return `${role}: ${content.map((item) => (item.type === 'text' ? item.text : '')).join('\n')}`;
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join('\n');
|
||||
const concatFewShot = `${systemFewShot}${historyFewShot}`.trim();
|
||||
|
||||
const messages = [
|
||||
{
|
||||
role: 'user',
|
||||
content: replaceVariable(defaultPrompt, {
|
||||
query: `${query}`,
|
||||
histories: concatFewShot
|
||||
histories: concatFewShot || 'null'
|
||||
})
|
||||
}
|
||||
] as any;
|
||||
@@ -154,7 +172,7 @@ A: ${chatBg}
|
||||
{
|
||||
stream: false,
|
||||
model: modelData.model,
|
||||
temperature: 0.01,
|
||||
temperature: 0.1,
|
||||
messages
|
||||
},
|
||||
modelData
|
||||
@@ -172,22 +190,41 @@ A: ${chatBg}
|
||||
};
|
||||
}
|
||||
|
||||
const start = answer.indexOf('[');
|
||||
const end = answer.lastIndexOf(']');
|
||||
if (start === -1 || end === -1) {
|
||||
addLog.warn('Query extension failed, not a valid JSON', {
|
||||
answer
|
||||
});
|
||||
return {
|
||||
rawQuery: query,
|
||||
extensionQueries: [],
|
||||
model,
|
||||
inputTokens: 0,
|
||||
outputTokens: 0
|
||||
};
|
||||
}
|
||||
|
||||
// Intercept the content of [] and retain []
|
||||
answer = answer.match(/\[.*?\]/)?.[0] || '';
|
||||
answer = answer.replace(/\\"/g, '"');
|
||||
const jsonStr = answer
|
||||
.substring(start, end + 1)
|
||||
.replace(/(\\n|\\)/g, '')
|
||||
.replace(/ /g, '');
|
||||
|
||||
try {
|
||||
const queries = JSON.parse(answer) as string[];
|
||||
const queries = json5.parse(jsonStr) as string[];
|
||||
|
||||
return {
|
||||
rawQuery: query,
|
||||
extensionQueries: Array.isArray(queries) ? queries : [],
|
||||
extensionQueries: (Array.isArray(queries) ? queries : []).slice(0, 5),
|
||||
model,
|
||||
inputTokens: await countGptMessagesTokens(messages),
|
||||
outputTokens: await countPromptTokens(answer)
|
||||
};
|
||||
} catch (error) {
|
||||
addLog.error(`Query extension error`, error);
|
||||
addLog.warn('Query extension failed, not a valid JSON', {
|
||||
answer
|
||||
});
|
||||
return {
|
||||
rawQuery: query,
|
||||
extensionQueries: [],
|
||||
|
||||
@@ -1,51 +1,52 @@
|
||||
import { SystemModelItemType } from './type';
|
||||
|
||||
export const getDefaultLLMModel = () => global?.systemDefaultModel.llm!;
|
||||
export const getLLMModel = (model?: string) => {
|
||||
return (
|
||||
global.llmModels.find((item) => item.model === model || item.name === model) ??
|
||||
global.llmModels[0]
|
||||
);
|
||||
if (!model) return getDefaultLLMModel();
|
||||
return global.llmModelMap.get(model) || getDefaultLLMModel();
|
||||
};
|
||||
|
||||
export const getDatasetModel = (model?: string) => {
|
||||
return (
|
||||
global.llmModels
|
||||
Array.from(global.llmModelMap.values())
|
||||
?.filter((item) => item.datasetProcess)
|
||||
?.find((item) => item.model === model || item.name === model) ?? global.llmModels[0]
|
||||
?.find((item) => item.model === model || item.name === model) ?? getDefaultLLMModel()
|
||||
);
|
||||
};
|
||||
|
||||
export const getVectorModel = (model?: string) => {
|
||||
return (
|
||||
global.vectorModels.find((item) => item.model === model || item.name === model) ||
|
||||
global.vectorModels[0]
|
||||
);
|
||||
export const getDefaultEmbeddingModel = () => global?.systemDefaultModel.embedding!;
|
||||
export const getEmbeddingModel = (model?: string) => {
|
||||
if (!model) return getDefaultEmbeddingModel();
|
||||
return global.embeddingModelMap.get(model) || getDefaultEmbeddingModel();
|
||||
};
|
||||
|
||||
export function getAudioSpeechModel(model?: string) {
|
||||
return (
|
||||
global.audioSpeechModels.find((item) => item.model === model || item.name === model) ||
|
||||
global.audioSpeechModels[0]
|
||||
);
|
||||
export const getDefaultTTSModel = () => global?.systemDefaultModel.tts!;
|
||||
export function getTTSModel(model?: string) {
|
||||
if (!model) return getDefaultTTSModel();
|
||||
return global.ttsModelMap.get(model) || getDefaultTTSModel();
|
||||
}
|
||||
|
||||
export function getWhisperModel(model?: string) {
|
||||
return global.whisperModel;
|
||||
export const getDefaultSTTModel = () => global?.systemDefaultModel.stt!;
|
||||
export function getSTTModel(model?: string) {
|
||||
if (!model) return getDefaultSTTModel();
|
||||
return global.sttModelMap.get(model) || getDefaultSTTModel();
|
||||
}
|
||||
|
||||
export const getDefaultRerankModel = () => global?.systemDefaultModel.rerank!;
|
||||
export function getReRankModel(model?: string) {
|
||||
return global.reRankModels.find((item) => item.model === model);
|
||||
if (!model) return getDefaultRerankModel();
|
||||
return global.reRankModelMap.get(model) || getDefaultRerankModel();
|
||||
}
|
||||
|
||||
export enum ModelTypeEnum {
|
||||
llm = 'llm',
|
||||
vector = 'vector',
|
||||
audioSpeech = 'audioSpeech',
|
||||
whisper = 'whisper',
|
||||
rerank = 'rerank'
|
||||
}
|
||||
export const getModelMap = {
|
||||
[ModelTypeEnum.llm]: getLLMModel,
|
||||
[ModelTypeEnum.vector]: getVectorModel,
|
||||
[ModelTypeEnum.audioSpeech]: getAudioSpeechModel,
|
||||
[ModelTypeEnum.whisper]: getWhisperModel,
|
||||
[ModelTypeEnum.rerank]: getReRankModel
|
||||
export const findAIModel = (model: string): SystemModelItemType | undefined => {
|
||||
return (
|
||||
global.llmModelMap.get(model) ||
|
||||
global.embeddingModelMap.get(model) ||
|
||||
global.ttsModelMap.get(model) ||
|
||||
global.sttModelMap.get(model) ||
|
||||
global.reRankModelMap.get(model)
|
||||
);
|
||||
};
|
||||
export const findModelFromAlldata = (model: string) => {
|
||||
return global.systemModelList.find((item) => item.model === model);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { addLog } from '../../../common/system/log';
|
||||
import { POST } from '../../../common/api/serverRequest';
|
||||
import { getDefaultRerankModel } from '../model';
|
||||
import { getAxiosConfig } from '../config';
|
||||
import { ReRankModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
|
||||
type PostReRankResponse = {
|
||||
id: string;
|
||||
@@ -11,21 +14,23 @@ type PostReRankResponse = {
|
||||
type ReRankCallResult = { id: string; score?: number }[];
|
||||
|
||||
export function reRankRecall({
|
||||
model = getDefaultRerankModel(),
|
||||
query,
|
||||
documents
|
||||
}: {
|
||||
model?: ReRankModelItemType;
|
||||
query: string;
|
||||
documents: { id: string; text: string }[];
|
||||
}): Promise<ReRankCallResult> {
|
||||
const model = global.reRankModels[0];
|
||||
|
||||
if (!model || !model?.requestUrl) {
|
||||
if (!model) {
|
||||
return Promise.reject('no rerank model');
|
||||
}
|
||||
|
||||
const { baseUrl, authorization } = getAxiosConfig({});
|
||||
|
||||
let start = Date.now();
|
||||
return POST<PostReRankResponse>(
|
||||
model.requestUrl,
|
||||
model.requestUrl ? model.requestUrl : `${baseUrl}/rerank`,
|
||||
{
|
||||
model: model.model,
|
||||
query,
|
||||
@@ -33,7 +38,7 @@ export function reRankRecall({
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${model.requestAuth}`
|
||||
Authorization: model.requestAuth ? model.requestAuth : authorization
|
||||
},
|
||||
timeout: 30000
|
||||
}
|
||||
@@ -53,6 +58,6 @@ export function reRankRecall({
|
||||
.catch((err) => {
|
||||
addLog.error('rerank error', err);
|
||||
|
||||
return [];
|
||||
return Promise.reject(err);
|
||||
});
|
||||
}
|
||||
|
||||
42
packages/service/core/ai/type.d.ts
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||
import {
|
||||
STTModelType,
|
||||
ReRankModelItemType,
|
||||
TTSModelType,
|
||||
EmbeddingModelItemType,
|
||||
LLMModelItemType
|
||||
} from '@fastgpt/global/core/ai/model.d';
|
||||
|
||||
export type SystemModelSchemaType = {
|
||||
_id: string;
|
||||
model: string;
|
||||
metadata: SystemModelItemType;
|
||||
};
|
||||
|
||||
export type SystemModelItemType =
|
||||
| LLMModelItemType
|
||||
| EmbeddingModelItemType
|
||||
| TTSModelType
|
||||
| STTModelType
|
||||
| ReRankModelItemType;
|
||||
|
||||
export type SystemDefaultModelType = {
|
||||
[ModelTypeEnum.llm]?: LLMModelItemType;
|
||||
[ModelTypeEnum.embedding]?: EmbeddingModelItemType;
|
||||
[ModelTypeEnum.tts]?: TTSModelType;
|
||||
[ModelTypeEnum.stt]?: STTModelType;
|
||||
[ModelTypeEnum.rerank]?: ReRankModelItemType;
|
||||
};
|
||||
|
||||
declare global {
|
||||
var systemModelList: SystemModelItemType[];
|
||||
// var systemModelMap: Map<string, SystemModelItemType>;
|
||||
var llmModelMap: Map<string, LLMModelItemType>;
|
||||
var embeddingModelMap: Map<string, EmbeddingModelItemType>;
|
||||
var ttsModelMap: Map<string, TTSModelType>;
|
||||
var sttModelMap: Map<string, STTModelType>;
|
||||
var reRankModelMap: Map<string, ReRankModelItemType>;
|
||||
|
||||
var systemActiveModelList: SystemModelItemType[];
|
||||
var systemDefaultModel: SystemDefaultModelType;
|
||||
}
|
||||
@@ -2,32 +2,23 @@ import { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import {
|
||||
ChatCompletionCreateParamsNonStreaming,
|
||||
ChatCompletionCreateParamsStreaming,
|
||||
ChatCompletionMessageParam
|
||||
StreamChatType
|
||||
} from '@fastgpt/global/core/ai/type';
|
||||
import { countGptMessagesTokens } from '../../common/string/tiktoken';
|
||||
import { getLLMModel } from './model';
|
||||
|
||||
export const computedMaxToken = async ({
|
||||
/*
|
||||
Count response max token
|
||||
*/
|
||||
export const computedMaxToken = ({
|
||||
maxToken,
|
||||
model,
|
||||
filterMessages = []
|
||||
model
|
||||
}: {
|
||||
maxToken?: number;
|
||||
model: LLMModelItemType;
|
||||
filterMessages: ChatCompletionMessageParam[];
|
||||
}) => {
|
||||
if (maxToken === undefined) return;
|
||||
|
||||
maxToken = Math.min(maxToken, model.maxResponse);
|
||||
const tokensLimit = model.maxContext;
|
||||
|
||||
/* count response max token */
|
||||
const promptsToken = await countGptMessagesTokens(filterMessages);
|
||||
maxToken = promptsToken + maxToken > tokensLimit ? tokensLimit - promptsToken : maxToken;
|
||||
|
||||
if (maxToken <= 0) {
|
||||
maxToken = 200;
|
||||
}
|
||||
return maxToken;
|
||||
};
|
||||
|
||||
@@ -39,6 +30,7 @@ export const computedTemperature = ({
|
||||
model: LLMModelItemType;
|
||||
temperature: number;
|
||||
}) => {
|
||||
if (typeof model.maxTemperature !== 'number') return undefined;
|
||||
temperature = +(model.maxTemperature * (temperature / 10)).toFixed(2);
|
||||
temperature = Math.max(temperature, 0.01);
|
||||
|
||||
@@ -87,3 +79,12 @@ export const llmCompletionsBodyFormat = <T extends CompletionsBodyType>(
|
||||
|
||||
return requestBody as InferCompletionsBody<T>;
|
||||
};
|
||||
|
||||
export const llmStreamResponseToText = async (response: StreamChatType) => {
|
||||
let answer = '';
|
||||
for await (const part of response) {
|
||||
const content = part.choices?.[0]?.delta?.content || '';
|
||||
answer += content;
|
||||
}
|
||||
return answer;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { countGptMessagesTokens } from '../../common/string/tiktoken/index';
|
||||
import type {
|
||||
ChatCompletionAssistantMessageParam,
|
||||
ChatCompletionContentPart,
|
||||
ChatCompletionContentPartRefusal,
|
||||
ChatCompletionContentPartText,
|
||||
ChatCompletionMessageParam,
|
||||
SdkChatCompletionMessageParam
|
||||
} from '@fastgpt/global/core/ai/type.d';
|
||||
@@ -11,36 +14,19 @@ import { serverRequestBaseUrl } from '../../common/api/serverRequest';
|
||||
import { i18nT } from '../../../web/i18n/utils';
|
||||
import { addLog } from '../../common/system/log';
|
||||
|
||||
export const filterGPTMessageByMaxTokens = async ({
|
||||
export const filterGPTMessageByMaxContext = async ({
|
||||
messages = [],
|
||||
maxTokens
|
||||
maxContext
|
||||
}: {
|
||||
messages: ChatCompletionMessageParam[];
|
||||
maxTokens: number;
|
||||
maxContext: number;
|
||||
}) => {
|
||||
if (!Array.isArray(messages)) {
|
||||
return [];
|
||||
}
|
||||
const rawTextLen = messages.reduce((sum, item) => {
|
||||
if (typeof item.content === 'string') {
|
||||
return sum + item.content.length;
|
||||
}
|
||||
if (Array.isArray(item.content)) {
|
||||
return (
|
||||
sum +
|
||||
item.content.reduce((sum, item) => {
|
||||
if (item.type === 'text') {
|
||||
return sum + item.text.length;
|
||||
}
|
||||
return sum;
|
||||
}, 0)
|
||||
);
|
||||
}
|
||||
return sum;
|
||||
}, 0);
|
||||
|
||||
// If the text length is less than half of the maximum token, no calculation is required
|
||||
if (rawTextLen < maxTokens * 0.5) {
|
||||
if (messages.length < 4) {
|
||||
return messages;
|
||||
}
|
||||
|
||||
@@ -52,7 +38,7 @@ export const filterGPTMessageByMaxTokens = async ({
|
||||
const chatPrompts: ChatCompletionMessageParam[] = messages.slice(chatStartIndex);
|
||||
|
||||
// reduce token of systemPrompt
|
||||
maxTokens -= await countGptMessagesTokens(systemPrompts);
|
||||
maxContext -= await countGptMessagesTokens(systemPrompts);
|
||||
|
||||
// Save the last chat prompt(question)
|
||||
const question = chatPrompts.pop();
|
||||
@@ -70,9 +56,9 @@ export const filterGPTMessageByMaxTokens = async ({
|
||||
}
|
||||
|
||||
const tokens = await countGptMessagesTokens([assistant, user]);
|
||||
maxTokens -= tokens;
|
||||
maxContext -= tokens;
|
||||
/* 整体 tokens 超出范围,截断 */
|
||||
if (maxTokens < 0) {
|
||||
if (maxContext < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -102,223 +88,324 @@ export const loadRequestMessages = async ({
|
||||
useVision?: boolean;
|
||||
origin?: string;
|
||||
}) => {
|
||||
// Load image to base64
|
||||
const loadImageToBase64 = async (messages: ChatCompletionContentPart[]) => {
|
||||
return Promise.all(
|
||||
messages.map(async (item) => {
|
||||
if (item.type === 'image_url') {
|
||||
// Remove url origin
|
||||
const imgUrl = (() => {
|
||||
if (origin && item.image_url.url.startsWith(origin)) {
|
||||
return item.image_url.url.replace(origin, '');
|
||||
}
|
||||
return item.image_url.url;
|
||||
})();
|
||||
|
||||
// base64 image
|
||||
if (imgUrl.startsWith('data:image/')) {
|
||||
return item;
|
||||
}
|
||||
|
||||
try {
|
||||
// If imgUrl is a local path, load image from local, and set url to base64
|
||||
if (imgUrl.startsWith('/') || process.env.MULTIPLE_DATA_TO_BASE64 === 'true') {
|
||||
addLog.debug('Load image from local server', {
|
||||
baseUrl: serverRequestBaseUrl,
|
||||
requestUrl: imgUrl
|
||||
});
|
||||
const response = await axios.get(imgUrl, {
|
||||
baseURL: serverRequestBaseUrl,
|
||||
responseType: 'arraybuffer',
|
||||
proxy: false
|
||||
});
|
||||
const base64 = Buffer.from(response.data, 'binary').toString('base64');
|
||||
const imageType =
|
||||
getFileContentTypeFromHeader(response.headers['content-type']) ||
|
||||
guessBase64ImageType(base64);
|
||||
|
||||
return {
|
||||
...item,
|
||||
image_url: {
|
||||
...item.image_url,
|
||||
url: `data:${imageType};base64,${base64}`
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 检查下这个图片是否可以被访问,如果不行的话,则过滤掉
|
||||
const response = await axios.head(imgUrl, {
|
||||
timeout: 10000
|
||||
});
|
||||
if (response.status < 200 || response.status >= 400) {
|
||||
addLog.info(`Filter invalid image: ${imgUrl}`);
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return item;
|
||||
})
|
||||
).then((res) => res.filter(Boolean) as ChatCompletionContentPart[]);
|
||||
const replaceLinkUrl = (text: string) => {
|
||||
const baseURL = process.env.FE_DOMAIN;
|
||||
if (!baseURL) return text;
|
||||
// 匹配 /api/system/img/xxx.xx 的图片链接,并追加 baseURL
|
||||
return text.replace(/(\/api\/system\/img\/[^\s.]*\.[^\s]*)/g, (match, p1) => `${baseURL}${p1}`);
|
||||
};
|
||||
// Split question text and image
|
||||
const parseStringWithImages = (input: string): ChatCompletionContentPart[] => {
|
||||
if (!useVision || input.length > 500) {
|
||||
return [{ type: 'text', text: input || '' }];
|
||||
const parseSystemMessage = (
|
||||
content: string | ChatCompletionContentPartText[]
|
||||
): string | ChatCompletionContentPartText[] | undefined => {
|
||||
if (typeof content === 'string') {
|
||||
if (!content) return;
|
||||
return replaceLinkUrl(content);
|
||||
}
|
||||
|
||||
// 正则表达式匹配图片URL
|
||||
const imageRegex =
|
||||
/(https?:\/\/[^\s/$.?#].[^\s]*\.(?:png|jpe?g|gif|webp|bmp|tiff?|svg|ico|heic|avif))/gi;
|
||||
|
||||
const result: ChatCompletionContentPart[] = [];
|
||||
|
||||
// 提取所有HTTPS图片URL并添加到result开头
|
||||
const httpsImages = [...new Set(Array.from(input.matchAll(imageRegex), (m) => m[0]))];
|
||||
httpsImages.forEach((url) => {
|
||||
result.push({
|
||||
type: 'image_url',
|
||||
image_url: {
|
||||
url: url
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Too many images return text
|
||||
if (httpsImages.length > 4) {
|
||||
return [{ type: 'text', text: input || '' }];
|
||||
}
|
||||
|
||||
// 添加原始input作为文本
|
||||
result.push({ type: 'text', text: input });
|
||||
return result;
|
||||
const arrayContent = content
|
||||
.filter((item) => item.text)
|
||||
.map((item) => ({ ...item, text: replaceLinkUrl(item.text) }));
|
||||
if (arrayContent.length === 0) return;
|
||||
return arrayContent;
|
||||
};
|
||||
// Parse user content(text and img) Store history => api messages
|
||||
const parseUserContent = async (content: string | ChatCompletionContentPart[]) => {
|
||||
if (typeof content === 'string') {
|
||||
return loadImageToBase64(parseStringWithImages(content));
|
||||
}
|
||||
|
||||
const result = await Promise.all(
|
||||
content.map(async (item) => {
|
||||
if (item.type === 'text') return parseStringWithImages(item.text);
|
||||
if (item.type === 'file_url') return; // LLM not support file_url
|
||||
|
||||
if (!item.image_url.url) return item;
|
||||
|
||||
return item;
|
||||
})
|
||||
);
|
||||
|
||||
return loadImageToBase64(result.flat().filter(Boolean) as ChatCompletionContentPart[]);
|
||||
};
|
||||
|
||||
// format GPT messages, concat text messages
|
||||
const clearInvalidMessages = (messages: ChatCompletionMessageParam[]) => {
|
||||
return messages
|
||||
.map((item) => {
|
||||
if (item.role === ChatCompletionRequestMessageRoleEnum.System && !item.content) {
|
||||
return;
|
||||
}
|
||||
if (item.role === ChatCompletionRequestMessageRoleEnum.User) {
|
||||
if (item.content === undefined) return;
|
||||
|
||||
if (typeof item.content === 'string') {
|
||||
return {
|
||||
...item,
|
||||
content: item.content.trim()
|
||||
};
|
||||
}
|
||||
|
||||
// array
|
||||
if (item.content.length === 0) return;
|
||||
if (item.content.length === 1 && item.content[0].type === 'text') {
|
||||
return {
|
||||
...item,
|
||||
content: item.content[0].text
|
||||
};
|
||||
}
|
||||
}
|
||||
if (item.role === ChatCompletionRequestMessageRoleEnum.Assistant) {
|
||||
if (item.content === undefined && !item.tool_calls && !item.function_call) return;
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
.filter(Boolean) as ChatCompletionMessageParam[];
|
||||
};
|
||||
/*
|
||||
Merge data for some consecutive roles
|
||||
1. Contiguous assistant and both have content, merge content
|
||||
*/
|
||||
const mergeConsecutiveMessages = (
|
||||
messages: ChatCompletionMessageParam[]
|
||||
): ChatCompletionMessageParam[] => {
|
||||
return messages.reduce((mergedMessages: ChatCompletionMessageParam[], currentMessage) => {
|
||||
const lastMessage = mergedMessages[mergedMessages.length - 1];
|
||||
|
||||
if (
|
||||
lastMessage &&
|
||||
currentMessage.role === ChatCompletionRequestMessageRoleEnum.Assistant &&
|
||||
lastMessage.role === ChatCompletionRequestMessageRoleEnum.Assistant &&
|
||||
typeof lastMessage.content === 'string' &&
|
||||
typeof currentMessage.content === 'string'
|
||||
) {
|
||||
lastMessage.content += currentMessage ? `\n${currentMessage.content}` : '';
|
||||
} else {
|
||||
mergedMessages.push(currentMessage);
|
||||
// Split question text and image
|
||||
const parseStringWithImages = (input: string): ChatCompletionContentPart[] => {
|
||||
if (!useVision || input.length > 500) {
|
||||
return [{ type: 'text', text: input }];
|
||||
}
|
||||
|
||||
return mergedMessages;
|
||||
}, []);
|
||||
// 正则表达式匹配图片URL
|
||||
const imageRegex =
|
||||
/(https?:\/\/[^\s/$.?#].[^\s]*\.(?:png|jpe?g|gif|webp|bmp|tiff?|svg|ico|heic|avif))/gi;
|
||||
|
||||
const result: ChatCompletionContentPart[] = [];
|
||||
|
||||
// 提取所有HTTPS图片URL并添加到result开头
|
||||
const httpsImages = [...new Set(Array.from(input.matchAll(imageRegex), (m) => m[0]))];
|
||||
httpsImages.forEach((url) => {
|
||||
result.push({
|
||||
type: 'image_url',
|
||||
image_url: {
|
||||
url: url
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Too many images return text
|
||||
if (httpsImages.length > 4) {
|
||||
return [{ type: 'text', text: input }];
|
||||
}
|
||||
|
||||
// 添加原始input作为文本
|
||||
result.push({ type: 'text', text: input });
|
||||
return result;
|
||||
};
|
||||
// Load image to base64
|
||||
const loadUserContentImage = async (content: ChatCompletionContentPart[]) => {
|
||||
return Promise.all(
|
||||
content.map(async (item) => {
|
||||
if (item.type === 'image_url') {
|
||||
// Remove url origin
|
||||
const imgUrl = (() => {
|
||||
if (origin && item.image_url.url.startsWith(origin)) {
|
||||
return item.image_url.url.replace(origin, '');
|
||||
}
|
||||
return item.image_url.url;
|
||||
})();
|
||||
|
||||
// base64 image
|
||||
if (imgUrl.startsWith('data:image/')) {
|
||||
return item;
|
||||
}
|
||||
|
||||
try {
|
||||
// If imgUrl is a local path, load image from local, and set url to base64
|
||||
if (imgUrl.startsWith('/') || process.env.MULTIPLE_DATA_TO_BASE64 === 'true') {
|
||||
addLog.debug('Load image from local server', {
|
||||
baseUrl: serverRequestBaseUrl,
|
||||
requestUrl: imgUrl
|
||||
});
|
||||
const response = await axios.get(imgUrl, {
|
||||
baseURL: serverRequestBaseUrl,
|
||||
responseType: 'arraybuffer',
|
||||
proxy: false
|
||||
});
|
||||
const base64 = Buffer.from(response.data, 'binary').toString('base64');
|
||||
const imageType =
|
||||
getFileContentTypeFromHeader(response.headers['content-type']) ||
|
||||
guessBase64ImageType(base64);
|
||||
|
||||
return {
|
||||
...item,
|
||||
image_url: {
|
||||
...item.image_url,
|
||||
url: `data:${imageType};base64,${base64}`
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 检查下这个图片是否可以被访问,如果不行的话,则过滤掉
|
||||
const response = await axios.head(imgUrl, {
|
||||
timeout: 10000
|
||||
});
|
||||
if (response.status < 200 || response.status >= 400) {
|
||||
addLog.info(`Filter invalid image: ${imgUrl}`);
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return item;
|
||||
})
|
||||
).then((res) => res.filter(Boolean) as ChatCompletionContentPart[]);
|
||||
};
|
||||
|
||||
if (content === undefined) return;
|
||||
if (typeof content === 'string') {
|
||||
if (content === '') return;
|
||||
|
||||
const loadImageContent = await loadUserContentImage(parseStringWithImages(content));
|
||||
if (loadImageContent.length === 0) return;
|
||||
return loadImageContent;
|
||||
}
|
||||
|
||||
const result = (
|
||||
await Promise.all(
|
||||
content.map(async (item) => {
|
||||
if (item.type === 'text') {
|
||||
if (item.text) return parseStringWithImages(item.text);
|
||||
return;
|
||||
}
|
||||
if (item.type === 'file_url') return; // LLM not support file_url
|
||||
if (item.type === 'image_url') {
|
||||
// close vision, remove image_url
|
||||
if (!useVision) return;
|
||||
// remove empty image_url
|
||||
if (!item.image_url.url) return;
|
||||
}
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
)
|
||||
.flat()
|
||||
.filter(Boolean) as ChatCompletionContentPart[];
|
||||
|
||||
const loadImageContent = await loadUserContentImage(result);
|
||||
|
||||
if (loadImageContent.length === 0) return;
|
||||
return loadImageContent;
|
||||
};
|
||||
|
||||
const formatAssistantItem = (item: ChatCompletionAssistantMessageParam) => {
|
||||
return {
|
||||
role: item.role,
|
||||
content: item.content,
|
||||
function_call: item.function_call,
|
||||
name: item.name,
|
||||
refusal: item.refusal,
|
||||
tool_calls: item.tool_calls
|
||||
};
|
||||
};
|
||||
const parseAssistantContent = (
|
||||
content:
|
||||
| string
|
||||
| (ChatCompletionContentPartText | ChatCompletionContentPartRefusal)[]
|
||||
| null
|
||||
| undefined
|
||||
) => {
|
||||
if (typeof content === 'string') {
|
||||
return content || '';
|
||||
}
|
||||
// 交互节点
|
||||
if (!content) return '';
|
||||
|
||||
const result = content.filter((item) => item?.type === 'text');
|
||||
if (result.length === 0) return '';
|
||||
|
||||
return result.map((item) => item.text).join('\n');
|
||||
};
|
||||
|
||||
if (messages.length === 0) {
|
||||
return Promise.reject(i18nT('common:core.chat.error.Messages empty'));
|
||||
}
|
||||
|
||||
// filter messages file
|
||||
const filterMessages = messages.map((item) => {
|
||||
// If useVision=false, only retain text.
|
||||
if (
|
||||
item.role === ChatCompletionRequestMessageRoleEnum.User &&
|
||||
Array.isArray(item.content) &&
|
||||
!useVision
|
||||
) {
|
||||
return {
|
||||
...item,
|
||||
content: item.content.filter((item) => item.type === 'text')
|
||||
};
|
||||
}
|
||||
// 合并相邻 role 的内容,只保留一个 role, content 变成数组。 assistant 的话,工具调用不合并。
|
||||
const mergeMessages = ((messages: ChatCompletionMessageParam[]): ChatCompletionMessageParam[] => {
|
||||
return messages.reduce((mergedMessages: ChatCompletionMessageParam[], currentMessage) => {
|
||||
const lastMessage = mergedMessages[mergedMessages.length - 1];
|
||||
|
||||
return item;
|
||||
});
|
||||
|
||||
const loadMessages = (await Promise.all(
|
||||
filterMessages.map(async (item) => {
|
||||
if (item.role === ChatCompletionRequestMessageRoleEnum.User) {
|
||||
return {
|
||||
...item,
|
||||
content: await parseUserContent(item.content)
|
||||
};
|
||||
} else if (item.role === ChatCompletionRequestMessageRoleEnum.Assistant) {
|
||||
// remove invalid field
|
||||
return {
|
||||
role: item.role,
|
||||
content: item.content,
|
||||
function_call: item.function_call,
|
||||
name: item.name,
|
||||
refusal: item.refusal,
|
||||
tool_calls: item.tool_calls
|
||||
};
|
||||
} else {
|
||||
return item;
|
||||
if (!lastMessage) {
|
||||
return [currentMessage];
|
||||
}
|
||||
})
|
||||
)) as ChatCompletionMessageParam[];
|
||||
|
||||
return mergeConsecutiveMessages(
|
||||
clearInvalidMessages(loadMessages)
|
||||
) as SdkChatCompletionMessageParam[];
|
||||
if (
|
||||
lastMessage.role === ChatCompletionRequestMessageRoleEnum.System &&
|
||||
currentMessage.role === ChatCompletionRequestMessageRoleEnum.System
|
||||
) {
|
||||
const lastContent: ChatCompletionContentPartText[] = Array.isArray(lastMessage.content)
|
||||
? lastMessage.content
|
||||
: [{ type: 'text', text: lastMessage.content || '' }];
|
||||
const currentContent: ChatCompletionContentPartText[] = Array.isArray(
|
||||
currentMessage.content
|
||||
)
|
||||
? currentMessage.content
|
||||
: [{ type: 'text', text: currentMessage.content || '' }];
|
||||
lastMessage.content = [...lastContent, ...currentContent];
|
||||
} // Handle user messages
|
||||
else if (
|
||||
lastMessage.role === ChatCompletionRequestMessageRoleEnum.User &&
|
||||
currentMessage.role === ChatCompletionRequestMessageRoleEnum.User
|
||||
) {
|
||||
const lastContent: ChatCompletionContentPart[] = Array.isArray(lastMessage.content)
|
||||
? lastMessage.content
|
||||
: [{ type: 'text', text: lastMessage.content }];
|
||||
const currentContent: ChatCompletionContentPart[] = Array.isArray(currentMessage.content)
|
||||
? currentMessage.content
|
||||
: [{ type: 'text', text: currentMessage.content }];
|
||||
lastMessage.content = [...lastContent, ...currentContent];
|
||||
} else if (
|
||||
lastMessage.role === ChatCompletionRequestMessageRoleEnum.Assistant &&
|
||||
currentMessage.role === ChatCompletionRequestMessageRoleEnum.Assistant
|
||||
) {
|
||||
// Content 不为空的对象,或者是交互节点
|
||||
if (
|
||||
(typeof lastMessage.content === 'string' ||
|
||||
Array.isArray(lastMessage.content) ||
|
||||
lastMessage.interactive) &&
|
||||
(typeof currentMessage.content === 'string' ||
|
||||
Array.isArray(currentMessage.content) ||
|
||||
currentMessage.interactive)
|
||||
) {
|
||||
const lastContent: (ChatCompletionContentPartText | ChatCompletionContentPartRefusal)[] =
|
||||
Array.isArray(lastMessage.content)
|
||||
? lastMessage.content
|
||||
: [{ type: 'text', text: lastMessage.content || '' }];
|
||||
const currentContent: (
|
||||
| ChatCompletionContentPartText
|
||||
| ChatCompletionContentPartRefusal
|
||||
)[] = Array.isArray(currentMessage.content)
|
||||
? currentMessage.content
|
||||
: [{ type: 'text', text: currentMessage.content || '' }];
|
||||
|
||||
lastMessage.content = [...lastContent, ...currentContent];
|
||||
} else {
|
||||
// 有其中一个没有 content,说明不是连续的文本输出
|
||||
mergedMessages.push(currentMessage);
|
||||
}
|
||||
} else {
|
||||
mergedMessages.push(currentMessage);
|
||||
}
|
||||
|
||||
return mergedMessages;
|
||||
}, []);
|
||||
})(messages);
|
||||
|
||||
const loadMessages = (
|
||||
await Promise.all(
|
||||
mergeMessages.map(async (item, i) => {
|
||||
if (item.role === ChatCompletionRequestMessageRoleEnum.System) {
|
||||
const content = parseSystemMessage(item.content);
|
||||
if (!content) return;
|
||||
return {
|
||||
...item,
|
||||
content
|
||||
};
|
||||
} else if (item.role === ChatCompletionRequestMessageRoleEnum.User) {
|
||||
const content = await parseUserContent(item.content);
|
||||
if (!content) {
|
||||
return {
|
||||
...item,
|
||||
content: 'null'
|
||||
};
|
||||
}
|
||||
|
||||
const formatContent = (() => {
|
||||
if (Array.isArray(content) && content.length === 1 && content[0].type === 'text') {
|
||||
return content[0].text;
|
||||
}
|
||||
return content;
|
||||
})();
|
||||
|
||||
return {
|
||||
...item,
|
||||
content: formatContent
|
||||
};
|
||||
} else if (item.role === ChatCompletionRequestMessageRoleEnum.Assistant) {
|
||||
if (item.tool_calls || item.function_call) {
|
||||
return formatAssistantItem(item);
|
||||
}
|
||||
|
||||
const parseContent = parseAssistantContent(item.content);
|
||||
|
||||
// 如果内容为空,且前后不再是 assistant,需要补充成 null,避免丢失 user-assistant 的交互
|
||||
const formatContent = (() => {
|
||||
const lastItem = mergeMessages[i - 1];
|
||||
const nextItem = mergeMessages[i + 1];
|
||||
if (
|
||||
parseContent === '' &&
|
||||
(lastItem?.role === ChatCompletionRequestMessageRoleEnum.Assistant ||
|
||||
nextItem?.role === ChatCompletionRequestMessageRoleEnum.Assistant)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
return parseContent || 'null';
|
||||
})();
|
||||
if (!formatContent) return;
|
||||
|
||||
return {
|
||||
...formatAssistantItem(item),
|
||||
content: formatContent
|
||||
};
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
})
|
||||
)
|
||||
).filter(Boolean) as ChatCompletionMessageParam[];
|
||||
|
||||
return loadMessages as SdkChatCompletionMessageParam[];
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ import { predictDataLimitLength } from '../../../../global/core/dataset/utils';
|
||||
import { mongoSessionRun } from '../../../common/mongo/sessionRun';
|
||||
import { createTrainingUsage } from '../../../support/wallet/usage/controller';
|
||||
import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants';
|
||||
import { getLLMModel, getVectorModel } from '../../ai/model';
|
||||
import { getLLMModel, getEmbeddingModel } from '../../ai/model';
|
||||
import { pushDataListToTrainingQueue } from '../training/controller';
|
||||
import { MongoImage } from '../../../common/file/image/schema';
|
||||
import { hashStr } from '@fastgpt/global/common/string/tools';
|
||||
@@ -93,7 +93,7 @@ export const createCollectionAndInsertData = async ({
|
||||
tmbId,
|
||||
appName: usageName,
|
||||
billSource: UsageSourceEnum.training,
|
||||
vectorModel: getVectorModel(dataset.vectorModel)?.name,
|
||||
vectorModel: getEmbeddingModel(dataset.vectorModel)?.name,
|
||||
agentModel: getLLMModel(dataset.agentModel)?.name,
|
||||
session
|
||||
});
|
||||
|
||||
@@ -33,7 +33,18 @@ const DatasetDataTextSchema = new Schema({
|
||||
});
|
||||
|
||||
try {
|
||||
DatasetDataTextSchema.index({ teamId: 1, datasetId: 1, fullTextToken: 'text' });
|
||||
DatasetDataTextSchema.index(
|
||||
{ teamId: 1, datasetId: 1, fullTextToken: 'text' },
|
||||
{
|
||||
name: 'teamId_1_datasetId_1_fullTextToken_text',
|
||||
default_language: 'none',
|
||||
collation: {
|
||||
locale: 'simple', // 使用简单匹配规则
|
||||
strength: 2, // 忽略大小写
|
||||
caseLevel: false // 进一步确保大小写不敏感
|
||||
}
|
||||
}
|
||||
);
|
||||
DatasetDataTextSchema.index({ dataId: 1 }, { unique: true });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
@@ -5,10 +5,9 @@ import {
|
||||
} from '@fastgpt/global/core/dataset/constants';
|
||||
import { recallFromVectorStore } from '../../../common/vectorStore/controller';
|
||||
import { getVectorsByText } from '../../ai/embedding';
|
||||
import { getVectorModel } from '../../ai/model';
|
||||
import { getEmbeddingModel, getDefaultRerankModel } from '../../ai/model';
|
||||
import { MongoDatasetData } from '../data/schema';
|
||||
import {
|
||||
DatasetDataSchemaType,
|
||||
DatasetDataTextSchemaType,
|
||||
SearchDataResponseItemType
|
||||
} from '@fastgpt/global/core/dataset/type';
|
||||
@@ -67,7 +66,7 @@ export async function searchDatasetData(props: SearchDatasetDataProps) {
|
||||
|
||||
/* init params */
|
||||
searchMode = DatasetSearchModeMap[searchMode] ? searchMode : DatasetSearchModeEnum.embedding;
|
||||
usingReRank = usingReRank && global.reRankModels.length > 0;
|
||||
usingReRank = usingReRank && !!getDefaultRerankModel();
|
||||
|
||||
// Compatible with topk limit
|
||||
let set = new Set<string>();
|
||||
@@ -253,7 +252,7 @@ export async function searchDatasetData(props: SearchDatasetDataProps) {
|
||||
filterCollectionIdList?: string[];
|
||||
}) => {
|
||||
const { vectors, tokens } = await getVectorsByText({
|
||||
model: getVectorModel(model),
|
||||
model: getEmbeddingModel(model),
|
||||
input: query,
|
||||
type: 'query'
|
||||
});
|
||||
@@ -348,119 +347,6 @@ export async function searchDatasetData(props: SearchDatasetDataProps) {
|
||||
};
|
||||
}
|
||||
|
||||
const searchResults = (
|
||||
await Promise.all(
|
||||
datasetIds.map(async (id) => {
|
||||
return MongoDatasetData.aggregate(
|
||||
[
|
||||
{
|
||||
$match: {
|
||||
teamId: new Types.ObjectId(teamId),
|
||||
datasetId: new Types.ObjectId(id),
|
||||
$text: { $search: jiebaSplit({ text: query }) },
|
||||
...(filterCollectionIdList
|
||||
? {
|
||||
collectionId: {
|
||||
$in: filterCollectionIdList.map((id) => new Types.ObjectId(id))
|
||||
}
|
||||
}
|
||||
: {}),
|
||||
...(forbidCollectionIdList && forbidCollectionIdList.length > 0
|
||||
? {
|
||||
collectionId: {
|
||||
$nin: forbidCollectionIdList.map((id) => new Types.ObjectId(id))
|
||||
}
|
||||
}
|
||||
: {})
|
||||
}
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
score: { $meta: 'textScore' }
|
||||
}
|
||||
},
|
||||
{
|
||||
$limit: limit
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 1,
|
||||
datasetId: 1,
|
||||
collectionId: 1,
|
||||
updateTime: 1,
|
||||
q: 1,
|
||||
a: 1,
|
||||
chunkIndex: 1,
|
||||
score: { $meta: 'textScore' }
|
||||
}
|
||||
}
|
||||
],
|
||||
{
|
||||
...readFromSecondary
|
||||
}
|
||||
);
|
||||
})
|
||||
)
|
||||
).flat() as (DatasetDataSchemaType & { score: number })[];
|
||||
|
||||
// Get data and collections
|
||||
const collections = await MongoDatasetCollection.find(
|
||||
{
|
||||
_id: { $in: searchResults.map((item) => item.collectionId) }
|
||||
},
|
||||
'_id name fileId rawLink externalFileId externalFileUrl',
|
||||
{ ...readFromSecondary }
|
||||
).lean();
|
||||
|
||||
return {
|
||||
fullTextRecallResults: searchResults
|
||||
.map((data, index) => {
|
||||
const collection = collections.find(
|
||||
(col) => String(col._id) === String(data.collectionId)
|
||||
);
|
||||
if (!collection) {
|
||||
console.log('Collection is not found', data);
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
id: String(data._id),
|
||||
datasetId: String(data.datasetId),
|
||||
collectionId: String(data.collectionId),
|
||||
updateTime: data.updateTime,
|
||||
q: data.q,
|
||||
a: data.a,
|
||||
chunkIndex: data.chunkIndex,
|
||||
indexes: data.indexes,
|
||||
...getCollectionSourceData(collection),
|
||||
score: [{ type: SearchScoreTypeEnum.fullText, value: data.score ?? 0, index }]
|
||||
};
|
||||
})
|
||||
.filter(Boolean) as SearchDataResponseItemType[],
|
||||
tokenLen: 0
|
||||
};
|
||||
};
|
||||
const fullTextRecall2 = async ({
|
||||
query,
|
||||
limit,
|
||||
filterCollectionIdList,
|
||||
forbidCollectionIdList
|
||||
}: {
|
||||
query: string;
|
||||
limit: number;
|
||||
filterCollectionIdList?: string[];
|
||||
forbidCollectionIdList: string[];
|
||||
}): Promise<{
|
||||
fullTextRecallResults: SearchDataResponseItemType[];
|
||||
tokenLen: number;
|
||||
}> => {
|
||||
if (limit === 0) {
|
||||
return {
|
||||
fullTextRecallResults: [],
|
||||
tokenLen: 0
|
||||
};
|
||||
}
|
||||
|
||||
const searchResults = (
|
||||
await Promise.all(
|
||||
datasetIds.map(async (id) => {
|
||||
@@ -637,7 +523,7 @@ export async function searchDatasetData(props: SearchDatasetDataProps) {
|
||||
filterCollectionIdList
|
||||
}),
|
||||
// FullText tmp
|
||||
fullTextRecall2({
|
||||
fullTextRecall({
|
||||
query,
|
||||
limit: fullTextLimit,
|
||||
filterCollectionIdList,
|
||||
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
import { TrainingModeEnum } from '@fastgpt/global/core/dataset/constants';
|
||||
import { simpleText } from '@fastgpt/global/common/string/tools';
|
||||
import { ClientSession } from '../../../common/mongo';
|
||||
import { getLLMModel, getVectorModel } from '../../ai/model';
|
||||
import { getLLMModel, getEmbeddingModel } from '../../ai/model';
|
||||
import { addLog } from '../../../common/system/log';
|
||||
import { getCollectionWithDataset } from '../controller';
|
||||
import { mongoSessionRun } from '../../../common/mongo/sessionRun';
|
||||
@@ -70,7 +70,7 @@ export async function pushDataListToTrainingQueue({
|
||||
if (!agentModelData) {
|
||||
return Promise.reject(`File model ${agentModel} is inValid`);
|
||||
}
|
||||
const vectorModelData = getVectorModel(vectorModel);
|
||||
const vectorModelData = getEmbeddingModel(vectorModel);
|
||||
if (!vectorModelData) {
|
||||
return Promise.reject(`Vector model ${vectorModel} is inValid`);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/
|
||||
import { replaceVariable } from '@fastgpt/global/common/string/tools';
|
||||
import { Prompt_CQJson } from '@fastgpt/global/core/ai/prompt/agent';
|
||||
import { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { ModelTypeEnum, getLLMModel } from '../../../ai/model';
|
||||
import { getLLMModel } from '../../../ai/model';
|
||||
import { getHistories } from '../utils';
|
||||
import { formatModelChars2Points } from '../../../../support/wallet/usage/utils';
|
||||
import { DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
@@ -22,6 +22,7 @@ import { getHandleId } from '@fastgpt/global/core/workflow/utils';
|
||||
import { loadRequestMessages } from '../../../chat/utils';
|
||||
import { llmCompletionsBodyFormat } from '../../../ai/utils';
|
||||
import { addLog } from '../../../../common/system/log';
|
||||
import { ModelTypeEnum } from '../../../../../global/core/ai/model';
|
||||
|
||||
type Props = ModuleDispatchProps<{
|
||||
[NodeInputKeyEnum.aiModel]: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { chats2GPTMessages } from '@fastgpt/global/core/chat/adapt';
|
||||
import { filterGPTMessageByMaxTokens, loadRequestMessages } from '../../../chat/utils';
|
||||
import { filterGPTMessageByMaxContext, loadRequestMessages } from '../../../chat/utils';
|
||||
import type { ChatItemType } from '@fastgpt/global/core/chat/type.d';
|
||||
import {
|
||||
countMessagesTokens,
|
||||
@@ -16,7 +16,7 @@ import { Prompt_ExtractJson } from '@fastgpt/global/core/ai/prompt/agent';
|
||||
import { replaceVariable, sliceJsonStr } from '@fastgpt/global/common/string/tools';
|
||||
import { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { getHistories } from '../utils';
|
||||
import { ModelTypeEnum, getLLMModel } from '../../../ai/model';
|
||||
import { getLLMModel } from '../../../ai/model';
|
||||
import { formatModelChars2Points } from '../../../../support/wallet/usage/utils';
|
||||
import json5 from 'json5';
|
||||
import {
|
||||
@@ -28,6 +28,7 @@ import { ChatCompletionRequestMessageRoleEnum } from '@fastgpt/global/core/ai/co
|
||||
import { DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';
|
||||
import { llmCompletionsBodyFormat } from '../../../ai/utils';
|
||||
import { ModelTypeEnum } from '../../../../../global/core/ai/model';
|
||||
|
||||
type Props = ModuleDispatchProps<{
|
||||
[NodeInputKeyEnum.history]?: ChatItemType[];
|
||||
@@ -174,9 +175,9 @@ ${description ? `- ${description}` : ''}
|
||||
}
|
||||
];
|
||||
const adaptMessages = chats2GPTMessages({ messages, reserveId: false });
|
||||
const filterMessages = await filterGPTMessageByMaxTokens({
|
||||
const filterMessages = await filterGPTMessageByMaxContext({
|
||||
messages: adaptMessages,
|
||||
maxTokens: extractModel.maxContext
|
||||
maxContext: extractModel.maxContext
|
||||
});
|
||||
const requestMessages = await loadRequestMessages({
|
||||
messages: filterMessages,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createChatCompletion } from '../../../../ai/config';
|
||||
import { filterGPTMessageByMaxTokens, loadRequestMessages } from '../../../../chat/utils';
|
||||
import { filterGPTMessageByMaxContext, loadRequestMessages } from '../../../../chat/utils';
|
||||
import {
|
||||
ChatCompletion,
|
||||
StreamChatType,
|
||||
@@ -172,10 +172,14 @@ export const runToolWithFunctionCall = async (
|
||||
};
|
||||
});
|
||||
|
||||
const max_tokens = computedMaxToken({
|
||||
model: toolModel,
|
||||
maxToken
|
||||
});
|
||||
const filterMessages = (
|
||||
await filterGPTMessageByMaxTokens({
|
||||
await filterGPTMessageByMaxContext({
|
||||
messages,
|
||||
maxTokens: toolModel.maxContext - 300 // filter token. not response maxToken
|
||||
maxContext: toolModel.maxContext - (max_tokens || 0) // filter token. not response maxToken
|
||||
})
|
||||
).map((item) => {
|
||||
if (item.role === ChatCompletionRequestMessageRoleEnum.Assistant && item.function_call) {
|
||||
@@ -190,16 +194,11 @@ export const runToolWithFunctionCall = async (
|
||||
}
|
||||
return item;
|
||||
});
|
||||
const [requestMessages, max_tokens] = await Promise.all([
|
||||
const [requestMessages] = await Promise.all([
|
||||
loadRequestMessages({
|
||||
messages: filterMessages,
|
||||
useVision: toolModel.vision && aiChatVision,
|
||||
origin: requestOrigin
|
||||
}),
|
||||
computedMaxToken({
|
||||
model: toolModel,
|
||||
maxToken,
|
||||
filterMessages
|
||||
})
|
||||
]);
|
||||
const requestBody = llmCompletionsBodyFormat(
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
DispatchNodeResultType,
|
||||
RuntimeNodeItemType
|
||||
} from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { ModelTypeEnum, getLLMModel } from '../../../../ai/model';
|
||||
import { getLLMModel } from '../../../../ai/model';
|
||||
import { filterToolNodeIdByEdges, getHistories } from '../../utils';
|
||||
import { runToolWithToolChoice } from './toolChoice';
|
||||
import { DispatchToolModuleProps, ToolNodeItemType } from './type.d';
|
||||
@@ -30,6 +30,7 @@ import { parseUrlToFileType } from '@fastgpt/global/common/file/tools';
|
||||
import { Prompt_DocumentQuote } from '@fastgpt/global/core/ai/prompt/AIChat';
|
||||
import { FlowNodeTypeEnum } from '@fastgpt/global/core/workflow/node/constant';
|
||||
import { postTextCensor } from '../../../../../common/api/requestPlusApi';
|
||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||
|
||||
type Response = DispatchNodeResultType<{
|
||||
[NodeOutputKeyEnum.answerText]: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createChatCompletion } from '../../../../ai/config';
|
||||
import { filterGPTMessageByMaxTokens, loadRequestMessages } from '../../../../chat/utils';
|
||||
import { filterGPTMessageByMaxContext, loadRequestMessages } from '../../../../chat/utils';
|
||||
import {
|
||||
ChatCompletion,
|
||||
StreamChatType,
|
||||
@@ -196,21 +196,20 @@ export const runToolWithPromptCall = async (
|
||||
return Promise.reject('Prompt call invalid input');
|
||||
}
|
||||
|
||||
const filterMessages = await filterGPTMessageByMaxTokens({
|
||||
const max_tokens = computedMaxToken({
|
||||
model: toolModel,
|
||||
maxToken
|
||||
});
|
||||
const filterMessages = await filterGPTMessageByMaxContext({
|
||||
messages,
|
||||
maxTokens: toolModel.maxContext - 500 // filter token. not response maxToken
|
||||
maxContext: toolModel.maxContext - (max_tokens || 0) // filter token. not response maxToken
|
||||
});
|
||||
|
||||
const [requestMessages, max_tokens] = await Promise.all([
|
||||
const [requestMessages] = await Promise.all([
|
||||
loadRequestMessages({
|
||||
messages: filterMessages,
|
||||
useVision: toolModel.vision && aiChatVision,
|
||||
origin: requestOrigin
|
||||
}),
|
||||
computedMaxToken({
|
||||
model: toolModel,
|
||||
maxToken,
|
||||
filterMessages
|
||||
})
|
||||
]);
|
||||
const requestBody = llmCompletionsBodyFormat(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createChatCompletion } from '../../../../ai/config';
|
||||
import { filterGPTMessageByMaxTokens, loadRequestMessages } from '../../../../chat/utils';
|
||||
import { filterGPTMessageByMaxContext, loadRequestMessages } from '../../../../chat/utils';
|
||||
import {
|
||||
ChatCompletion,
|
||||
ChatCompletionMessageToolCall,
|
||||
@@ -228,11 +228,16 @@ export const runToolWithToolChoice = async (
|
||||
};
|
||||
});
|
||||
|
||||
const max_tokens = computedMaxToken({
|
||||
model: toolModel,
|
||||
maxToken
|
||||
});
|
||||
|
||||
// Filter histories by maxToken
|
||||
const filterMessages = (
|
||||
await filterGPTMessageByMaxTokens({
|
||||
await filterGPTMessageByMaxContext({
|
||||
messages,
|
||||
maxTokens: toolModel.maxContext - 300 // filter token. not response maxToken
|
||||
maxContext: toolModel.maxContext - (max_tokens || 0) // filter token. not response maxToken
|
||||
})
|
||||
).map((item) => {
|
||||
if (item.role === 'assistant' && item.tool_calls) {
|
||||
@@ -248,16 +253,11 @@ export const runToolWithToolChoice = async (
|
||||
return item;
|
||||
});
|
||||
|
||||
const [requestMessages, max_tokens] = await Promise.all([
|
||||
const [requestMessages] = await Promise.all([
|
||||
loadRequestMessages({
|
||||
messages: filterMessages,
|
||||
useVision: toolModel.vision && aiChatVision,
|
||||
origin: requestOrigin
|
||||
}),
|
||||
computedMaxToken({
|
||||
model: toolModel,
|
||||
maxToken,
|
||||
filterMessages
|
||||
})
|
||||
]);
|
||||
const requestBody = llmCompletionsBodyFormat(
|
||||
@@ -272,7 +272,7 @@ export const runToolWithToolChoice = async (
|
||||
},
|
||||
toolModel
|
||||
);
|
||||
// console.log(JSON.stringify(requestBody, null, 2), '==requestBody');
|
||||
// console.log(JSON.stringify(requestMessages, null, 2), '==requestBody');
|
||||
/* Run llm */
|
||||
const {
|
||||
response: aiResponse,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { NextApiResponse } from 'next';
|
||||
import { filterGPTMessageByMaxTokens, loadRequestMessages } from '../../../chat/utils';
|
||||
import { filterGPTMessageByMaxContext, loadRequestMessages } from '../../../chat/utils';
|
||||
import type { ChatItemType, UserChatItemValueItemType } from '@fastgpt/global/core/chat/type.d';
|
||||
import { ChatRoleEnum } from '@fastgpt/global/core/chat/constants';
|
||||
import { SseResponseEventEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
@@ -33,7 +33,7 @@ import type { AIChatNodeProps } from '@fastgpt/global/core/workflow/runtime/type
|
||||
import { replaceVariable } from '@fastgpt/global/common/string/tools';
|
||||
import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { responseWriteController } from '../../../../common/response';
|
||||
import { getLLMModel, ModelTypeEnum } from '../../../ai/model';
|
||||
import { getLLMModel } from '../../../ai/model';
|
||||
import type { SearchDataResponseItemType } from '@fastgpt/global/core/dataset/type';
|
||||
import { NodeInputKeyEnum, NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
@@ -47,6 +47,7 @@ import { AiChatQuoteRoleType } from '@fastgpt/global/core/workflow/template/syst
|
||||
import { getFileContentFromLinks, getHistoryFileLinks } from '../tools/readFiles';
|
||||
import { parseUrlToFileType } from '@fastgpt/global/common/file/tools';
|
||||
import { i18nT } from '../../../../../web/i18n/utils';
|
||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||
|
||||
export type ChatProps = ModuleDispatchProps<
|
||||
AIChatNodeProps & {
|
||||
@@ -57,6 +58,7 @@ export type ChatProps = ModuleDispatchProps<
|
||||
>;
|
||||
export type ChatResponse = DispatchNodeResultType<{
|
||||
[NodeOutputKeyEnum.answerText]: string;
|
||||
[NodeOutputKeyEnum.reasoningText]?: string;
|
||||
[NodeOutputKeyEnum.history]: ChatItemType[];
|
||||
}>;
|
||||
|
||||
@@ -86,22 +88,24 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
|
||||
quoteTemplate,
|
||||
quotePrompt,
|
||||
aiChatVision,
|
||||
aiChatReasoning = true,
|
||||
fileUrlList: fileLinks, // node quote file links
|
||||
stringQuoteText //abandon
|
||||
}
|
||||
} = props;
|
||||
const { files: inputFiles } = chatValue2RuntimePrompt(query); // Chat box input files
|
||||
|
||||
stream = stream && isResponseAnswerText;
|
||||
|
||||
const chatHistories = getHistories(history, histories);
|
||||
quoteQA = checkQuoteQAValue(quoteQA);
|
||||
|
||||
const modelConstantsData = getLLMModel(model);
|
||||
if (!modelConstantsData) {
|
||||
return Promise.reject('The chat model is undefined, you need to select a chat model.');
|
||||
}
|
||||
|
||||
stream = stream && isResponseAnswerText;
|
||||
aiChatReasoning = !!aiChatReasoning && !!modelConstantsData.reasoning;
|
||||
|
||||
const chatHistories = getHistories(history, histories);
|
||||
quoteQA = checkQuoteQAValue(quoteQA);
|
||||
|
||||
const [{ datasetQuoteText }, { documentQuoteText, userFiles }] = await Promise.all([
|
||||
filterDatasetQuote({
|
||||
quoteQA,
|
||||
@@ -123,9 +127,15 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
|
||||
return Promise.reject(i18nT('chat:AI_input_is_empty'));
|
||||
}
|
||||
|
||||
const max_tokens = computedMaxToken({
|
||||
model: modelConstantsData,
|
||||
maxToken
|
||||
});
|
||||
|
||||
const [{ filterMessages }] = await Promise.all([
|
||||
getChatMessages({
|
||||
model: modelConstantsData,
|
||||
maxTokens: max_tokens,
|
||||
histories: chatHistories,
|
||||
useDatasetQuote: quoteQA !== undefined,
|
||||
datasetQuoteText,
|
||||
@@ -136,8 +146,8 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
|
||||
userFiles,
|
||||
documentQuoteText
|
||||
}),
|
||||
// Censor = true and system key, will check content
|
||||
(() => {
|
||||
// censor model and system key
|
||||
if (modelConstantsData.censor && !externalProvider.openaiAccount?.key) {
|
||||
return postTextCensor({
|
||||
text: `${systemPrompt}
|
||||
@@ -148,18 +158,11 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
|
||||
})()
|
||||
]);
|
||||
|
||||
const [requestMessages, max_tokens] = await Promise.all([
|
||||
loadRequestMessages({
|
||||
messages: filterMessages,
|
||||
useVision: modelConstantsData.vision && aiChatVision,
|
||||
origin: requestOrigin
|
||||
}),
|
||||
computedMaxToken({
|
||||
model: modelConstantsData,
|
||||
maxToken,
|
||||
filterMessages
|
||||
})
|
||||
]);
|
||||
const requestMessages = await loadRequestMessages({
|
||||
messages: filterMessages,
|
||||
useVision: modelConstantsData.vision && aiChatVision,
|
||||
origin: requestOrigin
|
||||
});
|
||||
|
||||
const requestBody = llmCompletionsBodyFormat(
|
||||
{
|
||||
@@ -182,34 +185,41 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
|
||||
}
|
||||
});
|
||||
|
||||
const { answerText } = await (async () => {
|
||||
const { answerText, reasoningText } = await (async () => {
|
||||
if (res && isStreamResponse) {
|
||||
// sse response
|
||||
const { answer } = await streamResponse({
|
||||
const { answer, reasoning } = await streamResponse({
|
||||
res,
|
||||
stream: response,
|
||||
aiChatReasoning,
|
||||
workflowStreamResponse
|
||||
});
|
||||
|
||||
return {
|
||||
answerText: answer
|
||||
answerText: answer,
|
||||
reasoningText: reasoning
|
||||
};
|
||||
} else {
|
||||
const unStreamResponse = response as ChatCompletion;
|
||||
const answer = unStreamResponse.choices?.[0]?.message?.content || '';
|
||||
|
||||
const reasoning = aiChatReasoning
|
||||
? // @ts-ignore
|
||||
unStreamResponse.choices?.[0]?.message?.reasoning_content || ''
|
||||
: '';
|
||||
if (stream) {
|
||||
// Some models do not support streaming
|
||||
workflowStreamResponse?.({
|
||||
event: SseResponseEventEnum.fastAnswer,
|
||||
data: textAdaptGptResponse({
|
||||
text: answer
|
||||
text: answer,
|
||||
reasoning_content: reasoning
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
answerText: answer
|
||||
answerText: answer,
|
||||
reasoningText: reasoning
|
||||
};
|
||||
}
|
||||
})();
|
||||
@@ -240,6 +250,7 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
|
||||
|
||||
return {
|
||||
answerText,
|
||||
reasoningText,
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||
totalPoints: externalProvider.openaiAccount?.key ? 0 : totalPoints,
|
||||
model: modelName,
|
||||
@@ -280,11 +291,12 @@ async function filterDatasetQuote({
|
||||
}) {
|
||||
function getValue(item: SearchDataResponseItemType, index: number) {
|
||||
return replaceVariable(quoteTemplate || Prompt_QuoteTemplateList[0].value, {
|
||||
id: item.id,
|
||||
q: item.q,
|
||||
a: item.a,
|
||||
updateTime: formatTime2YMDHM(item.updateTime),
|
||||
source: item.sourceName,
|
||||
sourceId: String(item.sourceId || 'UnKnow'),
|
||||
sourceId: String(item.sourceId || ''),
|
||||
index: index + 1
|
||||
});
|
||||
}
|
||||
@@ -365,6 +377,7 @@ async function getMultiInput({
|
||||
|
||||
async function getChatMessages({
|
||||
model,
|
||||
maxTokens = 0,
|
||||
aiChatQuoteRole,
|
||||
datasetQuotePrompt = '',
|
||||
datasetQuoteText,
|
||||
@@ -376,6 +389,7 @@ async function getChatMessages({
|
||||
documentQuoteText
|
||||
}: {
|
||||
model: LLMModelItemType;
|
||||
maxTokens?: number;
|
||||
// dataset quote
|
||||
aiChatQuoteRole: AiChatQuoteRoleType; // user: replace user prompt; system: replace system prompt
|
||||
datasetQuotePrompt?: string;
|
||||
@@ -442,9 +456,9 @@ async function getChatMessages({
|
||||
|
||||
const adaptMessages = chats2GPTMessages({ messages, reserveId: false });
|
||||
|
||||
const filterMessages = await filterGPTMessageByMaxTokens({
|
||||
const filterMessages = await filterGPTMessageByMaxContext({
|
||||
messages: adaptMessages,
|
||||
maxTokens: model.maxContext - 300 // filter token. not response maxToken
|
||||
maxContext: model.maxContext - maxTokens // filter token. not response maxToken
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -455,33 +469,43 @@ async function getChatMessages({
|
||||
async function streamResponse({
|
||||
res,
|
||||
stream,
|
||||
workflowStreamResponse
|
||||
workflowStreamResponse,
|
||||
aiChatReasoning
|
||||
}: {
|
||||
res: NextApiResponse;
|
||||
stream: StreamChatType;
|
||||
workflowStreamResponse?: WorkflowResponseType;
|
||||
aiChatReasoning?: boolean;
|
||||
}) {
|
||||
const write = responseWriteController({
|
||||
res,
|
||||
readStream: stream
|
||||
});
|
||||
let answer = '';
|
||||
let reasoning = '';
|
||||
for await (const part of stream) {
|
||||
if (res.closed) {
|
||||
stream.controller?.abort();
|
||||
break;
|
||||
}
|
||||
|
||||
const content = part.choices?.[0]?.delta?.content || '';
|
||||
answer += content;
|
||||
|
||||
const reasoningContent = aiChatReasoning
|
||||
? part.choices?.[0]?.delta?.reasoning_content || ''
|
||||
: '';
|
||||
reasoning += reasoningContent;
|
||||
|
||||
workflowStreamResponse?.({
|
||||
write,
|
||||
event: SseResponseEventEnum.answer,
|
||||
data: textAdaptGptResponse({
|
||||
text: content
|
||||
text: content,
|
||||
reasoning_content: reasoningContent
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
return { answer };
|
||||
return { answer, reasoning };
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { formatModelChars2Points } from '../../../../support/wallet/usage/utils'
|
||||
import type { SelectedDatasetType } from '@fastgpt/global/core/workflow/api.d';
|
||||
import type { SearchDataResponseItemType } from '@fastgpt/global/core/dataset/type';
|
||||
import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { ModelTypeEnum, getLLMModel, getVectorModel } from '../../../ai/model';
|
||||
import { getLLMModel, getEmbeddingModel } from '../../../ai/model';
|
||||
import { searchDatasetData } from '../../../dataset/search/controller';
|
||||
import { NodeInputKeyEnum, NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
@@ -18,6 +18,7 @@ import { checkTeamReRankPermission } from '../../../../support/permission/teamLi
|
||||
import { MongoDataset } from '../../../dataset/schema';
|
||||
import { i18nT } from '../../../../../web/i18n/utils';
|
||||
import { filterDatasetsByTmbId } from '../../../dataset/utils';
|
||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||
|
||||
type DatasetSearchProps = ModuleDispatchProps<{
|
||||
[NodeInputKeyEnum.datasetSelectList]: SelectedDatasetType;
|
||||
@@ -110,7 +111,7 @@ export async function dispatchDatasetSearch(
|
||||
// console.log(concatQueries, rewriteQuery, aiExtensionResult);
|
||||
|
||||
// get vector
|
||||
const vectorModel = getVectorModel(
|
||||
const vectorModel = getEmbeddingModel(
|
||||
(await MongoDataset.findById(datasets[0].datasetId, 'vectorModel').lean())?.vectorModel
|
||||
);
|
||||
|
||||
@@ -138,7 +139,7 @@ export async function dispatchDatasetSearch(
|
||||
const { totalPoints, modelName } = formatModelChars2Points({
|
||||
model: vectorModel.model,
|
||||
inputTokens: tokens,
|
||||
modelType: ModelTypeEnum.vector
|
||||
modelType: ModelTypeEnum.embedding
|
||||
});
|
||||
const responseData: DispatchNodeResponseType & { totalPoints: number } = {
|
||||
totalPoints,
|
||||
|
||||
@@ -204,6 +204,7 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
||||
{ inputs = [] }: RuntimeNodeItemType,
|
||||
{
|
||||
answerText = '',
|
||||
reasoningText,
|
||||
responseData,
|
||||
nodeDispatchUsages,
|
||||
toolResponses,
|
||||
@@ -213,6 +214,7 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
||||
}: Omit<
|
||||
DispatchNodeResultType<{
|
||||
[NodeOutputKeyEnum.answerText]?: string;
|
||||
[NodeOutputKeyEnum.reasoningText]?: string;
|
||||
[DispatchNodeResponseKeyEnum.nodeResponse]?: ChatHistoryItemResType;
|
||||
}>,
|
||||
'nodeResponse'
|
||||
@@ -239,18 +241,28 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
||||
// Histories store
|
||||
if (assistantResponses) {
|
||||
chatAssistantResponse = chatAssistantResponse.concat(assistantResponses);
|
||||
} else if (answerText) {
|
||||
// save assistant text response
|
||||
const isResponseAnswerText =
|
||||
inputs.find((item) => item.key === NodeInputKeyEnum.aiChatIsResponseText)?.value ?? true;
|
||||
if (isResponseAnswerText) {
|
||||
} else {
|
||||
if (reasoningText) {
|
||||
chatAssistantResponse.push({
|
||||
type: ChatItemValueTypeEnum.text,
|
||||
text: {
|
||||
content: answerText
|
||||
type: ChatItemValueTypeEnum.reasoning,
|
||||
reasoning: {
|
||||
content: reasoningText
|
||||
}
|
||||
});
|
||||
}
|
||||
if (answerText) {
|
||||
// save assistant text response
|
||||
const isResponseAnswerText =
|
||||
inputs.find((item) => item.key === NodeInputKeyEnum.aiChatIsResponseText)?.value ?? true;
|
||||
if (isResponseAnswerText) {
|
||||
chatAssistantResponse.push({
|
||||
type: ChatItemValueTypeEnum.text,
|
||||
text: {
|
||||
content: answerText
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rewriteHistories) {
|
||||
|
||||
@@ -244,7 +244,6 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
|
||||
if (!httpJsonBody) return {};
|
||||
if (httpContentType === ContentTypes.json) {
|
||||
httpJsonBody = replaceJsonBodyString(httpJsonBody);
|
||||
console.log(httpJsonBody);
|
||||
return json5.parse(httpJsonBody);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,13 @@ import type { ChatItemType } from '@fastgpt/global/core/chat/type.d';
|
||||
import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { NodeInputKeyEnum, NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
import { ModelTypeEnum, getLLMModel } from '../../../../core/ai/model';
|
||||
import { getLLMModel } from '../../../../core/ai/model';
|
||||
import { formatModelChars2Points } from '../../../../support/wallet/usage/utils';
|
||||
import { queryExtension } from '../../../../core/ai/functions/queryExtension';
|
||||
import { getHistories } from '../utils';
|
||||
import { hashStr } from '@fastgpt/global/common/string/tools';
|
||||
import { DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||
|
||||
type Props = ModuleDispatchProps<{
|
||||
[NodeInputKeyEnum.aiModel]: string;
|
||||
|
||||
@@ -279,6 +279,7 @@ export async function authDatasetData({
|
||||
|
||||
return {
|
||||
...result,
|
||||
datasetData: data
|
||||
datasetData: data,
|
||||
collection: result.collection
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
|
||||
import { AuthModeType, AuthResponseType } from '../type';
|
||||
import { NullPermission } from '@fastgpt/global/support/permission/constant';
|
||||
import { TeamPermission } from '@fastgpt/global/support/permission/user/controller';
|
||||
import { authCert } from '../auth/common';
|
||||
import { MongoUser } from '../../user/schema';
|
||||
import { ERROR_ENUM } from '@fastgpt/global/common/error/errorCode';
|
||||
import { ApiRequestProps } from '../../../type/next';
|
||||
|
||||
/* auth user role */
|
||||
export async function authUserPer(props: AuthModeType): Promise<
|
||||
@@ -34,3 +38,19 @@ export async function authUserPer(props: AuthModeType): Promise<
|
||||
tmb
|
||||
};
|
||||
}
|
||||
|
||||
export const authSystemAdmin = async ({ req }: { req: ApiRequestProps }) => {
|
||||
try {
|
||||
const result = await authCert({ req, authToken: true });
|
||||
const user = await MongoUser.findOne({
|
||||
_id: result.userId
|
||||
});
|
||||
|
||||
if (user && user.username !== 'root') {
|
||||
return Promise.reject(ERROR_ENUM.unAuthorization);
|
||||
}
|
||||
return result;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -61,7 +61,8 @@ const UsageSchema = new Schema({
|
||||
});
|
||||
|
||||
try {
|
||||
UsageSchema.index({ teamId: 1, tmbId: 1, source: 1, time: -1 });
|
||||
UsageSchema.index({ teamId: 1, time: 1, tmbId: 1, source: 1 });
|
||||
UsageSchema.index({ teamId: 1, time: 1, appName: 1 });
|
||||
// timer task. clear dead team
|
||||
// UsageSchema.index({ teamId: 1, time: -1 });
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { ModelTypeEnum, getModelMap } from '../../../core/ai/model';
|
||||
import { findAIModel } from '../../../core/ai/model';
|
||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||
|
||||
export const formatModelChars2Points = ({
|
||||
model,
|
||||
@@ -14,7 +14,7 @@ export const formatModelChars2Points = ({
|
||||
modelType: `${ModelTypeEnum}`;
|
||||
multiple?: number;
|
||||
}) => {
|
||||
const modelData = getModelMap?.[modelType]?.(model) as LLMModelItemType;
|
||||
const modelData = findAIModel(model);
|
||||
if (!modelData) {
|
||||
return {
|
||||
totalPoints: 0,
|
||||
|
||||
12
packages/service/type.d.ts
vendored
@@ -1,9 +1,9 @@
|
||||
import { FastGPTFeConfigsType, SystemEnvType } from '@fastgpt/global/common/system/types';
|
||||
import {
|
||||
AudioSpeechModelType,
|
||||
TTSModelType,
|
||||
ReRankModelItemType,
|
||||
STTModelType,
|
||||
VectorModelItemType,
|
||||
EmbeddingModelItemType,
|
||||
LLMModelItemType
|
||||
} from '@fastgpt/global/core/ai/model.d';
|
||||
import { SubPlanType } from '@fastgpt/global/support/wallet/sub/type';
|
||||
@@ -12,17 +12,11 @@ import { Worker } from 'worker_threads';
|
||||
|
||||
declare global {
|
||||
var systemInitBufferId: string | undefined;
|
||||
|
||||
var systemVersion: string;
|
||||
var feConfigs: FastGPTFeConfigsType;
|
||||
var systemEnv: SystemEnvType;
|
||||
var subPlans: SubPlanType | undefined;
|
||||
|
||||
var llmModels: LLMModelItemType[];
|
||||
var llmModelPriceType: 'IO' | 'Tokens';
|
||||
var vectorModels: VectorModelItemType[];
|
||||
var audioSpeechModels: AudioSpeechModelType[];
|
||||
var whisperModel: STTModelType;
|
||||
var reRankModels: ReRankModelItemType[];
|
||||
|
||||
var workerPoll: Record<WorkerNameEnum, WorkerPool>;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useMemo, useRef } from 'react';
|
||||
import React, { useState, useMemo, useRef, useEffect } from 'react';
|
||||
import { Box, Card, Flex, useTheme, useOutsideClick, Button } from '@chakra-ui/react';
|
||||
import { addDays, format } from 'date-fns';
|
||||
import { type DateRange, DayPicker } from 'react-day-picker';
|
||||
@@ -14,12 +14,14 @@ const DateRangePicker = ({
|
||||
defaultDate = {
|
||||
from: addDays(new Date(), -30),
|
||||
to: new Date()
|
||||
}
|
||||
},
|
||||
dateRange
|
||||
}: {
|
||||
onChange?: (date: DateRange) => void;
|
||||
onSuccess?: (date: DateRange) => void;
|
||||
position?: 'bottom' | 'top';
|
||||
defaultDate?: DateRange;
|
||||
dateRange?: DateRange;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
@@ -27,6 +29,12 @@ const DateRangePicker = ({
|
||||
const [range, setRange] = useState<DateRange | undefined>(defaultDate);
|
||||
const [showSelected, setShowSelected] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (dateRange) {
|
||||
setRange(dateRange);
|
||||
}
|
||||
}, [dateRange]);
|
||||
|
||||
const formatSelected = useMemo(() => {
|
||||
if (range?.from && range.to) {
|
||||
return `${format(range.from, 'y-MM-dd')} ~ ${format(range.to, 'y-MM-dd')}`;
|
||||
@@ -49,7 +57,7 @@ const DateRangePicker = ({
|
||||
py={1}
|
||||
borderRadius={'sm'}
|
||||
cursor={'pointer'}
|
||||
bg={'myGray.100'}
|
||||
bg={'myGray.50'}
|
||||
fontSize={'sm'}
|
||||
onClick={() => setShowSelected(true)}
|
||||
>
|
||||
@@ -93,7 +101,7 @@ const DateRangePicker = ({
|
||||
date.to = date.from;
|
||||
}
|
||||
setRange(date);
|
||||
onChange && onChange(date);
|
||||
onChange?.(date);
|
||||
}}
|
||||
footer={
|
||||
<Flex justifyContent={'flex-end'}>
|
||||
@@ -108,7 +116,7 @@ const DateRangePicker = ({
|
||||
<Button
|
||||
size={'sm'}
|
||||
onClick={() => {
|
||||
onSuccess && onSuccess(range || defaultDate);
|
||||
onSuccess?.(range || defaultDate);
|
||||
setShowSelected(false);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import React from 'react';
|
||||
import { Flex, FlexProps } from '@chakra-ui/react';
|
||||
import MyIcon from './index';
|
||||
import MyTooltip from '../MyTooltip';
|
||||
|
||||
type Props = FlexProps & {
|
||||
icon: string;
|
||||
size?: string;
|
||||
onClick?: () => void;
|
||||
hoverColor?: string;
|
||||
tip?: string;
|
||||
};
|
||||
|
||||
const MyIconButton = ({
|
||||
@@ -14,26 +16,29 @@ const MyIconButton = ({
|
||||
onClick,
|
||||
hoverColor = 'primary.600',
|
||||
size = '1rem',
|
||||
tip,
|
||||
...props
|
||||
}: Props) => {
|
||||
return (
|
||||
<Flex
|
||||
p={1}
|
||||
color={'myGray.500'}
|
||||
rounded={'sm'}
|
||||
alignItems={'center'}
|
||||
bg={'transparent'}
|
||||
transition={'background 0.1s'}
|
||||
cursor={'pointer'}
|
||||
_hover={{
|
||||
bg: 'myGray.05',
|
||||
color: hoverColor
|
||||
}}
|
||||
onClick={onClick}
|
||||
{...props}
|
||||
>
|
||||
<MyIcon name={icon as any} w={size} />
|
||||
</Flex>
|
||||
<MyTooltip label={tip}>
|
||||
<Flex
|
||||
p={1}
|
||||
color={'myGray.500'}
|
||||
rounded={'sm'}
|
||||
alignItems={'center'}
|
||||
bg={'transparent'}
|
||||
transition={'background 0.1s'}
|
||||
cursor={'pointer'}
|
||||
_hover={{
|
||||
bg: 'myGray.05',
|
||||
color: hoverColor
|
||||
}}
|
||||
onClick={onClick}
|
||||
{...props}
|
||||
>
|
||||
<MyIcon name={icon as any} w={size} />
|
||||
</Flex>
|
||||
</MyTooltip>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -178,6 +178,7 @@ export const iconPaths = {
|
||||
'core/chat/sideLine': () => import('./icons/core/chat/sideLine.svg'),
|
||||
'core/chat/speaking': () => import('./icons/core/chat/speaking.svg'),
|
||||
'core/chat/stopSpeech': () => import('./icons/core/chat/stopSpeech.svg'),
|
||||
'core/chat/think': () => import('./icons/core/chat/think.svg'),
|
||||
'core/dataset/commonDataset': () => import('./icons/core/dataset/commonDataset.svg'),
|
||||
'core/dataset/commonDatasetColor': () => import('./icons/core/dataset/commonDatasetColor.svg'),
|
||||
'core/dataset/commonDatasetOutline': () =>
|
||||
@@ -270,7 +271,6 @@ export const iconPaths = {
|
||||
import('./icons/core/workflow/template/datasource.svg'),
|
||||
'core/workflow/template/duckduckgo': () =>
|
||||
import('./icons/core/workflow/template/duckduckgo.svg'),
|
||||
'core/workflow/template/sleep': () => import('./icons/core/workflow/template/sleep.svg'),
|
||||
'core/workflow/template/extractJson': () =>
|
||||
import('./icons/core/workflow/template/extractJson.svg'),
|
||||
'core/workflow/template/fetchUrl': () => import('./icons/core/workflow/template/fetchUrl.svg'),
|
||||
@@ -296,6 +296,7 @@ export const iconPaths = {
|
||||
'core/workflow/template/reply': () => import('./icons/core/workflow/template/reply.svg'),
|
||||
'core/workflow/template/runApp': () => import('./icons/core/workflow/template/runApp.svg'),
|
||||
'core/workflow/template/searxng': () => import('./icons/core/workflow/template/searxng.svg'),
|
||||
'core/workflow/template/sleep': () => import('./icons/core/workflow/template/sleep.svg'),
|
||||
'core/workflow/template/stopTool': () => import('./icons/core/workflow/template/stopTool.svg'),
|
||||
'core/workflow/template/systemConfig': () =>
|
||||
import('./icons/core/workflow/template/systemConfig.svg'),
|
||||
@@ -374,21 +375,23 @@ export const iconPaths = {
|
||||
'model/ernie': () => import('./icons/model/ernie.svg'),
|
||||
'model/fishaudio': () => import('./icons/model/fishaudio.svg'),
|
||||
'model/gemini': () => import('./icons/model/gemini.svg'),
|
||||
'model/grok': () => import('./icons/model/grok.svg'),
|
||||
'model/groq': () => import('./icons/model/groq.svg'),
|
||||
'model/huggingface': () => import('./icons/model/huggingface.svg'),
|
||||
'model/hunyuan': () => import('./icons/model/hunyuan.svg'),
|
||||
'model/intern': () => import('./icons/model/intern.svg'),
|
||||
'model/meta': () => import('./icons/model/meta.svg'),
|
||||
'model/minimax': () => import('./icons/model/minimax.svg'),
|
||||
'model/mistral': () => import('./icons/model/mistral.svg'),
|
||||
'model/moka': () => import('./icons/model/moka.svg'),
|
||||
'model/moonshot': () => import('./icons/model/moonshot.svg'),
|
||||
'model/ollama': () => import('./icons/model/ollama.svg'),
|
||||
'model/openai': () => import('./icons/model/openai.svg'),
|
||||
'model/qwen': () => import('./icons/model/qwen.svg'),
|
||||
'model/siliconflow': () => import('./icons/model/siliconflow.svg'),
|
||||
'model/sparkDesk': () => import('./icons/model/sparkDesk.svg'),
|
||||
'model/stepfun': () => import('./icons/model/stepfun.svg'),
|
||||
'model/yi': () => import('./icons/model/yi.svg'),
|
||||
'model/intern': () => import('./icons/model/intern.svg'),
|
||||
'model/moka': () => import('./icons/model/moka.svg'),
|
||||
more: () => import('./icons/more.svg'),
|
||||
moreLine: () => import('./icons/moreLine.svg'),
|
||||
out: () => import('./icons/out.svg'),
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg t="1737983662269" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6134" width="64" height="64"><path d="M512 512m-91.264 0a91.264 91.264 0 1 0 182.528 0 91.264 91.264 0 1 0-182.528 0Z" fill="" p-id="6135"></path><path d="M256.341333 693.546667l-20.138666-5.12C86.101333 650.496 0 586.112 0 511.829333s86.101333-138.666667 236.202667-176.597333l20.138666-5.077333 5.674667 19.968a1003.946667 1003.946667 0 0 0 58.154667 152.661333l4.309333 9.088-4.309333 9.088a994.432 994.432 0 0 0-58.154667 152.661333l-5.674667 19.925334zM226.858667 381.866667c-114.090667 32.042667-184.106667 81.066667-184.106667 129.962666 0 48.853333 70.016 97.877333 184.106667 129.962667a1064.533333 1064.533333 0 0 1 50.432-129.962667A1056.085333 1056.085333 0 0 1 226.858667 381.866667z m540.8 311.68l-5.674667-20.010667a996.565333 996.565333 0 0 0-58.197333-152.618667l-4.309334-9.088 4.309334-9.088a999.253333 999.253333 0 0 0 58.197333-152.661333l5.674667-19.968 20.181333 5.077333c150.058667 37.930667 236.16 102.314667 236.16 176.64s-86.101333 138.666667-236.16 176.597334l-20.181333 5.12z m-20.949334-181.717334c20.48 44.330667 37.418667 87.893333 50.432 129.962667 114.133333-32.085333 184.106667-81.109333 184.106667-129.962667 0-48.896-70.016-97.877333-184.106667-129.962666a1057.621333 1057.621333 0 0 1-50.432 129.962666z" fill="" p-id="6136"></path><path d="M226.56 381.653333l-5.674667-19.925333C178.688 212.992 191.488 106.410667 256 69.205333c63.274667-36.522667 164.864 6.613333 271.317333 115.882667l14.506667 14.890667-14.506667 14.890666a1004.885333 1004.885333 0 0 0-103.338666 126.592l-5.76 8.234667-10.026667 0.853333a1009.365333 1009.365333 0 0 0-161.493333 26.026667l-20.138667 5.077333z m80.896-282.88c-11.434667 0-21.546667 2.474667-30.08 7.381334-42.410667 24.448-49.92 109.44-20.693333 224.128a1071.872 1071.872 0 0 1 137.941333-21.376 1060.138667 1060.138667 0 0 1 87.552-108.544c-66.56-64.810667-129.578667-101.589333-174.72-101.589334z m409.130667 868.778667c-0.042667 0-0.042667 0 0 0-60.8 0-138.88-45.781333-219.904-128.981333l-14.506667-14.890667 14.506667-14.890667a1003.946667 1003.946667 0 0 0 103.296-126.634666l5.76-8.234667 9.984-0.853333a1008.213333 1008.213333 0 0 0 161.578666-25.984l20.138667-5.077334 5.717333 19.968c42.112 148.650667 29.354667 255.274667-35.157333 292.437334a101.546667 101.546667 0 0 1-51.413333 13.141333z m-174.762667-144.256c66.56 64.810667 129.578667 101.589333 174.72 101.589333h0.042667c11.392 0 21.546667-2.474667 30.037333-7.381333 42.410667-24.448 49.962667-109.482667 20.693333-224.170667a1067.52 1067.52 0 0 1-137.984 21.376 1052.757333 1052.757333 0 0 1-87.509333 108.586667z" fill="" p-id="6137"></path><path d="M797.44 381.653333l-20.138667-5.077333a1001.770667 1001.770667 0 0 0-161.578666-26.026667l-9.984-0.853333-5.76-8.234667a998.997333 998.997333 0 0 0-103.296-126.592l-14.506667-14.890666 14.506667-14.890667C603.093333 75.861333 704.64 32.725333 768 69.205333c64.512 37.205333 77.312 143.786667 35.157333 292.48l-5.717333 19.968zM629.333333 308.906667c48.725333 4.437333 95.018667 11.648 137.984 21.376 29.269333-114.688 21.717333-199.68-20.693333-224.128-42.154667-24.362667-121.386667 12.970667-204.8 94.208A1060.224 1060.224 0 0 1 629.333333 308.906667zM307.456 967.552A101.546667 101.546667 0 0 1 256 954.410667c-64.512-37.162667-77.312-143.744-35.114667-292.437334l5.632-19.968 20.138667 5.077334c49.28 12.416 103.637333 21.162667 161.493333 25.984l10.026667 0.853333 5.717333 8.234667a1006.762667 1006.762667 0 0 0 103.338667 126.634666l14.506667 14.890667-14.506667 14.890667c-80.981333 83.2-159.061333 128.981333-219.776 128.981333z m-50.773333-274.218667c-29.269333 114.688-21.717333 199.722667 20.693333 224.170667 42.112 24.021333 121.301333-13.013333 204.8-94.208a1066.581333 1066.581333 0 0 1-87.552-108.586667 1065.642667 1065.642667 0 0 1-137.941333-21.376z" fill="" p-id="6138"></path><path d="M512 720.128c-35.114667 0-71.210667-1.536-107.349333-4.522667l-10.026667-0.853333-5.76-8.234667a1296.554667 1296.554667 0 0 1-57.6-90.538666 1295.104 1295.104 0 0 1-49.749333-95.061334l-4.266667-9.088 4.266667-9.088a1292.8 1292.8 0 0 1 49.749333-95.061333c17.664-30.549333 37.077333-61.013333 57.6-90.538667l5.76-8.234666 10.026667-0.853334a1270.826667 1270.826667 0 0 1 214.741333 0l9.984 0.853334 5.717333 8.234666a1280.256 1280.256 0 0 1 107.392 185.6l4.309334 9.088-4.309334 9.088a1262.933333 1262.933333 0 0 1-107.392 185.6l-5.717333 8.234667-9.984 0.853333c-36.138667 2.986667-72.277333 4.522667-107.392 4.522667z m-93.738667-46.250667c63.146667 4.736 124.330667 4.736 187.52 0a1237.589333 1237.589333 0 0 0 93.696-162.048 1219.626667 1219.626667 0 0 0-93.738666-162.048 1238.656 1238.656 0 0 0-187.477334 0 1215.018667 1215.018667 0 0 0-93.738666 162.048 1242.197333 1242.197333 0 0 0 93.738666 162.048z" p-id="6139"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.7 KiB |
@@ -1,4 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" >
|
||||
<path d="M13.6688 3.97738C13.9942 3.65195 14.5219 3.65195 14.8473 3.97738L18.1446 7.27471C18.1531 7.28305 18.1613 7.29157 18.1693 7.30026C18.2353 7.37136 18.2865 7.45116 18.3231 7.53579C18.3669 7.63717 18.3912 7.74898 18.3912 7.86647C18.3912 7.98306 18.3673 8.09406 18.3241 8.19481C18.2868 8.28189 18.234 8.3639 18.1656 8.43664C18.1537 8.44941 18.1413 8.46179 18.1285 8.47378C18.0538 8.54406 17.9693 8.59796 17.8796 8.63546C17.7843 8.67534 17.6801 8.69805 17.5708 8.69971L17.5565 8.6998L5.39124 8.6998C4.931 8.6998 4.55791 8.32671 4.55791 7.86647C4.55791 7.40623 4.931 7.03314 5.39124 7.03314L15.5461 7.03314L13.6688 5.1559C13.3434 4.83046 13.3434 4.30282 13.6688 3.97738Z"/>
|
||||
<path d="M1.96866 11.5443C2.04865 11.4643 2.14086 11.404 2.23928 11.3633C2.33521 11.3236 2.44016 11.3012 2.55022 11.3002L2.55791 11.3002H14.7246C15.1848 11.3002 15.5579 11.6733 15.5579 12.1335C15.5579 12.5938 15.1848 12.9669 14.7246 12.9669H4.56976L6.447 14.8441C6.77244 15.1696 6.77244 15.6972 6.447 16.0226C6.12156 16.3481 5.59392 16.3481 5.26849 16.0226L1.96953 12.7237L1.96146 12.7155C1.88513 12.6373 1.82725 12.5478 1.78781 12.4525C1.74707 12.3543 1.72458 12.2465 1.72458 12.1335C1.72458 12.0207 1.74701 11.9131 1.78767 11.8149C1.82833 11.7165 1.88866 11.6243 1.96866 11.5443Z"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
3
packages/web/components/common/Icon/icons/model/grok.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000">
|
||||
<rect width="1000" height="1000" fill="#000"/>
|
||||
<g><polygon fill="#fff" points="226.83 411.15 501.31 803.15 623.31 803.15 348.82 411.15 226.83 411.15"></polygon><polygon fill="#fff" points="348.72 628.87 226.69 803.15 348.77 803.15 409.76 716.05 348.72 628.87"></polygon><polygon fill="#fff" points="651.23 196.85 440.28 498.12 501.32 585.29 773.31 196.85 651.23 196.85"></polygon><polygon fill="#fff" points="673.31 383.25 673.31 803.15 773.31 803.15 773.31 240.44 673.31 383.25"></polygon></g></svg>
|
||||
|
After Width: | Height: | Size: 569 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120">
|
||||
<path fill="#8358F6" fill-rule="evenodd" d="M100.74 12h-7.506c-24.021 0-37.867 15.347-37.867 38.867V54.9a30.862 30.862 0 0 0-8.507-1.196C29.816 53.703 16 67.52 16 84.563c0 17.044 13.816 30.86 30.86 30.86 17.044 0 30.86-13.816 30.86-30.86 0-2.073-.209-4.14-.623-6.172h23.643c6.225-.023 11.26-5.076 11.26-11.301 0-6.226-5.035-11.279-11.26-11.302H77.22v-5.922c0-9.008 6.505-15.513 16.014-15.513h7.506c6.107-.093 11.01-5.069 11.01-11.177 0-6.107-4.903-11.084-11.01-11.176zM56.035 84.563a9.175 9.175 0 1 0-18.35 0 9.175 9.175 0 0 0 18.35 0z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 610 B |
@@ -1 +1,29 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="52" height="52" style="shape-rendering:geometricPrecision;text-rendering:geometricPrecision;image-rendering:optimizeQuality;fill-rule:evenodd;clip-rule:evenodd"><path style="opacity:.718" fill="#0080ff" d="M46.5-.5h3c0 1.333.667 2 2 2v3c-1.676.683-2.343 2.017-2 4h-3v-4c-.427-1.238-.427-2.238 0-3v-2z"/><path style="opacity:.596" fill="#0084ff" d="M46.5 1.5c-.427.762-.427 1.762 0 3h-4v-3h4z"/><path style="opacity:.605" fill="#009dff" d="M7.5 4.5a10.173 10.173 0 0 0-3 3v-4c1.291-.237 2.291.096 3 1z"/><path style="opacity:.749" fill="#09f" d="M7.5 4.5v10a5.728 5.728 0 0 1-3-1v-6a10.173 10.173 0 0 1 3-3z"/><path style="opacity:.741" fill="#0196ff" d="M15.5 6.5a303.97 303.97 0 0 1-4 3v-3h4z"/><path style="opacity:.938" fill="#0091ff" d="M15.5 6.5h8c-1.965 2.978-4.632 4.978-8 6v3h-4v-6a303.97 303.97 0 0 0 4-3z"/><path style="opacity:.963" fill="#008cff" d="M23.5 6.5h9a147.885 147.885 0 0 0-18.5 17c-.77-1.098-1.603-1.098-2.5 0v-8h4v-3c3.368-1.022 6.035-3.022 8-6z"/><path style="opacity:.932" fill="#0086ff" d="M32.5 6.5h10c-5.818 2.99-10.484 6.658-14 11h-6v5a109.794 109.794 0 0 1-11 9v-8c.897-1.098 1.73-1.098 2.5 0a147.885 147.885 0 0 1 18.5-17z"/><path style="opacity:.853" fill="#0080ff" d="M42.5 6.5h3v8a30.943 30.943 0 0 1-2-2 17.853 17.853 0 0 0-5 5h-10c3.516-4.342 8.182-8.01 14-11z"/><path style="opacity:.749" fill="#007aff" d="M45.5 14.5v3h-7a17.853 17.853 0 0 1 5-5c.682.743 1.349 1.41 2 2z"/><path style="opacity:.721" fill="#0092ff" d="M4.5 13.5c.891.61 1.891.943 3 1v7c-.617.11-1.117.444-1.5 1-.278-.916-.778-1.582-1.5-2v-7z"/><path style="opacity:.618" fill="#008dff" d="M4.5 20.5c.722.418 1.222 1.084 1.5 2 .383-.556.883-.89 1.5-1v6h-3v-7z"/><path style="opacity:.941" fill="#0080ff" d="M22.5 22.5v8A273.02 273.02 0 0 1 7.5 43c.556.383.89.883 1 1.5h-9v-3a19.582 19.582 0 0 1 6-4.5 18.492 18.492 0 0 0 2-3.5c1.983.343 3.317-.324 4-2a109.794 109.794 0 0 0 11-9z"/><path style="opacity:.693" fill="#0078ff" d="M35.5 27.5v1c-3.515.845-6.181 2.845-8 6v-7h8z"/><path style="opacity:.716" fill="#016eff" d="M35.5 28.5v-1h16v1c-1.527-.073-2.527.594-3 2h-8c.11-.617.444-1.117 1-1.5a18.436 18.436 0 0 0-6-.5z"/><path style="opacity:.967" fill="#0073ff" d="M35.5 28.5a18.436 18.436 0 0 1 6 .5c-.556.383-.89.883-1 1.5-.992-.172-1.658.162-2 1-3.85 2.76-7.517 5.76-11 9v-6c1.819-3.155 4.485-5.155 8-6z"/><path style="opacity:.874" fill="#0069ff" d="M51.5 28.5v2h-3c.473-1.406 1.473-2.073 3-2z"/><path style="opacity:.921" fill="#0079ff" d="M22.5 30.5v8c-2.938 1.122-4.938 3.122-6 6h-8c-.11-.617-.444-1.117-1-1.5a273.02 273.02 0 0 0 15-12.5z"/><path style="opacity:.924" fill="#006dff" d="M38.5 31.5v8a73.126 73.126 0 0 0-11 9v-8c3.483-3.24 7.15-6.24 11-9z"/><path style="opacity:.878" fill="#0085ff" d="M-.5 33.5h8a18.492 18.492 0 0 1-2 3.5 19.582 19.582 0 0 0-6 4.5v-8z"/><path style="opacity:.788" fill="#0074ff" d="M22.5 38.5v6h-6c1.062-2.878 3.062-4.878 6-6z"/><path style="opacity:.93" fill="#0067ff" d="M38.5 39.5v9c-2.212-.547-3.879.453-5 3h-6v-3a73.126 73.126 0 0 1 11-9z"/><path style="opacity:.883" fill="#0062ff" d="M38.5 48.5v3h-5c1.121-2.547 2.788-3.547 5-3z"/></svg>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 52 52"
|
||||
style="shape-rendering:geometricPrecision;text-rendering:geometricPrecision;image-rendering:optimizeQuality;fill-rule:evenodd;clip-rule:evenodd"
|
||||
>
|
||||
<path style="opacity:.718" fill="#0080ff" d="M46.5-.5h3c0 1.333.667 2 2 2v3c-1.676.683-2.343 2.017-2 4h-3v-4c-.427-1.238-.427-2.238 0-3v-2z"/>
|
||||
<path style="opacity:.596" fill="#0084ff" d="M46.5 1.5c-.427.762-.427 1.762 0 3h-4v-3h4z"/>
|
||||
<path style="opacity:.605" fill="#009dff" d="M7.5 4.5a10.173 10.173 0 0 0-3 3v-4c1.291-.237 2.291.096 3 1z"/>
|
||||
<path style="opacity:.749" fill="#09f" d="M7.5 4.5v10a5.728 5.728 0 0 1-3-1v-6a10.173 10.173 0 0 1 3-3z"/>
|
||||
<path style="opacity:.741" fill="#0196ff" d="M15.5 6.5a303.97 303.97 0 0 1-4 3v-3h4z"/>
|
||||
<path style="opacity:.938" fill="#0091ff" d="M15.5 6.5h8c-1.965 2.978-4.632 4.978-8 6v3h-4v-6a303.97 303.97 0 0 0 4-3z"/>
|
||||
<path style="opacity:.963" fill="#008cff" d="M23.5 6.5h9a147.885 147.885 0 0 0-18.5 17c-.77-1.098-1.603-1.098-2.5 0v-8h4v-3c3.368-1.022 6.035-3.022 8-6z"/>
|
||||
<path style="opacity:.932" fill="#0086ff" d="M32.5 6.5h10c-5.818 2.99-10.484 6.658-14 11h-6v5a109.794 109.794 0 0 1-11 9v-8c.897-1.098 1.73-1.098 2.5 0a147.885 147.885 0 0 1 18.5-17z"/>
|
||||
<path style="opacity:.853" fill="#0080ff" d="M42.5 6.5h3v8a30.943 30.943 0 0 1-2-2 17.853 17.853 0 0 0-5 5h-10c3.516-4.342 8.182-8.01 14-11z"/>
|
||||
<path style="opacity:.749" fill="#007aff" d="M45.5 14.5v3h-7a17.853 17.853 0 0 1 5-5c.682.743 1.349 1.41 2 2z"/>
|
||||
<path style="opacity:.721" fill="#0092ff" d="M4.5 13.5c.891.61 1.891.943 3 1v7c-.617.11-1.117.444-1.5 1-.278-.916-.778-1.582-1.5-2v-7z"/>
|
||||
<path style="opacity:.618" fill="#008dff" d="M4.5 20.5c.722.418 1.222 1.084 1.5 2 .383-.556.883-.89 1.5-1v6h-3v-7z"/>
|
||||
<path style="opacity:.941" fill="#0080ff" d="M22.5 22.5v8A273.02 273.02 0 0 1 7.5 43c.556.383.89.883 1 1.5h-9v-3a19.582 19.582 0 0 1 6-4.5 18.492 18.492 0 0 0 2-3.5c1.983.343 3.317-.324 4-2a109.794 109.794 0 0 0 11-9z"/>
|
||||
<path style="opacity:.693" fill="#0078ff" d="M35.5 27.5v1c-3.515.845-6.181 2.845-8 6v-7h8z"/>
|
||||
<path style="opacity:.716" fill="#016eff" d="M35.5 28.5v-1h16v1c-1.527-.073-2.527.594-3 2h-8c.11-.617.444-1.117 1-1.5a18.436 18.436 0 0 0-6-.5z"/>
|
||||
<path style="opacity:.967" fill="#0073ff" d="M35.5 28.5a18.436 18.436 0 0 1 6 .5c-.556.383-.89.883-1 1.5-.992-.172-1.658.162-2 1-3.85 2.76-7.517 5.76-11 9v-6c1.819-3.155 4.485-5.155 8-6z"/>
|
||||
<path style="opacity:.874" fill="#0069ff" d="M51.5 28.5v2h-3c.473-1.406 1.473-2.073 3-2z"/>
|
||||
<path style="opacity:.921" fill="#0079ff" d="M22.5 30.5v8c-2.938 1.122-4.938 3.122-6 6h-8c-.11-.617-.444-1.117-1-1.5a273.02 273.02 0 0 0 15-12.5z"/>
|
||||
<path style="opacity:.924" fill="#006dff" d="M38.5 31.5v8a73.126 73.126 0 0 0-11 9v-8c3.483-3.24 7.15-6.24 11-9z"/>
|
||||
<path style="opacity:.878" fill="#0085ff" d="M-.5 33.5h8a18.492 18.492 0 0 1-2 3.5 19.582 19.582 0 0 0-6 4.5v-8z"/>
|
||||
<path style="opacity:.788" fill="#0074ff" d="M22.5 38.5v6h-6c1.062-2.878 3.062-4.878 6-6z"/>
|
||||
<path style="opacity:.93" fill="#0067ff" d="M38.5 39.5v9c-2.212-.547-3.879.453-5 3h-6v-3a73.126 73.126 0 0 1 11-9z"/>
|
||||
<path style="opacity:.883" fill="#0062ff" d="M38.5 48.5v3h-5c1.121-2.547 2.788-3.547 5-3z"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
@@ -26,11 +26,12 @@ const MyNumberInput = (props: Props) => {
|
||||
{...restProps}
|
||||
onChange={(e) => {
|
||||
if (!onChange) return;
|
||||
if (e === '') {
|
||||
const numE = Number(e);
|
||||
if (isNaN(numE)) {
|
||||
// @ts-ignore
|
||||
onChange('');
|
||||
} else {
|
||||
onChange(Number(e));
|
||||
onChange(numE);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||