mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
4.6.8-alpha (#804)
* perf: redirect request and err log replace perf: dataset openapi feat: session fix: retry input error feat: 468 doc sub page feat: standard sub perf: rerank tip perf: rerank tip perf: api sdk perf: openapi sub plan perf: sub ui fix: ts * perf: init log * fix: variable select * sub page * icon * perf: llm model config * perf: menu ux * perf: system store * perf: publish app name * fix: init data * perf: flow edit ux * fix: value type format and ux * fix prompt editor default value (#13) * fix prompt editor default value * fix prompt editor update when not focus * add key with variable --------- Co-authored-by: Archer <545436317@qq.com> * fix: value type * doc * i18n * import path * home page * perf: mongo session running * fix: ts * perf: use toast * perf: flow edit * perf: sse response * slider ui * fetch error * fix prompt editor rerender when not focus by key defaultvalue (#14) * perf: prompt editor * feat: dataset search concat * perf: doc * fix:ts * perf: doc * fix json editor onblur value (#15) * faq * vector model default config * ipv6 --------- Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
23
packages/global/common/system/types/index.d.ts
vendored
23
packages/global/common/system/types/index.d.ts
vendored
@@ -1,3 +1,4 @@
|
||||
import { StandSubPlanLevelMapType, SubPlanType } from '../../../support/wallet/sub/type';
|
||||
import type {
|
||||
ChatModelItemType,
|
||||
FunctionModelItemType,
|
||||
@@ -7,16 +8,14 @@ import type {
|
||||
WhisperModelType,
|
||||
ReRankModelItemType
|
||||
} from '../../../core/ai/model.d';
|
||||
import { SubTypeEnum } from '../../../support/wallet/sub/constants';
|
||||
|
||||
/* fastgpt main */
|
||||
export type FastGPTConfigFileType = {
|
||||
feConfigs: FastGPTFeConfigsType;
|
||||
systemEnv: SystemEnvType;
|
||||
chatModels: ChatModelItemType[];
|
||||
qaModels: LLMModelItemType[];
|
||||
cqModels: FunctionModelItemType[];
|
||||
extractModels: FunctionModelItemType[];
|
||||
qgModels: LLMModelItemType[];
|
||||
subPlans?: SubPlanType;
|
||||
llmModels: ChatModelItemType[];
|
||||
vectorModels: VectorModelItemType[];
|
||||
reRankModels: ReRankModelItemType[];
|
||||
audioSpeechModels: AudioSpeechModelType[];
|
||||
@@ -51,10 +50,6 @@ export type FastGPTFeConfigsType = {
|
||||
favicon?: string;
|
||||
customApiDomain?: string;
|
||||
customSharePageDomain?: string;
|
||||
subscription?: {
|
||||
datasetStoreFreeSize?: number;
|
||||
datasetStorePrice?: number;
|
||||
};
|
||||
|
||||
uploadFileMaxSize?: number;
|
||||
};
|
||||
@@ -66,8 +61,8 @@ export type SystemEnvType = {
|
||||
pgHNSWEfSearch: number;
|
||||
};
|
||||
|
||||
declare global {
|
||||
var feConfigs: FastGPTFeConfigsType;
|
||||
var systemEnv: SystemEnvType;
|
||||
var systemInitd: boolean;
|
||||
}
|
||||
// declare global {
|
||||
// var feConfigs: FastGPTFeConfigsType;
|
||||
// var systemEnv: SystemEnvType;
|
||||
// var systemInitd: boolean;
|
||||
// }
|
||||
|
22
packages/global/core/ai/model.d.ts
vendored
22
packages/global/core/ai/model.d.ts
vendored
@@ -3,20 +3,24 @@ export type LLMModelItemType = {
|
||||
name: string;
|
||||
maxContext: number;
|
||||
maxResponse: number;
|
||||
inputPrice: number;
|
||||
outputPrice: number;
|
||||
};
|
||||
export type ChatModelItemType = LLMModelItemType & {
|
||||
quoteMaxToken: number;
|
||||
maxTemperature: number;
|
||||
|
||||
inputPrice: number;
|
||||
outputPrice: number;
|
||||
|
||||
censor?: boolean;
|
||||
vision?: boolean;
|
||||
defaultSystemChatPrompt?: string;
|
||||
};
|
||||
datasetProcess?: boolean;
|
||||
|
||||
export type FunctionModelItemType = LLMModelItemType & {
|
||||
functionCall: boolean;
|
||||
toolChoice: boolean;
|
||||
functionPrompt: string;
|
||||
|
||||
customCQPrompt: string;
|
||||
customExtractPrompt: string;
|
||||
|
||||
defaultSystemChatPrompt?: string;
|
||||
defaultConfig?: Record<string, any>;
|
||||
};
|
||||
|
||||
export type VectorModelItemType = {
|
||||
@@ -27,6 +31,8 @@ export type VectorModelItemType = {
|
||||
outputPrice: number;
|
||||
maxToken: number;
|
||||
weight: number;
|
||||
hidden?: boolean;
|
||||
defaultConfig?: Record<string, any>;
|
||||
};
|
||||
|
||||
export type ReRankModelItemType = {
|
||||
|
@@ -3,11 +3,22 @@ import type { LLMModelItemType, VectorModelItemType } from './model.d';
|
||||
export const defaultQAModels: LLMModelItemType[] = [
|
||||
{
|
||||
model: 'gpt-3.5-turbo-16k',
|
||||
name: 'GPT35-16k',
|
||||
name: 'gpt-3.5-turbo-16k',
|
||||
maxContext: 16000,
|
||||
maxResponse: 16000,
|
||||
quoteMaxToken: 13000,
|
||||
maxTemperature: 1.2,
|
||||
inputPrice: 0,
|
||||
outputPrice: 0
|
||||
outputPrice: 0,
|
||||
censor: false,
|
||||
vision: false,
|
||||
datasetProcess: true,
|
||||
toolChoice: true,
|
||||
functionCall: false,
|
||||
customCQPrompt: '',
|
||||
customExtractPrompt: '',
|
||||
defaultSystemChatPrompt: '',
|
||||
defaultConfig: {}
|
||||
}
|
||||
];
|
||||
|
||||
|
4
packages/global/core/app/api.d.ts
vendored
4
packages/global/core/app/api.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import type { ChatModelItemType } from '../ai/model.d';
|
||||
import type { LLMModelItemType } from '../ai/model.d';
|
||||
import { AppTypeEnum } from './constants';
|
||||
import { AppSchema, AppSimpleEditFormType } from './type';
|
||||
|
||||
@@ -22,5 +22,5 @@ export interface AppUpdateParams {
|
||||
export type FormatForm2ModulesProps = {
|
||||
formData: AppSimpleEditFormType;
|
||||
chatModelMaxToken: number;
|
||||
chatModelList: ChatModelItemType[];
|
||||
llmModelList: LLMModelItemType[];
|
||||
};
|
||||
|
@@ -91,7 +91,7 @@ export const appModules2Form = ({
|
||||
);
|
||||
defaultAppForm.dataset.limit = findInputValueByKey(
|
||||
module.inputs,
|
||||
ModuleInputKeyEnum.datasetLimit
|
||||
ModuleInputKeyEnum.datasetMaxTokens
|
||||
);
|
||||
defaultAppForm.dataset.searchMode =
|
||||
findInputValueByKey(module.inputs, ModuleInputKeyEnum.datasetSearchMode) ||
|
||||
|
95
packages/global/core/dataset/search/utils.ts
Normal file
95
packages/global/core/dataset/search/utils.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { countPromptTokens } from '../../../common/string/tiktoken';
|
||||
import { SearchScoreTypeEnum } from '../constants';
|
||||
import { SearchDataResponseItemType } from '../type';
|
||||
|
||||
/* dataset search result concat */
|
||||
export const datasetSearchResultConcat = (
|
||||
arr: { k: number; list: SearchDataResponseItemType[] }[]
|
||||
): SearchDataResponseItemType[] => {
|
||||
arr = arr.filter((item) => item.list.length > 0);
|
||||
|
||||
if (arr.length === 0) return [];
|
||||
if (arr.length === 1) return arr[0].list;
|
||||
|
||||
const map = new Map<string, SearchDataResponseItemType & { rrfScore: number }>();
|
||||
|
||||
// rrf
|
||||
arr.forEach((item) => {
|
||||
const k = item.k;
|
||||
|
||||
item.list.forEach((data, index) => {
|
||||
const rank = index + 1;
|
||||
const score = 1 / (k + rank);
|
||||
|
||||
const record = map.get(data.id);
|
||||
if (record) {
|
||||
// 合并两个score,有相同type的score,取最大值
|
||||
const concatScore = [...record.score];
|
||||
for (const dataItem of data.score) {
|
||||
const sameScore = concatScore.find((item) => item.type === dataItem.type);
|
||||
if (sameScore) {
|
||||
sameScore.value = Math.max(sameScore.value, dataItem.value);
|
||||
} else {
|
||||
concatScore.push(dataItem);
|
||||
}
|
||||
}
|
||||
|
||||
map.set(data.id, {
|
||||
...record,
|
||||
score: concatScore,
|
||||
rrfScore: record.rrfScore + score
|
||||
});
|
||||
} else {
|
||||
map.set(data.id, {
|
||||
...data,
|
||||
rrfScore: score
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// sort
|
||||
const mapArray = Array.from(map.values());
|
||||
const results = mapArray.sort((a, b) => b.rrfScore - a.rrfScore);
|
||||
|
||||
return results.map((item, index) => {
|
||||
// if SearchScoreTypeEnum.rrf exist, reset score
|
||||
const rrfScore = item.score.find((item) => item.type === SearchScoreTypeEnum.rrf);
|
||||
if (rrfScore) {
|
||||
rrfScore.value = item.rrfScore;
|
||||
rrfScore.index = index;
|
||||
} else {
|
||||
item.score.push({
|
||||
type: SearchScoreTypeEnum.rrf,
|
||||
value: item.rrfScore,
|
||||
index
|
||||
});
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
delete item.rrfScore;
|
||||
return item;
|
||||
});
|
||||
};
|
||||
|
||||
export const filterSearchResultsByMaxChars = (
|
||||
list: SearchDataResponseItemType[],
|
||||
maxTokens: number
|
||||
) => {
|
||||
const results: SearchDataResponseItemType[] = [];
|
||||
let totalTokens = 0;
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const item = list[i];
|
||||
totalTokens += countPromptTokens(item.q + item.a);
|
||||
if (totalTokens > maxTokens + 500) {
|
||||
break;
|
||||
}
|
||||
results.push(item);
|
||||
if (totalTokens > maxTokens) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return results.length === 0 ? list.slice(0, 1) : results;
|
||||
};
|
@@ -35,6 +35,7 @@ export function getSourceNameIcon({
|
||||
return 'file/fill/manual';
|
||||
}
|
||||
|
||||
/* get dataset data default index */
|
||||
export function getDefaultIndex(props?: { q?: string; a?: string; dataId?: string }) {
|
||||
const { q = '', a, dataId } = props || {};
|
||||
const qaStr = `${q}\n${a}`.trim();
|
||||
|
@@ -61,7 +61,7 @@ export enum ModuleInputKeyEnum {
|
||||
// dataset
|
||||
datasetSelectList = 'datasets',
|
||||
datasetSimilarity = 'similarity',
|
||||
datasetLimit = 'limit',
|
||||
datasetMaxTokens = 'limit',
|
||||
datasetSearchMode = 'searchMode',
|
||||
datasetSearchUsingReRank = 'usingReRank',
|
||||
datasetParamsModal = 'datasetParamsModal',
|
||||
|
@@ -45,7 +45,10 @@ export enum FlowNodeTypeEnum {
|
||||
questionInput = 'questionInput',
|
||||
historyNode = 'historyNode',
|
||||
chatNode = 'chatNode',
|
||||
|
||||
datasetSearchNode = 'datasetSearchNode',
|
||||
datasetConcatNode = 'datasetConcatNode',
|
||||
|
||||
answerNode = 'answerNode',
|
||||
classifyQuestion = 'classifyQuestion',
|
||||
contentExtract = 'contentExtract',
|
||||
|
2
packages/global/core/module/node/type.d.ts
vendored
2
packages/global/core/module/node/type.d.ts
vendored
@@ -106,6 +106,6 @@ export type AIChatModuleProps = {
|
||||
export type DatasetModuleProps = {
|
||||
[ModuleInputKeyEnum.datasetSelectList]: SelectedDatasetType;
|
||||
[ModuleInputKeyEnum.datasetSimilarity]: number;
|
||||
[ModuleInputKeyEnum.datasetLimit]: number;
|
||||
[ModuleInputKeyEnum.datasetMaxTokens]: number;
|
||||
[ModuleInputKeyEnum.datasetStartReRank]: boolean;
|
||||
};
|
||||
|
@@ -7,6 +7,7 @@ export const Input_Template_Switch: FlowNodeInputItemType = {
|
||||
key: ModuleInputKeyEnum.switch,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: 'core.module.input.label.switch',
|
||||
description: 'core.module.input.description.Trigger',
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
@@ -27,8 +28,8 @@ export const Input_Template_History: FlowNodeInputItemType = {
|
||||
|
||||
export const Input_Template_UserChatInput: FlowNodeInputItemType = {
|
||||
key: ModuleInputKeyEnum.userChatInput,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: 'core.module.input.label.user question',
|
||||
type: FlowNodeInputTypeEnum.custom,
|
||||
label: '',
|
||||
required: true,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: true,
|
||||
@@ -56,3 +57,13 @@ export const Input_Template_DynamicInput: FlowNodeInputItemType = {
|
||||
showTargetInPlugin: true,
|
||||
hideInApp: true
|
||||
};
|
||||
|
||||
export const Input_Template_Dataset_Quote: FlowNodeInputItemType = {
|
||||
key: ModuleInputKeyEnum.aiChatDatasetQuote,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: '知识库引用',
|
||||
description: 'core.module.Dataset quote.Input description',
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
};
|
||||
|
@@ -1,52 +0,0 @@
|
||||
import {
|
||||
FlowNodeInputTypeEnum,
|
||||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../../type';
|
||||
import {
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../../constants';
|
||||
|
||||
export const HistoryModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.historyNode,
|
||||
templateType: ModuleTemplateTypeEnum.systemInput,
|
||||
flowType: FlowNodeTypeEnum.historyNode,
|
||||
avatar: '/imgs/module/history.png',
|
||||
name: '聊天记录(弃用)',
|
||||
intro: '聊天记录,该模块已被弃用',
|
||||
inputs: [
|
||||
{
|
||||
key: ModuleInputKeyEnum.historyMaxAmount,
|
||||
type: FlowNodeInputTypeEnum.numberInput,
|
||||
label: '最长记录数',
|
||||
description:
|
||||
'该记录数不代表模型可接收这么多的历史记录,具体可接收多少历史记录,取决于模型的能力,通常建议不要超过20条。',
|
||||
value: 6,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
min: 0,
|
||||
max: 100,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
{
|
||||
key: ModuleInputKeyEnum.history,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
valueType: ModuleIOValueTypeEnum.chatHistory,
|
||||
label: '聊天记录',
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
}
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
key: ModuleInputKeyEnum.history,
|
||||
label: '聊天记录',
|
||||
valueType: ModuleIOValueTypeEnum.chatHistory,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
}
|
||||
]
|
||||
};
|
@@ -11,6 +11,7 @@ import {
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../constants';
|
||||
import {
|
||||
Input_Template_Dataset_Quote,
|
||||
Input_Template_History,
|
||||
Input_Template_Switch,
|
||||
Input_Template_UserChatInput
|
||||
@@ -108,16 +109,8 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
showTargetInPlugin: true
|
||||
},
|
||||
Input_Template_History,
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiChatDatasetQuote,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: 'core.module.input.label.Quote',
|
||||
description: 'core.module.input.description.Quote',
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
},
|
||||
Input_Template_UserChatInput
|
||||
Input_Template_UserChatInput,
|
||||
Input_Template_Dataset_Quote
|
||||
],
|
||||
outputs: [
|
||||
Output_Template_UserChatInput,
|
||||
|
54
packages/global/core/module/template/system/datasetConcat.ts
Normal file
54
packages/global/core/module/template/system/datasetConcat.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import {
|
||||
FlowNodeInputTypeEnum,
|
||||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import {
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
ModuleOutputKeyEnum,
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../constants';
|
||||
import { Input_Template_Dataset_Quote, Input_Template_Switch } from '../input';
|
||||
import { Output_Template_Finish } from '../output';
|
||||
import { getNanoid } from '../../../../common/string/tools';
|
||||
|
||||
export const getOneQuoteInputTemplate = (key = getNanoid()) => ({
|
||||
...Input_Template_Dataset_Quote,
|
||||
key,
|
||||
type: FlowNodeInputTypeEnum.hidden
|
||||
});
|
||||
|
||||
export const DatasetConcatModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.datasetConcatNode,
|
||||
flowType: FlowNodeTypeEnum.datasetConcatNode,
|
||||
templateType: ModuleTemplateTypeEnum.tools,
|
||||
avatar: '/imgs/module/concat.svg',
|
||||
name: '知识库搜索引用合并',
|
||||
intro: 'core.module.template.Dataset search result concat intro',
|
||||
showStatus: false,
|
||||
inputs: [
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.datasetMaxTokens,
|
||||
type: FlowNodeInputTypeEnum.custom,
|
||||
label: '最大 Tokens',
|
||||
value: 1500,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
getOneQuoteInputTemplate('defaultQuote')
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
key: ModuleOutputKeyEnum.datasetQuoteQA,
|
||||
label: 'core.module.Dataset quote.label',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
targets: []
|
||||
},
|
||||
Output_Template_Finish
|
||||
]
|
||||
};
|
@@ -52,7 +52,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
{
|
||||
key: ModuleInputKeyEnum.datasetLimit,
|
||||
key: ModuleInputKeyEnum.datasetMaxTokens,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '',
|
||||
value: 1500,
|
||||
@@ -106,8 +106,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
},
|
||||
{
|
||||
key: ModuleOutputKeyEnum.datasetQuoteQA,
|
||||
label: 'core.module.output.label.Quote',
|
||||
description: 'core.module.output.label.Quote intro',
|
||||
label: 'core.module.Dataset quote.label',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
targets: []
|
||||
|
@@ -6,7 +6,7 @@ export const RunPluginModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.pluginModule,
|
||||
templateType: ModuleTemplateTypeEnum.externalCall,
|
||||
flowType: FlowNodeTypeEnum.pluginModule,
|
||||
avatar: '/imgs/module/custom.png',
|
||||
avatar: '',
|
||||
intro: '',
|
||||
name: '',
|
||||
showStatus: false,
|
||||
|
@@ -15,7 +15,7 @@ export const UserInputModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.questionInput,
|
||||
templateType: ModuleTemplateTypeEnum.systemInput,
|
||||
flowType: FlowNodeTypeEnum.questionInput,
|
||||
avatar: '/imgs/module/userChatInput.png',
|
||||
avatar: '/imgs/module/userChatInput.svg',
|
||||
name: 'core.module.template.Chat entrance',
|
||||
intro: 'core.module.template.Chat entrance intro',
|
||||
inputs: [
|
||||
|
9
packages/global/core/module/type.d.ts
vendored
9
packages/global/core/module/type.d.ts
vendored
@@ -3,9 +3,9 @@ import { ModuleIOValueTypeEnum, ModuleTemplateTypeEnum, VariableInputEnum } from
|
||||
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './node/type';
|
||||
|
||||
export type FlowModuleTemplateType = {
|
||||
id: string;
|
||||
id: string; // module id, unique
|
||||
templateType: `${ModuleTemplateTypeEnum}`;
|
||||
flowType: `${FlowNodeTypeEnum}`; // unique
|
||||
flowType: `${FlowNodeTypeEnum}`; // render node card
|
||||
avatar?: string;
|
||||
name: string;
|
||||
intro: string; // template list intro
|
||||
@@ -85,12 +85,14 @@ export type RunningModuleItemType = {
|
||||
inputs: {
|
||||
key: string;
|
||||
value?: any;
|
||||
valueType?: `${ModuleIOValueTypeEnum}`;
|
||||
}[];
|
||||
outputs: {
|
||||
key: string;
|
||||
answer?: boolean;
|
||||
response?: boolean;
|
||||
value?: any;
|
||||
valueType?: `${ModuleIOValueTypeEnum}`;
|
||||
targets: {
|
||||
moduleId: string;
|
||||
key: string;
|
||||
@@ -115,5 +117,6 @@ export type ChatDispatchProps = {
|
||||
|
||||
export type ModuleDispatchProps<T> = ChatDispatchProps & {
|
||||
outputs: RunningModuleItemType['outputs'];
|
||||
inputs: T;
|
||||
inputs: RunningModuleItemType['inputs'];
|
||||
params: T;
|
||||
};
|
||||
|
@@ -1,8 +1,14 @@
|
||||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from './node/constant';
|
||||
import { ModuleIOValueTypeEnum, ModuleInputKeyEnum, variableMap } from './constants';
|
||||
import {
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
VariableInputEnum,
|
||||
variableMap
|
||||
} from './constants';
|
||||
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './node/type';
|
||||
import { AppTTSConfigType, ModuleItemType, VariableItemType } from './type';
|
||||
import { Input_Template_Switch } from './template/input';
|
||||
import { EditorVariablePickerType } from '../../../web/components/common/Textarea/PromptEditor/type';
|
||||
|
||||
export const getGuideModule = (modules: ModuleItemType[]) =>
|
||||
modules.find((item) => item.flowType === FlowNodeTypeEnum.userGuide);
|
||||
@@ -68,7 +74,7 @@ export function plugin2ModuleIO(
|
||||
// plugin id
|
||||
key: ModuleInputKeyEnum.pluginId,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: 'pluginId',
|
||||
label: '',
|
||||
value: pluginId,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
connected: true,
|
||||
@@ -95,11 +101,11 @@ export function plugin2ModuleIO(
|
||||
};
|
||||
}
|
||||
|
||||
export const formatVariablesIcon = (
|
||||
variables: VariableItemType[]
|
||||
): (VariableItemType & { icon: string })[] => {
|
||||
export const formatEditorVariablePickerIcon = (
|
||||
variables: { key: string; label: string; type?: `${VariableInputEnum}` }[]
|
||||
): EditorVariablePickerType[] => {
|
||||
return variables.map((item) => ({
|
||||
...item,
|
||||
icon: variableMap[item.type]?.icon
|
||||
icon: item.type ? variableMap[item.type]?.icon : variableMap['input'].icon
|
||||
}));
|
||||
};
|
||||
|
@@ -7,6 +7,8 @@ export enum BillSourceEnum {
|
||||
api = 'api',
|
||||
shareLink = 'shareLink',
|
||||
training = 'training',
|
||||
|
||||
standSubPlan = 'standSubPlan',
|
||||
extraDatasetSub = 'extraDatasetSub'
|
||||
}
|
||||
|
||||
@@ -21,9 +23,12 @@ export const BillSourceMap = {
|
||||
label: '免登录链接'
|
||||
},
|
||||
[BillSourceEnum.training]: {
|
||||
label: '数据训练'
|
||||
label: 'dataset.Training Name'
|
||||
},
|
||||
[BillSourceEnum.standSubPlan]: {
|
||||
label: 'support.wallet.subscription.type.standard'
|
||||
},
|
||||
[BillSourceEnum.extraDatasetSub]: {
|
||||
label: '知识库扩容'
|
||||
label: 'support.wallet.subscription.type.extraDatasetSize'
|
||||
}
|
||||
};
|
||||
|
@@ -9,13 +9,13 @@ export const payTypeMap = {
|
||||
label: 'support.user.team.pay.type.balance'
|
||||
},
|
||||
[PayTypeEnum.subStandard]: {
|
||||
label: 'support.user.team.subscription.type.standard'
|
||||
label: 'support.wallet.subscription.type.standard'
|
||||
},
|
||||
[PayTypeEnum.subExtraDatasetSize]: {
|
||||
label: 'support.user.team.subscription.type.extraDatasetSize'
|
||||
label: 'support.wallet.subscription.type.extraDatasetSize'
|
||||
},
|
||||
[PayTypeEnum.subExtraPoints]: {
|
||||
label: 'support.user.team.subscription.type.extraPoints'
|
||||
label: 'support.wallet.subscription.type.extraPoints'
|
||||
}
|
||||
};
|
||||
|
||||
|
25
packages/global/support/wallet/sub/api.d.ts
vendored
25
packages/global/support/wallet/sub/api.d.ts
vendored
@@ -1,15 +1,36 @@
|
||||
import { SubModeEnum } from './constants';
|
||||
import { StandardSubLevelEnum, SubModeEnum } from './constants';
|
||||
import { TeamSubSchema } from './type.d';
|
||||
|
||||
export type SubDatasetSizeParams = {
|
||||
size: number;
|
||||
};
|
||||
export type StandardSubPlanParams = {
|
||||
level: `${StandardSubLevelEnum}`;
|
||||
mode: `${SubModeEnum}`;
|
||||
};
|
||||
|
||||
export type SubDatasetSizePreviewCheckResponse = {
|
||||
payForNewSub: boolean; // Does this change require payment
|
||||
newSubSize: number; // new sub dataset size
|
||||
alreadySubSize: number; // old sub dataset size
|
||||
payPrice: number; // this change require payment
|
||||
newPrice: number; // the new sub price
|
||||
newPlanPrice: number; // the new sub price
|
||||
newSubStartTime: Date;
|
||||
newSubExpiredTime: Date;
|
||||
balanceEnough: boolean; // team balance is enough
|
||||
};
|
||||
export type StandardSubPlanUpdateResponse = {
|
||||
balanceEnough: boolean; // team balance is enough
|
||||
payPrice?: number;
|
||||
planPrice: number;
|
||||
planPointPrice: number;
|
||||
|
||||
currentMode: `${SubModeEnum}`;
|
||||
nextMode: `${SubModeEnum}`;
|
||||
currentSubLevel: `${StandardSubLevelEnum}`;
|
||||
nextSubLevel: `${StandardSubLevelEnum}`;
|
||||
totalPoints: number;
|
||||
surplusPoints: number;
|
||||
planStartTime: Date;
|
||||
planExpiredTime: Date;
|
||||
};
|
||||
|
@@ -1,3 +1,5 @@
|
||||
export const POINTS_SCALE = 10000;
|
||||
|
||||
export enum SubTypeEnum {
|
||||
standard = 'standard',
|
||||
extraDatasetSize = 'extraDatasetSize',
|
||||
@@ -5,13 +7,13 @@ export enum SubTypeEnum {
|
||||
}
|
||||
export const subTypeMap = {
|
||||
[SubTypeEnum.standard]: {
|
||||
label: 'support.user.team.subscription.type.standard'
|
||||
label: 'support.wallet.subscription.type.standard'
|
||||
},
|
||||
[SubTypeEnum.extraDatasetSize]: {
|
||||
label: 'support.user.team.subscription.type.extraDatasetSize'
|
||||
label: 'support.wallet.subscription.type.extraDatasetSize'
|
||||
},
|
||||
[SubTypeEnum.extraPoints]: {
|
||||
label: 'support.user.team.subscription.type.extraPoints'
|
||||
label: 'support.wallet.subscription.type.extraPoints'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,10 +23,10 @@ export enum SubStatusEnum {
|
||||
}
|
||||
export const subStatusMap = {
|
||||
[SubStatusEnum.active]: {
|
||||
label: 'support.user.team.subscription.status.active'
|
||||
label: 'support.wallet.subscription.status.active'
|
||||
},
|
||||
[SubStatusEnum.canceled]: {
|
||||
label: 'support.user.team.subscription.status.canceled'
|
||||
label: 'support.wallet.subscription.status.canceled'
|
||||
}
|
||||
};
|
||||
export const subSelectMap = {
|
||||
@@ -38,11 +40,11 @@ export enum SubModeEnum {
|
||||
}
|
||||
export const subModeMap = {
|
||||
[SubModeEnum.month]: {
|
||||
label: 'support.user.team.subscription.mode.month',
|
||||
label: 'support.wallet.subscription.mode.month',
|
||||
durationMonth: 1
|
||||
},
|
||||
[SubModeEnum.year]: {
|
||||
label: 'support.user.team.subscription.mode.year',
|
||||
label: 'support.wallet.subscription.mode.year',
|
||||
durationMonth: 12
|
||||
}
|
||||
};
|
||||
@@ -56,18 +58,23 @@ export enum StandardSubLevelEnum {
|
||||
}
|
||||
export const standardSubLevelMap = {
|
||||
[StandardSubLevelEnum.free]: {
|
||||
label: 'support.user.team.subscription.standardSubLevel.free'
|
||||
label: 'support.wallet.subscription.standardSubLevel.free',
|
||||
desc: 'support.wallet.subscription.standardSubLevel.free desc'
|
||||
},
|
||||
[StandardSubLevelEnum.experience]: {
|
||||
label: 'support.user.team.subscription.standardSubLevel.experience'
|
||||
label: 'support.wallet.subscription.standardSubLevel.experience',
|
||||
desc: 'support.wallet.subscription.standardSubLevel.experience desc'
|
||||
},
|
||||
[StandardSubLevelEnum.team]: {
|
||||
label: 'support.user.team.subscription.standardSubLevel.team'
|
||||
label: 'support.wallet.subscription.standardSubLevel.team',
|
||||
desc: ''
|
||||
},
|
||||
[StandardSubLevelEnum.enterprise]: {
|
||||
label: 'support.user.team.subscription.standardSubLevel.enterprise'
|
||||
label: 'support.wallet.subscription.standardSubLevel.enterprise',
|
||||
desc: ''
|
||||
},
|
||||
[StandardSubLevelEnum.custom]: {
|
||||
label: 'support.user.team.subscription.standardSubLevel.custom'
|
||||
label: 'support.wallet.subscription.standardSubLevel.custom',
|
||||
desc: ''
|
||||
}
|
||||
};
|
||||
|
74
packages/global/support/wallet/sub/type.d.ts
vendored
74
packages/global/support/wallet/sub/type.d.ts
vendored
@@ -1,39 +1,73 @@
|
||||
import { StandardSubLevelEnum, SubModeEnum, SubStatusEnum, SubTypeEnum } from './constants';
|
||||
|
||||
// Content of plan
|
||||
export type TeamStandardSubPlanItemType = {
|
||||
price: number; // read price
|
||||
pointPrice: number; // read price/ one ten thousand
|
||||
maxTeamMember: number;
|
||||
maxAppAmount: number; // max app or plugin amount
|
||||
maxDatasetAmount: number;
|
||||
chatHistoryStoreDuration: number; // n day
|
||||
maxDatasetSize: number;
|
||||
customApiKey: boolean;
|
||||
customCopyright: boolean; // feature
|
||||
websiteSyncInterval: number; // n hours
|
||||
trainingWeight: number; // 1~4
|
||||
reRankWeight: number; // 1~4
|
||||
totalPoints: number; // n ten thousand
|
||||
};
|
||||
|
||||
export type StandSubPlanLevelMapType = Record<
|
||||
`${StandardSubLevelEnum}`,
|
||||
TeamStandardSubPlanItemType
|
||||
>;
|
||||
|
||||
export type SubPlanType = {
|
||||
[SubTypeEnum.standard]: StandSubPlanLevelMapType;
|
||||
[SubTypeEnum.extraDatasetSize]: {
|
||||
price: number;
|
||||
};
|
||||
};
|
||||
|
||||
export type TeamSubSchema = {
|
||||
_id: string;
|
||||
teamId: string;
|
||||
type: `${SubTypeEnum}`;
|
||||
status: `${SubStatusEnum}`;
|
||||
mode: `${SubModeEnum}`;
|
||||
currentMode: `${SubModeEnum}`;
|
||||
nextMode: `${SubModeEnum}`;
|
||||
startTime: Date;
|
||||
expiredTime: Date;
|
||||
price: number;
|
||||
|
||||
currentSubLevel?: `${StandardSubLevelEnum}`;
|
||||
nextSubLevel?: `${StandardSubLevelEnum}`;
|
||||
currentSubLevel: `${StandardSubLevelEnum}`;
|
||||
nextSubLevel: `${StandardSubLevelEnum}`;
|
||||
pointPrice: number;
|
||||
totalPoints: number;
|
||||
|
||||
currentExtraDatasetSize?: number;
|
||||
nextExtraDatasetSize?: number;
|
||||
currentExtraDatasetSize: number;
|
||||
nextExtraDatasetSize: number;
|
||||
|
||||
currentExtraPoints?: number;
|
||||
nextExtraPoints?: number;
|
||||
currentExtraPoints: number;
|
||||
nextExtraPoints: number;
|
||||
|
||||
maxTeamMember?: number;
|
||||
maxAppAmount?: number;
|
||||
maxDatasetAmount?: number;
|
||||
chatHistoryStoreDuration?: number;
|
||||
maxDatasetSize?: number;
|
||||
customApiKey?: boolean;
|
||||
customCopyright?: number;
|
||||
exportDatasetInterval?: number;
|
||||
websiteSyncInterval?: number;
|
||||
reRankWeight?: number;
|
||||
totalPoints?: number;
|
||||
|
||||
surplusPoints?: number;
|
||||
surplusPoints: number;
|
||||
|
||||
// abandon
|
||||
datasetStoreAmount?: number;
|
||||
renew?: boolean;
|
||||
};
|
||||
|
||||
export type FeTeamSubType = {
|
||||
[SubTypeEnum.standard]?: TeamSubSchema;
|
||||
[SubTypeEnum.extraDatasetSize]?: TeamSubSchema;
|
||||
[SubTypeEnum.extraPoints]?: TeamSubSchema;
|
||||
|
||||
standardMaxDatasetSize: number;
|
||||
totalPoints: number;
|
||||
usedPoints: number;
|
||||
|
||||
standardMaxPoints: number;
|
||||
datasetMaxSize: number;
|
||||
usedDatasetSize: number;
|
||||
};
|
||||
|
Reference in New Issue
Block a user