mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
perf: rewrite type with zod
This commit is contained in:
parent
ead1617372
commit
34c48e8c0b
|
|
@ -313,12 +313,12 @@ import React, { useMemo } from 'react';
|
|||
import { type NodeProps } from 'reactflow';
|
||||
import { Box, Button } from '@chakra-ui/react';
|
||||
import NodeCard from './render/NodeCard';
|
||||
import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node.d';
|
||||
import { type FlowNodeItemType } from '@fastgpt/global/core/workflow/type/node';
|
||||
import Container from '../components/Container';
|
||||
import RenderInput from './render/RenderInput';
|
||||
import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d';
|
||||
import { type FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import IOTitle from '../components/IOTitle';
|
||||
import RenderOutput from './render/RenderOutput';
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export type GetPathProps = {
|
|||
};
|
||||
|
||||
export type ParentTreePathItemType = {
|
||||
parentId: string;
|
||||
parentId: ParentIdType;
|
||||
parentName: string;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
export type SecretValueType = {
|
||||
value: string;
|
||||
secret: string;
|
||||
};
|
||||
|
||||
export type StoreSecretValueType = Record<string, SecretValueType>;
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import z from 'zod';
|
||||
|
||||
export const SecretValueTypeSchema = z.object({
|
||||
value: z.string(),
|
||||
secret: z.string()
|
||||
});
|
||||
export type SecretValueType = z.infer<typeof SecretValueTypeSchema>;
|
||||
|
||||
export const StoreSecretValueTypeSchema = z.record(z.string(), SecretValueTypeSchema);
|
||||
export type StoreSecretValueType = z.infer<typeof StoreSecretValueTypeSchema>;
|
||||
|
|
@ -8,7 +8,7 @@ import type {
|
|||
AudioSpeechModels,
|
||||
STTModelType,
|
||||
RerankModelItemType
|
||||
} from '../../../core/ai/model.d';
|
||||
} from '../../../core/ai/model';
|
||||
import { SubTypeEnum } from '../../../support/wallet/sub/constants';
|
||||
|
||||
export type NavbarItemType = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { i18nT } from '../../../web/i18n/utils';
|
||||
import type { CompletionUsage } from './type';
|
||||
import type { LLMModelItemType, EmbeddingModelItemType, STTModelType } from './model';
|
||||
|
||||
export const getLLMDefaultUsage = (): CompletionUsage => {
|
||||
return {
|
||||
|
|
@ -9,6 +10,66 @@ export const getLLMDefaultUsage = (): CompletionUsage => {
|
|||
};
|
||||
};
|
||||
|
||||
export enum ModelTypeEnum {
|
||||
llm = 'llm',
|
||||
embedding = 'embedding',
|
||||
tts = 'tts',
|
||||
stt = 'stt',
|
||||
rerank = 'rerank'
|
||||
}
|
||||
|
||||
export const defaultQAModels: LLMModelItemType[] = [
|
||||
{
|
||||
type: ModelTypeEnum.llm,
|
||||
provider: 'OpenAI',
|
||||
model: 'gpt-5',
|
||||
name: 'gpt-5',
|
||||
maxContext: 16000,
|
||||
maxResponse: 16000,
|
||||
quoteMaxToken: 13000,
|
||||
maxTemperature: 1.2,
|
||||
charsPointsPrice: 0,
|
||||
censor: false,
|
||||
vision: true,
|
||||
datasetProcess: true,
|
||||
toolChoice: true,
|
||||
functionCall: false,
|
||||
defaultSystemChatPrompt: '',
|
||||
defaultConfig: {}
|
||||
}
|
||||
];
|
||||
|
||||
export const defaultVectorModels: EmbeddingModelItemType[] = [
|
||||
{
|
||||
type: ModelTypeEnum.embedding,
|
||||
provider: 'OpenAI',
|
||||
model: 'text-embedding-3-small',
|
||||
name: 'Embedding-2',
|
||||
charsPointsPrice: 0,
|
||||
defaultToken: 500,
|
||||
maxToken: 3000,
|
||||
weight: 100
|
||||
}
|
||||
];
|
||||
|
||||
export const defaultSTTModels: STTModelType[] = [
|
||||
{
|
||||
type: ModelTypeEnum.stt,
|
||||
provider: 'OpenAI',
|
||||
model: 'whisper-1',
|
||||
name: 'whisper-1',
|
||||
charsPointsPrice: 0
|
||||
}
|
||||
];
|
||||
|
||||
export const modelTypeList = [
|
||||
{ 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.reRank'), value: ModelTypeEnum.rerank }
|
||||
];
|
||||
|
||||
export enum ChatCompletionRequestMessageRoleEnum {
|
||||
'System' = 'system',
|
||||
'User' = 'user',
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
import type { ModelTypeEnum } from './model';
|
||||
|
||||
type PriceType = {
|
||||
charsPointsPrice?: number; // 1k chars=n points; 60s=n points;
|
||||
|
||||
// If inputPrice is set, the input-output charging scheme is adopted
|
||||
inputPrice?: number; // 1k tokens=n points
|
||||
outputPrice?: number; // 1k tokens=n points
|
||||
};
|
||||
type BaseModelItemType = {
|
||||
provider: string;
|
||||
model: string;
|
||||
name: string;
|
||||
avatar?: string; // model icon, from provider
|
||||
|
||||
isActive?: boolean;
|
||||
isCustom?: boolean;
|
||||
isDefault?: boolean;
|
||||
isDefaultDatasetTextModel?: boolean;
|
||||
isDefaultDatasetImageModel?: boolean;
|
||||
|
||||
// If has requestUrl, it will request the model directly
|
||||
requestUrl?: string;
|
||||
requestAuth?: string;
|
||||
};
|
||||
|
||||
export type LLMModelItemType = PriceType &
|
||||
BaseModelItemType & {
|
||||
type: ModelTypeEnum.llm;
|
||||
// Model params
|
||||
maxContext: number;
|
||||
maxResponse: number;
|
||||
quoteMaxToken: number;
|
||||
maxTemperature?: number;
|
||||
|
||||
showTopP?: boolean;
|
||||
responseFormatList?: string[];
|
||||
showStopSign?: boolean;
|
||||
|
||||
censor?: boolean;
|
||||
vision?: boolean;
|
||||
reasoning?: boolean;
|
||||
|
||||
// diff function model
|
||||
datasetProcess?: boolean; // dataset
|
||||
usedInClassify?: boolean; // classify
|
||||
usedInExtractFields?: boolean; // extract fields
|
||||
usedInToolCall?: boolean; // tool call
|
||||
useInEvaluation?: boolean; // evaluation
|
||||
|
||||
functionCall: boolean;
|
||||
toolChoice: boolean;
|
||||
|
||||
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
|
||||
normalization?: boolean; // normalization processing
|
||||
batchSize?: number;
|
||||
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,62 +1,112 @@
|
|||
import { i18nT } from '../../../web/i18n/utils';
|
||||
import type { LLMModelItemType, STTModelType, EmbeddingModelItemType } from './model.d';
|
||||
import { ModelTypeEnum } from './constants';
|
||||
import z from 'zod';
|
||||
|
||||
export enum ModelTypeEnum {
|
||||
llm = 'llm',
|
||||
embedding = 'embedding',
|
||||
tts = 'tts',
|
||||
stt = 'stt',
|
||||
rerank = 'rerank'
|
||||
}
|
||||
const PriceTypeSchema = z.object({
|
||||
charsPointsPrice: z.number().optional(), // 1k chars=n points; 60s=n points;
|
||||
// If inputPrice is set, the input-output charging scheme is adopted
|
||||
inputPrice: z.number().optional(), // 1k tokens=n points
|
||||
outputPrice: z.number().optional() // 1k tokens=n points
|
||||
});
|
||||
type PriceType = z.infer<typeof PriceTypeSchema>;
|
||||
|
||||
export const defaultQAModels: LLMModelItemType[] = [
|
||||
{
|
||||
type: ModelTypeEnum.llm,
|
||||
provider: 'OpenAI',
|
||||
model: 'gpt-5',
|
||||
name: 'gpt-5',
|
||||
maxContext: 16000,
|
||||
maxResponse: 16000,
|
||||
quoteMaxToken: 13000,
|
||||
maxTemperature: 1.2,
|
||||
charsPointsPrice: 0,
|
||||
censor: false,
|
||||
vision: true,
|
||||
datasetProcess: true,
|
||||
toolChoice: true,
|
||||
functionCall: false,
|
||||
defaultSystemChatPrompt: '',
|
||||
defaultConfig: {}
|
||||
}
|
||||
];
|
||||
const BaseModelItemSchema = z.object({
|
||||
provider: z.string(),
|
||||
model: z.string(),
|
||||
name: z.string(),
|
||||
avatar: z.string().optional(), // model icon, from provider
|
||||
|
||||
export const defaultVectorModels: EmbeddingModelItemType[] = [
|
||||
{
|
||||
type: ModelTypeEnum.embedding,
|
||||
provider: 'OpenAI',
|
||||
model: 'text-embedding-3-small',
|
||||
name: 'Embedding-2',
|
||||
charsPointsPrice: 0,
|
||||
defaultToken: 500,
|
||||
maxToken: 3000,
|
||||
weight: 100
|
||||
}
|
||||
];
|
||||
isActive: z.boolean().optional(),
|
||||
isCustom: z.boolean().optional(),
|
||||
isDefault: z.boolean().optional(),
|
||||
isDefaultDatasetTextModel: z.boolean().optional(),
|
||||
isDefaultDatasetImageModel: z.boolean().optional(),
|
||||
|
||||
export const defaultSTTModels: STTModelType[] = [
|
||||
{
|
||||
type: ModelTypeEnum.stt,
|
||||
provider: 'OpenAI',
|
||||
model: 'whisper-1',
|
||||
name: 'whisper-1',
|
||||
charsPointsPrice: 0
|
||||
}
|
||||
];
|
||||
// If has requestUrl, it will request the model directly
|
||||
requestUrl: z.string().optional(),
|
||||
requestAuth: z.string().optional()
|
||||
});
|
||||
type BaseModelItemType = z.infer<typeof BaseModelItemSchema>;
|
||||
|
||||
export const modelTypeList = [
|
||||
{ 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.reRank'), value: ModelTypeEnum.rerank }
|
||||
];
|
||||
export const LLMModelItemSchema = PriceTypeSchema.and(BaseModelItemSchema).and(
|
||||
z.object({
|
||||
type: z.literal(ModelTypeEnum.llm),
|
||||
// Model params
|
||||
maxContext: z.number(),
|
||||
maxResponse: z.number(),
|
||||
quoteMaxToken: z.number(),
|
||||
maxTemperature: z.number().optional(),
|
||||
|
||||
showTopP: z.boolean().optional(),
|
||||
responseFormatList: z.array(z.string()).optional(),
|
||||
showStopSign: z.boolean().optional(),
|
||||
|
||||
censor: z.boolean().optional(),
|
||||
vision: z.boolean().optional(),
|
||||
reasoning: z.boolean().optional(),
|
||||
|
||||
// diff function model
|
||||
datasetProcess: z.boolean().optional(), // dataset
|
||||
usedInClassify: z.boolean().optional(), // classify
|
||||
usedInExtractFields: z.boolean().optional(), // extract fields
|
||||
usedInToolCall: z.boolean().optional(), // tool call
|
||||
useInEvaluation: z.boolean().optional(), // evaluation
|
||||
|
||||
functionCall: z.boolean(),
|
||||
toolChoice: z.boolean(),
|
||||
|
||||
defaultSystemChatPrompt: z.string().optional(),
|
||||
defaultConfig: z.record(z.string(), z.any()).optional(),
|
||||
fieldMap: z.record(z.string(), z.string()).optional()
|
||||
})
|
||||
);
|
||||
export type LLMModelItemType = z.infer<typeof LLMModelItemSchema>;
|
||||
|
||||
export const EmbeddingModelItemSchema = PriceTypeSchema.and(BaseModelItemSchema).and(
|
||||
z.object({
|
||||
type: z.literal(ModelTypeEnum.embedding),
|
||||
defaultToken: z.number(), // split text default token
|
||||
maxToken: z.number(), // model max token
|
||||
weight: z.number(), // training weight
|
||||
hidden: z.boolean().optional(), // Disallow creation
|
||||
normalization: z.boolean().optional(), // normalization processing
|
||||
batchSize: z.number().optional(), // batch request size
|
||||
defaultConfig: z.record(z.string(), z.any()).optional(), // post request config
|
||||
dbConfig: z.record(z.string(), z.any()).optional(), // Custom parameters for storage
|
||||
queryConfig: z.record(z.string(), z.any()).optional() // Custom parameters for query
|
||||
})
|
||||
);
|
||||
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
|
||||
normalization?: boolean; // normalization processing
|
||||
batchSize?: number;
|
||||
defaultConfig?: Record<string, any>; // post request config
|
||||
dbConfig?: Record<string, any>; // Custom parameters for storage
|
||||
queryConfig?: Record<string, any>; // Custom parameters for query
|
||||
};
|
||||
|
||||
export const RerankModelItemSchema = PriceTypeSchema.and(BaseModelItemSchema).and(
|
||||
z.object({
|
||||
type: z.literal(ModelTypeEnum.rerank)
|
||||
})
|
||||
);
|
||||
export type RerankModelItemType = z.infer<typeof RerankModelItemSchema>;
|
||||
|
||||
export const TTSModelItemSchema = PriceTypeSchema.and(BaseModelItemSchema).and(
|
||||
z.object({
|
||||
type: z.literal(ModelTypeEnum.tts),
|
||||
voices: z.array(z.object({ label: z.string(), value: z.string() }))
|
||||
})
|
||||
);
|
||||
export type TTSModelType = z.infer<typeof TTSModelItemSchema>;
|
||||
|
||||
export const STTModelItemSchema = PriceTypeSchema.and(BaseModelItemSchema).and(
|
||||
z.object({
|
||||
type: z.literal(ModelTypeEnum.stt)
|
||||
})
|
||||
);
|
||||
export type STTModelType = z.infer<typeof STTModelItemSchema>;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { type PromptTemplateItem } from '../type.d';
|
||||
import { type PromptTemplateItem } from '../type';
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
import { getPromptByVersion } from './utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
import openai from 'openai';
|
||||
import type {
|
||||
ChatCompletionMessageToolCall,
|
||||
ChatCompletionMessageParam as SdkChatCompletionMessageParam,
|
||||
ChatCompletionMessageParam as OpenaiChatCompletionMessageParam,
|
||||
ChatCompletionContentPart as SdkChatCompletionContentPart,
|
||||
ChatCompletionUserMessageParam as SdkChatCompletionUserMessageParam,
|
||||
ChatCompletionToolMessageParam as SdkChatCompletionToolMessageParam,
|
||||
ChatCompletionAssistantMessageParam as SdkChatCompletionAssistantMessageParam,
|
||||
ChatCompletionTool
|
||||
ChatCompletionAssistantMessageParam as SdkChatCompletionAssistantMessageParam
|
||||
} from 'openai/resources';
|
||||
import { ChatMessageTypeEnum } from './constants';
|
||||
import type { WorkflowInteractiveResponseType } from '../workflow/template/system/interactive/type';
|
||||
import type { Stream } from 'openai/streaming';
|
||||
export * from 'openai/resources';
|
||||
|
|
@ -24,7 +22,7 @@ export type ChatCompletionContentPartFile = {
|
|||
export type ChatCompletionContentPart =
|
||||
| (SdkChatCompletionContentPart & { key?: string })
|
||||
| ChatCompletionContentPartFile;
|
||||
type CustomChatCompletionUserMessageParam = Omit<ChatCompletionUserMessageParam, 'content'> & {
|
||||
type CustomChatCompletionUserMessageParam = Omit<SdkChatCompletionUserMessageParam, 'content'> & {
|
||||
role: 'user';
|
||||
content: string | Array<ChatCompletionContentPart>;
|
||||
};
|
||||
|
|
@ -52,7 +50,7 @@ export type ChatCompletionMessageParam = (
|
|||
dataId?: string;
|
||||
hideInUI?: boolean;
|
||||
};
|
||||
export type SdkChatCompletionMessageParam = SdkChatCompletionMessageParam;
|
||||
export type SdkChatCompletionMessageParam = OpenaiChatCompletionMessageParam;
|
||||
|
||||
/* ToolChoice and functionCall extension */
|
||||
export type ChatCompletionAssistantToolParam = {
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
import { ObjectIdSchema } from '../../../../global/common/type/mongo';
|
||||
import { z } from 'zod';
|
||||
|
||||
export type AgentSubAppItemType = {};
|
||||
|
||||
/* ===== Dataset ==== */
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import type { ParentIdType } from 'common/parentFolder/type';
|
||||
import type { AppSchema } from './type';
|
||||
import type { AppSchemaType } from './type';
|
||||
import type { AppTypeEnum } from './constants';
|
||||
|
||||
export type CreateAppProps = {
|
||||
|
|
@ -8,16 +8,16 @@ export type CreateAppProps = {
|
|||
avatar?: string;
|
||||
intro?: string;
|
||||
type?: AppTypeEnum;
|
||||
modules: AppSchema['modules'];
|
||||
edges?: AppSchema['edges'];
|
||||
modules: AppSchemaType['modules'];
|
||||
edges?: AppSchemaType['edges'];
|
||||
};
|
||||
export type CreateHttpPluginChildrenPros = Omit<CreateAppProps, 'type'> & {
|
||||
parentId: ParentIdType;
|
||||
name: string;
|
||||
intro: string;
|
||||
avatar: string;
|
||||
modules: AppSchema['modules'];
|
||||
edges: AppSchema['edges'];
|
||||
modules: AppSchemaType['modules'];
|
||||
edges: AppSchemaType['edges'];
|
||||
pluginData: {
|
||||
pluginUniId: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
import { SelectedDatasetSchema } from '../../workflow/type/io';
|
||||
import { z } from 'zod';
|
||||
import {
|
||||
AppChatConfigTypeSchema,
|
||||
AppDatasetSearchParamsTypeSchema,
|
||||
AppFileSelectConfigTypeSchema
|
||||
} from '../type';
|
||||
import { FlowNodeTemplateTypeSchema } from '../../workflow/type/node';
|
||||
import { NodeInputKeyEnum } from '../../workflow/constants';
|
||||
|
||||
export type AgentSubAppItemType = {};
|
||||
|
||||
/* ===== Tool ===== */
|
||||
export const SelectedToolItemTypeSchema = FlowNodeTemplateTypeSchema.and(
|
||||
z.object({
|
||||
configStatus: z.enum(['active', 'waitingForConfig', 'invalid']).optional()
|
||||
})
|
||||
);
|
||||
export type SelectedToolItemType = z.infer<typeof SelectedToolItemTypeSchema>;
|
||||
|
||||
/* ===== skill ===== */
|
||||
export const SkillEditTypeSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
prompt: z.string(),
|
||||
dataset: z.object({
|
||||
list: z.array(SelectedDatasetSchema)
|
||||
}),
|
||||
selectedTools: z.array(SelectedToolItemTypeSchema),
|
||||
fileSelectConfig: AppFileSelectConfigTypeSchema
|
||||
});
|
||||
export type SkillEditType = z.infer<typeof SkillEditTypeSchema>;
|
||||
|
||||
export const AppFormEditFormV1TypeSchema = z.object({
|
||||
aiSettings: z.object({
|
||||
[NodeInputKeyEnum.aiModel]: z.string(),
|
||||
[NodeInputKeyEnum.aiSystemPrompt]: z.string().optional(),
|
||||
[NodeInputKeyEnum.aiRole]: z.string().optional(),
|
||||
[NodeInputKeyEnum.aiTaskObject]: z.string().optional(),
|
||||
|
||||
[NodeInputKeyEnum.aiChatTemperature]: z.number().optional(),
|
||||
[NodeInputKeyEnum.aiChatMaxToken]: z.number().optional(),
|
||||
[NodeInputKeyEnum.aiChatIsResponseText]: z.boolean(),
|
||||
maxHistories: z.int().min(0).max(100),
|
||||
[NodeInputKeyEnum.aiChatReasoning]: z.boolean().optional(),
|
||||
[NodeInputKeyEnum.aiChatTopP]: z.number().optional(),
|
||||
[NodeInputKeyEnum.aiChatStopSign]: z.string().optional(),
|
||||
[NodeInputKeyEnum.aiChatResponseFormat]: z.string().optional(),
|
||||
[NodeInputKeyEnum.aiChatJsonSchema]: z.string().optional()
|
||||
}),
|
||||
dataset: AppDatasetSearchParamsTypeSchema.and(
|
||||
z.object({
|
||||
datasets: z.array(SelectedDatasetSchema)
|
||||
})
|
||||
),
|
||||
selectedTools: z.array(SelectedToolItemTypeSchema),
|
||||
skills: z.array(SkillEditTypeSchema),
|
||||
chatConfig: AppChatConfigTypeSchema
|
||||
});
|
||||
export type AppFormEditFormType = z.infer<typeof AppFormEditFormV1TypeSchema>;
|
||||
|
|
@ -6,27 +6,42 @@ import yaml from 'js-yaml';
|
|||
import type { OpenAPIV3 } from 'openapi-types';
|
||||
import type { OpenApiJsonSchema } from './tool/httpTool/type';
|
||||
import { i18nT } from '../../../web/i18n/utils';
|
||||
import z from 'zod';
|
||||
|
||||
type SchemaInputValueType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
||||
export type JsonSchemaPropertiesItemType = {
|
||||
description?: string;
|
||||
'x-tool-description'?: string;
|
||||
type: SchemaInputValueType;
|
||||
enum?: string[];
|
||||
minimum?: number;
|
||||
maximum?: number;
|
||||
items?: { type: SchemaInputValueType };
|
||||
};
|
||||
export type JSONSchemaInputType = {
|
||||
type: SchemaInputValueType;
|
||||
properties?: Record<string, JsonSchemaPropertiesItemType>;
|
||||
required?: string[];
|
||||
};
|
||||
export type JSONSchemaOutputType = {
|
||||
type: SchemaInputValueType;
|
||||
properties?: Record<string, JsonSchemaPropertiesItemType>;
|
||||
required?: string[];
|
||||
};
|
||||
const SchemaInputValueTypeSchema = z.enum([
|
||||
'string',
|
||||
'number',
|
||||
'integer',
|
||||
'boolean',
|
||||
'array',
|
||||
'object'
|
||||
]);
|
||||
type SchemaInputValueType = z.infer<typeof SchemaInputValueTypeSchema>;
|
||||
|
||||
export const JsonSchemaPropertiesItemSchema = z.object({
|
||||
description: z.string().optional(),
|
||||
'x-tool-description': z.string().optional(),
|
||||
type: SchemaInputValueTypeSchema,
|
||||
enum: z.array(z.string()).optional(),
|
||||
minimum: z.number().optional(),
|
||||
maximum: z.number().optional(),
|
||||
items: z.object({ type: SchemaInputValueTypeSchema }).optional()
|
||||
});
|
||||
export type JsonSchemaPropertiesItemType = z.infer<typeof JsonSchemaPropertiesItemSchema>;
|
||||
|
||||
export const JSONSchemaInputTypeSchema = z.object({
|
||||
type: SchemaInputValueTypeSchema,
|
||||
properties: z.record(z.string(), JsonSchemaPropertiesItemSchema).optional(),
|
||||
required: z.array(z.string()).optional()
|
||||
});
|
||||
export type JSONSchemaInputType = z.infer<typeof JSONSchemaInputTypeSchema>;
|
||||
|
||||
export const JSONSchemaOutputTypeSchema = z.object({
|
||||
type: SchemaInputValueTypeSchema,
|
||||
properties: z.record(z.string(), JsonSchemaPropertiesItemSchema).optional(),
|
||||
required: z.array(z.string()).optional()
|
||||
});
|
||||
export type JSONSchemaOutputType = z.infer<typeof JSONSchemaOutputTypeSchema>;
|
||||
|
||||
export const getNodeInputTypeFromSchemaInputType = ({
|
||||
type,
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
type PathDataType = {
|
||||
name: string;
|
||||
description: string;
|
||||
method: string;
|
||||
path: string;
|
||||
params: any[];
|
||||
request: any;
|
||||
response: any;
|
||||
};
|
||||
|
||||
export type OpenApiJsonSchema = {
|
||||
pathData: PathDataType[];
|
||||
serverPath: string;
|
||||
};
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
import { StoreSecretValueTypeSchema } from '../../../../common/secret/type';
|
||||
import { JSONSchemaInputTypeSchema, JSONSchemaOutputTypeSchema } from '../../jsonschema';
|
||||
import { ContentTypes } from '../../../workflow/constants';
|
||||
import z from 'zod';
|
||||
|
||||
const PathDataTypeSchema = z.object({
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
method: z.string(),
|
||||
path: z.string(),
|
||||
params: z.array(z.any()),
|
||||
request: z.any(),
|
||||
response: z.any()
|
||||
});
|
||||
export type PathDataType = z.infer<typeof PathDataTypeSchema>;
|
||||
|
||||
export const OpenApiJsonSchemaSchema = z.object({
|
||||
pathData: z.array(PathDataTypeSchema),
|
||||
serverPath: z.string()
|
||||
});
|
||||
export type OpenApiJsonSchema = z.infer<typeof OpenApiJsonSchemaSchema>;
|
||||
|
||||
export const HttpToolConfigTypeSchema = z.object({
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
inputSchema: JSONSchemaInputTypeSchema,
|
||||
outputSchema: JSONSchemaOutputTypeSchema,
|
||||
path: z.string(),
|
||||
method: z.string(),
|
||||
|
||||
// manual
|
||||
staticParams: z.array(z.object({ key: z.string(), value: z.string() })).optional(),
|
||||
staticHeaders: z.array(z.object({ key: z.string(), value: z.string() })).optional(),
|
||||
staticBody: z
|
||||
.object({
|
||||
type: z.enum(ContentTypes),
|
||||
content: z.string().optional(),
|
||||
formData: z.array(z.object({ key: z.string(), value: z.string() })).optional()
|
||||
})
|
||||
.optional(),
|
||||
headerSecret: StoreSecretValueTypeSchema.optional()
|
||||
});
|
||||
export type HttpToolConfigType = z.infer<typeof HttpToolConfigTypeSchema>;
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
import { getNanoid } from '../../../../common/string/tools';
|
||||
import type { PathDataType } from './type';
|
||||
import type { PathDataType, HttpToolConfigType } from './type';
|
||||
import { type RuntimeNodeItemType } from '../../../workflow/runtime/type';
|
||||
import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '../../../workflow/node/constant';
|
||||
import { type HttpToolConfigType } from '../../type';
|
||||
import { AppToolSourceEnum } from '../constants';
|
||||
import { jsonSchema2NodeInput, jsonSchema2NodeOutput } from '../../jsonschema';
|
||||
import { type StoreSecretValueType } from '../../../../common/secret/type';
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
import type { StoreSecretValueType } from '../../../../common/secret/type';
|
||||
import type { JSONSchemaInputType } from '../../jsonschema';
|
||||
|
||||
export type McpToolConfigType = {
|
||||
name: string;
|
||||
description: string;
|
||||
inputSchema: JSONSchemaInputType;
|
||||
};
|
||||
|
||||
export type McpToolSetDataType = {
|
||||
url: string;
|
||||
headerSecret?: StoreSecretValueType;
|
||||
toolList: McpToolConfigType[];
|
||||
};
|
||||
|
||||
export type McpToolDataType = McpToolConfigType & {
|
||||
url: string;
|
||||
headerSecret?: StoreSecretValueType;
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import { SecretValueTypeSchema } from '../../../../common/secret/type';
|
||||
import { JSONSchemaInputTypeSchema } from '../../jsonschema';
|
||||
import z from 'zod';
|
||||
|
||||
export const McpToolConfigSchema = z.object({
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
inputSchema: JSONSchemaInputTypeSchema
|
||||
});
|
||||
export type McpToolConfigType = z.infer<typeof McpToolConfigSchema>;
|
||||
|
||||
export const McpToolSetDataTypeSchema = z.object({
|
||||
url: z.string(),
|
||||
headerSecret: SecretValueTypeSchema.optional(),
|
||||
toolList: z.array(McpToolConfigSchema)
|
||||
});
|
||||
export type McpToolSetDataType = z.infer<typeof McpToolSetDataTypeSchema>;
|
||||
|
||||
export const McpToolDataTypeSchema = McpToolConfigSchema.and(
|
||||
z.object({
|
||||
url: z.string(),
|
||||
headerSecret: SecretValueTypeSchema.optional()
|
||||
})
|
||||
);
|
||||
export type McpToolDataType = z.infer<typeof McpToolDataTypeSchema>;
|
||||
|
|
@ -1,274 +0,0 @@
|
|||
import type { FlowNodeTemplateType, StoreNodeItemType } from '../workflow/type/node';
|
||||
import type { AppTypeEnum } from './constants';
|
||||
import { PermissionTypeEnum } from '../../support/permission/constant';
|
||||
import type {
|
||||
ContentTypes,
|
||||
NodeInputKeyEnum,
|
||||
VariableInputEnum,
|
||||
WorkflowIOValueTypeEnum
|
||||
} from '../workflow/constants';
|
||||
import type { InputComponentPropsType, SelectedDatasetType } from '../workflow/type/io';
|
||||
import type { DatasetSearchModeEnum } from '../dataset/constants';
|
||||
import { TeamTagSchema as TeamTagsSchemaType } from '@fastgpt/global/support/user/team/type.d';
|
||||
import type { StoreEdgeItemType } from '../workflow/type/edge';
|
||||
import type { AppPermission } from '../../support/permission/app/controller';
|
||||
import type { ParentIdType } from '../../common/parentFolder/type';
|
||||
import { FlowNodeInputTypeEnum } from '../../core/workflow/node/constant';
|
||||
import type { WorkflowTemplateBasicType } from '@fastgpt/global/core/workflow/type';
|
||||
import type { SourceMemberType } from '../../support/user/type';
|
||||
import type { JSONSchemaInputType, JSONSchemaOutputType } from './jsonschema';
|
||||
|
||||
export type AppSchema = {
|
||||
_id: string;
|
||||
parentId?: ParentIdType;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
type: AppTypeEnum;
|
||||
version?: 'v1' | 'v2';
|
||||
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
templateId?: string; // Create by template
|
||||
|
||||
updateTime: Date;
|
||||
|
||||
modules: StoreNodeItemType[];
|
||||
edges: StoreEdgeItemType[];
|
||||
pluginData?: {
|
||||
nodeVersion?: string;
|
||||
pluginUniId?: string; // plugin unique id(plugin name)
|
||||
apiSchemaStr?: string; // api schema string
|
||||
customHeaders?: string;
|
||||
};
|
||||
|
||||
// App system config
|
||||
chatConfig: AppChatConfigType;
|
||||
scheduledTriggerConfig?: AppScheduledTriggerConfigType | null;
|
||||
scheduledTriggerNextTime?: Date;
|
||||
|
||||
inheritPermission?: boolean;
|
||||
|
||||
// if access the app by favourite or quick
|
||||
favourite?: boolean;
|
||||
quick?: boolean;
|
||||
|
||||
/** @deprecated */
|
||||
defaultPermission?: number;
|
||||
/** @deprecated */
|
||||
inited?: boolean;
|
||||
/** @deprecated */
|
||||
teamTags: string[];
|
||||
|
||||
// 软删除字段
|
||||
deleteTime?: Date | null;
|
||||
};
|
||||
|
||||
export type AppListItemType = {
|
||||
_id: string;
|
||||
parentId: ParentIdType;
|
||||
tmbId: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
type: AppTypeEnum;
|
||||
updateTime: Date;
|
||||
pluginData?: AppSchema['pluginData'];
|
||||
permission: AppPermission;
|
||||
inheritPermission?: boolean;
|
||||
private?: boolean;
|
||||
sourceMember: SourceMemberType;
|
||||
hasInteractiveNode?: boolean;
|
||||
};
|
||||
|
||||
export type AppDetailType = AppSchema & {
|
||||
permission: AppPermission;
|
||||
};
|
||||
|
||||
export type AppDatasetSearchParamsType = {
|
||||
searchMode: `${DatasetSearchModeEnum}`;
|
||||
limit?: number; // limit max tokens
|
||||
similarity?: number;
|
||||
embeddingWeight?: number; // embedding weight, fullText weight = 1 - embeddingWeight
|
||||
|
||||
usingReRank?: boolean;
|
||||
rerankModel?: string;
|
||||
rerankWeight?: number;
|
||||
|
||||
datasetSearchUsingExtensionQuery?: boolean;
|
||||
datasetSearchExtensionModel?: string;
|
||||
datasetSearchExtensionBg?: string;
|
||||
};
|
||||
|
||||
/* ===== skill ===== */
|
||||
export type SkillEditType = {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
prompt: string;
|
||||
dataset: {
|
||||
list: SelectedDatasetType[];
|
||||
};
|
||||
selectedTools: SelectedToolItemType[];
|
||||
fileSelectConfig: AppFileSelectConfigType;
|
||||
};
|
||||
|
||||
export type SelectedToolItemType = FlowNodeTemplateType & {
|
||||
configStatus?: 'active' | 'waitingForConfig' | 'invalid';
|
||||
};
|
||||
export type AppFormEditFormType = {
|
||||
// templateId: string;
|
||||
aiSettings: {
|
||||
[NodeInputKeyEnum.aiModel]: string;
|
||||
[NodeInputKeyEnum.aiSystemPrompt]?: string | undefined;
|
||||
[NodeInputKeyEnum.aiRole]?: string | undefined;
|
||||
[NodeInputKeyEnum.aiTaskObject]?: string | undefined;
|
||||
|
||||
[NodeInputKeyEnum.aiChatTemperature]?: number;
|
||||
[NodeInputKeyEnum.aiChatMaxToken]?: number;
|
||||
[NodeInputKeyEnum.aiChatIsResponseText]: boolean;
|
||||
maxHistories: number;
|
||||
[NodeInputKeyEnum.aiChatReasoning]?: boolean; // Is open reasoning mode
|
||||
[NodeInputKeyEnum.aiChatTopP]?: number;
|
||||
[NodeInputKeyEnum.aiChatStopSign]?: string;
|
||||
[NodeInputKeyEnum.aiChatResponseFormat]?: string;
|
||||
[NodeInputKeyEnum.aiChatJsonSchema]?: string;
|
||||
};
|
||||
dataset: {
|
||||
datasets: SelectedDatasetType[];
|
||||
} & AppDatasetSearchParamsType;
|
||||
selectedTools: SelectedToolItemType[];
|
||||
chatConfig: AppChatConfigType;
|
||||
skills: SkillEditType[];
|
||||
};
|
||||
|
||||
export type HttpToolConfigType = {
|
||||
name: string;
|
||||
description: string;
|
||||
inputSchema: JSONSchemaInputType;
|
||||
outputSchema: JSONSchemaOutputType;
|
||||
path: string;
|
||||
method: string;
|
||||
|
||||
// manual
|
||||
staticParams?: Array<{ key: string; value: string }>;
|
||||
staticHeaders?: Array<{ key: string; value: string }>;
|
||||
staticBody?: {
|
||||
type: ContentTypes;
|
||||
content?: string;
|
||||
formData?: Array<{ key: string; value: string }>;
|
||||
};
|
||||
headerSecret?: StoreSecretValueType;
|
||||
};
|
||||
|
||||
/* app chat config type */
|
||||
export type AppChatConfigType = {
|
||||
welcomeText?: string;
|
||||
variables?: VariableItemType[];
|
||||
autoExecute?: AppAutoExecuteConfigType;
|
||||
questionGuide?: AppQGConfigType;
|
||||
ttsConfig?: AppTTSConfigType;
|
||||
whisperConfig?: AppWhisperConfigType;
|
||||
scheduledTriggerConfig?: AppScheduledTriggerConfigType;
|
||||
chatInputGuide?: ChatInputGuideConfigType;
|
||||
fileSelectConfig?: AppFileSelectConfigType;
|
||||
|
||||
// plugin
|
||||
instruction?: string;
|
||||
};
|
||||
export type SettingAIDataType = {
|
||||
model: string;
|
||||
temperature?: number;
|
||||
maxToken?: number;
|
||||
isResponseAnswerText?: boolean;
|
||||
maxHistories?: number;
|
||||
[NodeInputKeyEnum.aiChatVision]?: boolean; // Is open vision mode
|
||||
[NodeInputKeyEnum.aiChatReasoning]?: boolean; // Is open reasoning mode
|
||||
[NodeInputKeyEnum.aiChatTopP]?: number;
|
||||
[NodeInputKeyEnum.aiChatStopSign]?: string;
|
||||
[NodeInputKeyEnum.aiChatResponseFormat]?: string;
|
||||
[NodeInputKeyEnum.aiChatJsonSchema]?: string;
|
||||
};
|
||||
|
||||
// variable
|
||||
export type VariableItemType = AppFileSelectConfigType &
|
||||
InputComponentPropsType & {
|
||||
type: VariableInputEnum;
|
||||
description: string;
|
||||
};
|
||||
// tts
|
||||
export type AppTTSConfigType = {
|
||||
type: 'none' | 'web' | 'model';
|
||||
model?: string;
|
||||
voice?: string;
|
||||
speed?: number;
|
||||
};
|
||||
// whisper
|
||||
export type AppWhisperConfigType = {
|
||||
open: boolean;
|
||||
autoSend: boolean;
|
||||
autoTTSResponse: boolean;
|
||||
};
|
||||
|
||||
// question guide
|
||||
export type AppQGConfigType = {
|
||||
open: boolean;
|
||||
model?: string;
|
||||
customPrompt?: string;
|
||||
};
|
||||
|
||||
// question guide text
|
||||
export type ChatInputGuideConfigType = {
|
||||
open: boolean;
|
||||
customUrl: string;
|
||||
};
|
||||
// interval timer
|
||||
export type AppScheduledTriggerConfigType = {
|
||||
cronString: string;
|
||||
timezone: string;
|
||||
defaultPrompt: string;
|
||||
};
|
||||
// auto execute
|
||||
export type AppAutoExecuteConfigType = {
|
||||
open: boolean;
|
||||
defaultPrompt: string;
|
||||
};
|
||||
// File
|
||||
export type AppFileSelectConfigType = {
|
||||
maxFiles?: number;
|
||||
canSelectFile?: boolean;
|
||||
customPdfParse?: boolean;
|
||||
canSelectImg?: boolean;
|
||||
canSelectVideo?: boolean;
|
||||
canSelectAudio?: boolean;
|
||||
canSelectCustomFileExtension?: boolean;
|
||||
customFileExtensionList?: string[];
|
||||
};
|
||||
|
||||
export type AppTemplateSchemaType = {
|
||||
templateId: string;
|
||||
name: string;
|
||||
intro: string;
|
||||
avatar: string;
|
||||
tags: string[];
|
||||
type: string;
|
||||
author?: string;
|
||||
isActive?: boolean;
|
||||
isPromoted?: boolean;
|
||||
recommendText?: string;
|
||||
userGuide?: {
|
||||
type: 'markdown' | 'link';
|
||||
content?: string;
|
||||
link?: string;
|
||||
};
|
||||
isQuickTemplate?: boolean;
|
||||
order?: number;
|
||||
// TODO: 对于建议应用,是另一个格式
|
||||
workflow: WorkflowTemplateBasicType;
|
||||
};
|
||||
|
||||
export type TemplateTypeSchemaType = {
|
||||
typeName: string;
|
||||
typeId: string;
|
||||
typeOrder: number;
|
||||
};
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
import { StoreNodeItemTypeSchema } from '../workflow/type/node';
|
||||
import { AppTypeEnum } from './constants';
|
||||
import type { NodeInputKeyEnum } from '../workflow/constants';
|
||||
import { VariableInputEnum } from '../workflow/constants';
|
||||
import { InputComponentPropsTypeSchema } from '../workflow/type/io';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constants';
|
||||
import { StoreEdgeItemTypeSchema } from '../workflow/type/edge';
|
||||
import type { AppPermission } from '../../support/permission/app/controller';
|
||||
import { ParentIdSchema, type ParentIdType } from '../../common/parentFolder/type';
|
||||
import type { WorkflowTemplateBasicType } from '../workflow/type';
|
||||
import type { SourceMemberType } from '../../support/user/type';
|
||||
import z from 'zod';
|
||||
import { ObjectIdSchema } from '../../common/type/mongo';
|
||||
|
||||
/* app chat config type */
|
||||
// File
|
||||
export const AppFileSelectConfigTypeSchema = z.object({
|
||||
maxFiles: z.number().optional(),
|
||||
canSelectFile: z.boolean().optional(),
|
||||
customPdfParse: z.boolean().optional(),
|
||||
canSelectImg: z.boolean().optional(),
|
||||
canSelectVideo: z.boolean().optional(),
|
||||
canSelectAudio: z.boolean().optional(),
|
||||
canSelectCustomFileExtension: z.boolean().optional(),
|
||||
customFileExtensionList: z.array(z.string()).optional()
|
||||
});
|
||||
export type AppFileSelectConfigType = z.infer<typeof AppFileSelectConfigTypeSchema>;
|
||||
|
||||
// variable
|
||||
export const VariableItemTypeSchema = AppFileSelectConfigTypeSchema.and(
|
||||
InputComponentPropsTypeSchema
|
||||
).and(
|
||||
z.object({
|
||||
type: z.enum(VariableInputEnum),
|
||||
description: z.string()
|
||||
})
|
||||
);
|
||||
export type VariableItemType = z.infer<typeof VariableItemTypeSchema>;
|
||||
|
||||
// tts
|
||||
export const AppTTSConfigTypeSchema = z.object({
|
||||
type: z.enum(['none', 'web', 'model']),
|
||||
model: z.string().optional(),
|
||||
voice: z.string().optional(),
|
||||
speed: z.number().optional()
|
||||
});
|
||||
export type AppTTSConfigType = z.infer<typeof AppTTSConfigTypeSchema>;
|
||||
|
||||
// whisper
|
||||
export const AppWhisperConfigTypeSchema = z.object({
|
||||
open: z.boolean(),
|
||||
autoSend: z.boolean(),
|
||||
autoTTSResponse: z.boolean()
|
||||
});
|
||||
export type AppWhisperConfigType = z.infer<typeof AppWhisperConfigTypeSchema>;
|
||||
|
||||
// question guide
|
||||
export const AppQGConfigTypeSchema = z.object({
|
||||
open: z.boolean(),
|
||||
model: z.string().optional(),
|
||||
customPrompt: z.string().optional()
|
||||
});
|
||||
export type AppQGConfigType = z.infer<typeof AppQGConfigTypeSchema>;
|
||||
|
||||
// question guide text
|
||||
export const ChatInputGuideConfigTypeSchema = z.object({
|
||||
open: z.boolean(),
|
||||
customUrl: z.string()
|
||||
});
|
||||
export type ChatInputGuideConfigType = z.infer<typeof ChatInputGuideConfigTypeSchema>;
|
||||
|
||||
// interval timer
|
||||
export const AppScheduledTriggerConfigTypeSchema = z.object({
|
||||
cronString: z.string(),
|
||||
timezone: z.string(),
|
||||
defaultPrompt: z.string()
|
||||
});
|
||||
export type AppScheduledTriggerConfigType = z.infer<typeof AppScheduledTriggerConfigTypeSchema>;
|
||||
|
||||
// auto execute
|
||||
export const AppAutoExecuteConfigTypeSchema = z.object({
|
||||
open: z.boolean(),
|
||||
defaultPrompt: z.string()
|
||||
});
|
||||
export type AppAutoExecuteConfigType = z.infer<typeof AppAutoExecuteConfigTypeSchema>;
|
||||
|
||||
export const AppChatConfigTypeSchema = z.object({
|
||||
welcomeText: z.string().optional(),
|
||||
variables: z.array(VariableItemTypeSchema).optional(),
|
||||
autoExecute: AppAutoExecuteConfigTypeSchema.optional(),
|
||||
questionGuide: AppQGConfigTypeSchema.optional(),
|
||||
ttsConfig: AppTTSConfigTypeSchema.optional(),
|
||||
whisperConfig: AppWhisperConfigTypeSchema.optional(),
|
||||
scheduledTriggerConfig: AppScheduledTriggerConfigTypeSchema.optional(),
|
||||
chatInputGuide: ChatInputGuideConfigTypeSchema.optional(),
|
||||
fileSelectConfig: AppFileSelectConfigTypeSchema.optional(),
|
||||
instruction: z.string().optional()
|
||||
});
|
||||
export type AppChatConfigType = z.infer<typeof AppChatConfigTypeSchema>;
|
||||
|
||||
// Mongo Collection
|
||||
export const AppSchemaTypeSchema = z.object({
|
||||
_id: ObjectIdSchema,
|
||||
parentId: ParentIdSchema.optional(),
|
||||
teamId: z.string(),
|
||||
tmbId: z.string(),
|
||||
type: z.enum(AppTypeEnum),
|
||||
version: z.enum(['v1', 'v2']).optional(),
|
||||
|
||||
name: z.string(),
|
||||
avatar: z.string(),
|
||||
intro: z.string(),
|
||||
templateId: z.string().optional(),
|
||||
|
||||
updateTime: z.date(),
|
||||
|
||||
modules: z.array(StoreNodeItemTypeSchema),
|
||||
edges: z.array(StoreEdgeItemTypeSchema),
|
||||
pluginData: z
|
||||
.object({
|
||||
nodeVersion: z.string().optional(),
|
||||
pluginUniId: z.string().optional(), // plugin unique id(plugin name)
|
||||
apiSchemaStr: z.string().optional(), // api schema string
|
||||
customHeaders: z.string().optional()
|
||||
})
|
||||
.optional(),
|
||||
|
||||
// App system config
|
||||
chatConfig: AppChatConfigTypeSchema,
|
||||
scheduledTriggerConfig: AppScheduledTriggerConfigTypeSchema.optional(),
|
||||
scheduledTriggerNextTime: z.date().optional(),
|
||||
|
||||
inheritPermission: z.boolean().optional(),
|
||||
|
||||
// if access the app by favourite or quick
|
||||
favourite: z.boolean().optional(),
|
||||
quick: z.boolean().optional(),
|
||||
|
||||
// 软删除字段
|
||||
deleteTime: z.date().nullish(),
|
||||
|
||||
/** @deprecated */
|
||||
defaultPermission: z.number().optional(),
|
||||
/** @deprecated */
|
||||
inited: z.boolean().optional(),
|
||||
/** @deprecated */
|
||||
teamTags: z.array(z.string()).optional()
|
||||
});
|
||||
export type AppSchemaType = z.infer<typeof AppSchemaTypeSchema>;
|
||||
|
||||
export type AppListItemType = {
|
||||
_id: string;
|
||||
parentId: ParentIdType;
|
||||
tmbId: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
type: AppTypeEnum;
|
||||
updateTime: Date;
|
||||
pluginData?: AppSchemaType['pluginData'];
|
||||
permission: AppPermission;
|
||||
inheritPermission?: boolean;
|
||||
private?: boolean;
|
||||
sourceMember: SourceMemberType;
|
||||
hasInteractiveNode?: boolean;
|
||||
};
|
||||
|
||||
export type AppDetailType = AppSchemaType & {
|
||||
permission: AppPermission;
|
||||
};
|
||||
|
||||
export const AppDatasetSearchParamsTypeSchema = z.object({
|
||||
searchMode: z.enum(DatasetSearchModeEnum),
|
||||
limit: z.number().optional(), // limit max tokens
|
||||
similarity: z.number().optional(),
|
||||
embeddingWeight: z.number().optional(), // embedding weight, fullText weight = 1 - embeddingWeight
|
||||
|
||||
usingReRank: z.boolean().optional(),
|
||||
rerankModel: z.string().optional(),
|
||||
rerankWeight: z.number().optional(),
|
||||
|
||||
datasetSearchUsingExtensionQuery: z.boolean().optional(),
|
||||
datasetSearchExtensionModel: z.string().optional(),
|
||||
datasetSearchExtensionBg: z.string().optional()
|
||||
});
|
||||
export type AppDatasetSearchParamsType = z.infer<typeof AppDatasetSearchParamsTypeSchema>;
|
||||
|
||||
export type SettingAIDataType = {
|
||||
model: string;
|
||||
temperature?: number;
|
||||
maxToken?: number;
|
||||
isResponseAnswerText?: boolean;
|
||||
maxHistories?: number;
|
||||
[NodeInputKeyEnum.aiChatVision]?: boolean; // Is open vision mode
|
||||
[NodeInputKeyEnum.aiChatReasoning]?: boolean; // Is open reasoning mode
|
||||
[NodeInputKeyEnum.aiChatTopP]?: number;
|
||||
[NodeInputKeyEnum.aiChatStopSign]?: string;
|
||||
[NodeInputKeyEnum.aiChatResponseFormat]?: string;
|
||||
[NodeInputKeyEnum.aiChatJsonSchema]?: string;
|
||||
};
|
||||
|
||||
export type AppTemplateSchemaType = {
|
||||
templateId: string;
|
||||
name: string;
|
||||
intro: string;
|
||||
avatar: string;
|
||||
tags: string[];
|
||||
type: string;
|
||||
author?: string;
|
||||
isActive?: boolean;
|
||||
isPromoted?: boolean;
|
||||
recommendText?: string;
|
||||
userGuide?: {
|
||||
type: 'markdown' | 'link';
|
||||
content?: string;
|
||||
link?: string;
|
||||
};
|
||||
isQuickTemplate?: boolean;
|
||||
order?: number;
|
||||
// TODO: 对于建议应用,是另一个格式
|
||||
workflow: WorkflowTemplateBasicType;
|
||||
};
|
||||
|
||||
export type TemplateTypeSchemaType = {
|
||||
typeName: string;
|
||||
typeId: string;
|
||||
typeOrder: number;
|
||||
};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import type { AppFormEditFormType } from '../app/type';
|
||||
import type { AppFormEditFormType } from './formEdit/type';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constants';
|
||||
import { type WorkflowTemplateBasicType } from '../workflow/type';
|
||||
import { AppTypeEnum } from './constants';
|
||||
|
|
@ -9,12 +9,8 @@ export const getDefaultAppForm = (): AppFormEditFormType => {
|
|||
return {
|
||||
aiSettings: {
|
||||
model: '',
|
||||
systemPrompt: '',
|
||||
temperature: 0,
|
||||
isResponseAnswerText: true,
|
||||
maxHistories: 6,
|
||||
maxToken: 4000,
|
||||
aiChatReasoning: true
|
||||
maxHistories: 6
|
||||
},
|
||||
dataset: {
|
||||
datasets: [],
|
||||
|
|
@ -28,8 +24,8 @@ export const getDefaultAppForm = (): AppFormEditFormType => {
|
|||
datasetSearchExtensionBg: ''
|
||||
},
|
||||
selectedTools: [],
|
||||
chatConfig: {},
|
||||
skills: []
|
||||
skills: [],
|
||||
chatConfig: {}
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { TeamMemberStatusEnum } from 'support/user/team/constant';
|
||||
import { StoreEdgeItemType } from '../workflow/type/edge';
|
||||
import type { AppSchema } from './type';
|
||||
import type { AppSchemaType } from './type';
|
||||
import { AppChatConfigType } from './type';
|
||||
import type { SourceMemberType } from 'support/user/type';
|
||||
|
||||
|
|
@ -8,9 +8,9 @@ export type AppVersionSchemaType = {
|
|||
_id: string;
|
||||
appId: string;
|
||||
time: Date;
|
||||
nodes: AppSchema['modules'];
|
||||
edges: AppSchema['edges'];
|
||||
chatConfig: AppSchema['chatConfig'];
|
||||
nodes: AppSchemaType['modules'];
|
||||
edges: AppSchemaType['edges'];
|
||||
chatConfig: AppSchemaType['chatConfig'];
|
||||
isPublish?: boolean;
|
||||
isAutoSave?: boolean;
|
||||
versionName: string;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import type {
|
|||
ChatCompletionMessageParam,
|
||||
ChatCompletionMessageToolCall,
|
||||
ChatCompletionToolMessageParam
|
||||
} from '../../core/ai/type.d';
|
||||
} from '../../core/ai/type';
|
||||
import { ChatCompletionRequestMessageRoleEnum } from '../../core/ai/constants';
|
||||
|
||||
export const GPT2Chat = {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { ChatFileTypeEnum, ChatRoleEnum } from './constants';
|
|||
import type { FlowNodeTypeEnum } from '../workflow/node/constant';
|
||||
import { NodeOutputKeyEnum } from '../workflow/constants';
|
||||
import type { DispatchNodeResponseKeyEnum } from '../workflow/runtime/constants';
|
||||
import type { AppSchema, VariableItemType } from '../app/type';
|
||||
import type { AppSchemaType, VariableItemType } from '../app/type';
|
||||
import type { DispatchNodeResponseType } from '../workflow/runtime/type';
|
||||
import type { ChatBoxInputType } from '../../../../projects/app/src/components/core/chat/ChatContainer/ChatBox/type';
|
||||
import type { WorkflowInteractiveResponseType } from '../workflow/template/system/interactive/type';
|
||||
|
|
@ -61,7 +61,7 @@ export type ChatSchemaType = {
|
|||
};
|
||||
|
||||
export type ChatWithAppSchema = Omit<ChatSchemaType, 'appId'> & {
|
||||
appId: AppSchema;
|
||||
appId: AppSchemaType;
|
||||
};
|
||||
|
||||
/* --------- chat item ---------- */
|
||||
|
|
@ -216,7 +216,7 @@ export type ChatItemResponseSchemaType = {
|
|||
|
||||
/* --------- team chat --------- */
|
||||
export type ChatAppListSchema = {
|
||||
apps: AppSchema[];
|
||||
apps: AppSchemaType[];
|
||||
teamInfo: any;
|
||||
uid?: string;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getEmbeddingModel } from '../../../../service/core/ai/model';
|
||||
import { type EmbeddingModelItemType, type LLMModelItemType } from '../../../core/ai/model.d';
|
||||
import { type EmbeddingModelItemType, type LLMModelItemType } from '../../../core/ai/model';
|
||||
import {
|
||||
ChunkSettingModeEnum,
|
||||
DataChunkSplitModeEnum,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { LLMModelItemType, EmbeddingModelItemType } from '../../core/ai/model.d';
|
||||
import type { LLMModelItemType, EmbeddingModelItemType } from '../../core/ai/model';
|
||||
import { PermissionTypeEnum } from '../../support/permission/constant';
|
||||
import { PushDatasetDataChunkProps } from './api';
|
||||
import type {
|
||||
|
|
|
|||
|
|
@ -2,23 +2,25 @@ import { ParentIdSchema } from '../../../../common/parentFolder/type';
|
|||
import { SystemToolBasicConfigSchema, ToolSecretInputItemSchema } from '../../tool/type';
|
||||
import z from 'zod';
|
||||
|
||||
export const AdminSystemToolListItemSchema = SystemToolBasicConfigSchema.extend({
|
||||
id: z.string(),
|
||||
parentId: ParentIdSchema,
|
||||
name: z.string(),
|
||||
intro: z.string().optional(),
|
||||
author: z.string().optional(),
|
||||
avatar: z.string().optional(),
|
||||
tags: z.array(z.string()).nullish(),
|
||||
export const AdminSystemToolListItemSchema = SystemToolBasicConfigSchema.merge(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
parentId: ParentIdSchema,
|
||||
name: z.string(),
|
||||
intro: z.string().optional(),
|
||||
author: z.string().optional(),
|
||||
avatar: z.string().optional(),
|
||||
tags: z.array(z.string()).nullish(),
|
||||
|
||||
hasSystemSecret: z.boolean().optional(),
|
||||
hasSystemSecret: z.boolean().optional(),
|
||||
|
||||
// App tool
|
||||
associatedPluginId: z.string().optional(),
|
||||
// App tool
|
||||
associatedPluginId: z.string().optional(),
|
||||
|
||||
isFolder: z.boolean().optional(),
|
||||
hasSecretInput: z.boolean()
|
||||
});
|
||||
isFolder: z.boolean().optional(),
|
||||
hasSecretInput: z.boolean()
|
||||
})
|
||||
);
|
||||
export type AdminSystemToolListItemType = z.infer<typeof AdminSystemToolListItemSchema>;
|
||||
|
||||
// Child config schema for update
|
||||
|
|
@ -29,10 +31,12 @@ export const ToolsetChildSchema = z.object({
|
|||
});
|
||||
export const AdminSystemToolDetailSchema = AdminSystemToolListItemSchema.omit({
|
||||
hasSecretInput: true
|
||||
}).extend({
|
||||
userGuide: z.string().nullish(),
|
||||
inputList: z.array(ToolSecretInputItemSchema).optional(),
|
||||
inputListVal: z.record(z.string(), z.any()).nullish(),
|
||||
childTools: z.array(ToolsetChildSchema).optional()
|
||||
});
|
||||
}).and(
|
||||
z.object({
|
||||
userGuide: z.string().nullish(),
|
||||
inputList: z.array(ToolSecretInputItemSchema).optional(),
|
||||
inputListVal: z.record(z.string(), z.any()).nullish(),
|
||||
childTools: z.array(ToolsetChildSchema).optional()
|
||||
})
|
||||
);
|
||||
export type AdminSystemToolDetailType = z.infer<typeof AdminSystemToolDetailSchema>;
|
||||
|
|
|
|||
|
|
@ -12,36 +12,38 @@ export const SystemToolBasicConfigSchema = z.object({
|
|||
pluginOrder: z.number().optional()
|
||||
});
|
||||
|
||||
export const SystemPluginToolCollectionSchema = SystemToolBasicConfigSchema.extend({
|
||||
pluginId: z.string(),
|
||||
customConfig: z
|
||||
.object({
|
||||
name: z.string(),
|
||||
avatar: z.string().optional(),
|
||||
intro: z.string().optional(),
|
||||
toolDescription: z.string().optional(),
|
||||
version: z.string(),
|
||||
tags: z.array(z.string()).nullish(),
|
||||
associatedPluginId: z.string().optional(),
|
||||
userGuide: z.string().optional(),
|
||||
author: z.string().optional()
|
||||
})
|
||||
.optional(),
|
||||
inputListVal: z.record(z.string(), z.any()).optional(),
|
||||
|
||||
// @deprecated
|
||||
isActive: z.boolean().optional(),
|
||||
inputConfig: z
|
||||
.array(
|
||||
z.object({
|
||||
key: z.string(),
|
||||
label: z.string(),
|
||||
description: z.string().optional(),
|
||||
value: z.any().optional()
|
||||
export const SystemPluginToolCollectionSchema = SystemToolBasicConfigSchema.and(
|
||||
z.object({
|
||||
pluginId: z.string(),
|
||||
customConfig: z
|
||||
.object({
|
||||
name: z.string(),
|
||||
avatar: z.string().optional(),
|
||||
intro: z.string().optional(),
|
||||
toolDescription: z.string().optional(),
|
||||
version: z.string(),
|
||||
tags: z.array(z.string()).nullish(),
|
||||
associatedPluginId: z.string().optional(),
|
||||
userGuide: z.string().optional(),
|
||||
author: z.string().optional()
|
||||
})
|
||||
)
|
||||
.optional()
|
||||
});
|
||||
.optional(),
|
||||
inputListVal: z.record(z.string(), z.any()).optional(),
|
||||
|
||||
// @deprecated
|
||||
isActive: z.boolean().optional(),
|
||||
inputConfig: z
|
||||
.array(
|
||||
z.object({
|
||||
key: z.string(),
|
||||
label: z.string(),
|
||||
description: z.string().optional(),
|
||||
value: z.any().optional()
|
||||
})
|
||||
)
|
||||
.optional()
|
||||
})
|
||||
);
|
||||
export type SystemPluginToolCollectionType = z.infer<typeof SystemPluginToolCollectionSchema>;
|
||||
|
||||
// TODO: 移动到 plugin sdk 里
|
||||
|
|
|
|||
|
|
@ -453,13 +453,6 @@ export const variableMap: Record<VariableInputEnum, VariableConfigType> = {
|
|||
// Keep backward compatibility
|
||||
export const variableMapGroups = variableConfigs;
|
||||
|
||||
/* run time */
|
||||
export enum RuntimeEdgeStatusEnum {
|
||||
'waiting' = 'waiting',
|
||||
'active' = 'active',
|
||||
'skipped' = 'skipped'
|
||||
}
|
||||
|
||||
export const VARIABLE_NODE_ID = 'VARIABLE_NODE_ID';
|
||||
export const DYNAMIC_INPUT_REFERENCE_KEY = 'DYNAMIC_INPUT_REFERENCE_KEY';
|
||||
|
||||
|
|
|
|||
|
|
@ -5,25 +5,19 @@ import type {
|
|||
AIChatItemValueItemType,
|
||||
ChatHistoryItemResType
|
||||
} from '../../chat/type';
|
||||
import type { FlowNodeInputItemType, FlowNodeOutputItemType } from '../type/io.d';
|
||||
import type { NodeToolConfigType, StoreNodeItemType } from '../type/node';
|
||||
import type { FlowNodeInputItemType, FlowNodeOutputItemType } from '../type/io';
|
||||
import type { StoreNodeItemType } from '../type/node';
|
||||
import type { DispatchNodeResponseKeyEnum } from './constants';
|
||||
import type { StoreEdgeItemType } from '../type/edge';
|
||||
import type { NodeInputKeyEnum, NodeOutputKeyEnum } from '../constants';
|
||||
import type { ClassifyQuestionAgentItemType } from '../template/system/classifyQuestion/type';
|
||||
import type { NextApiResponse } from 'next';
|
||||
import { UserModelSchema } from '../../../support/user/type';
|
||||
import type { AppSchema } from '../../app/type';
|
||||
import { AppDetailType } from '../../app/type';
|
||||
import type { RuntimeNodeItemType } from '../runtime/type';
|
||||
import type { RuntimeEdgeItemType } from './edge';
|
||||
import type { AppSchemaType } from '../../app/type';
|
||||
import type { RuntimeEdgeItemType } from '../type/edge';
|
||||
import type { ReadFileNodeResponse } from '../template/system/readFiles/type';
|
||||
import { UserSelectOptionType } from '../template/system/userSelect/type';
|
||||
import type { WorkflowResponseType } from '../../../../service/core/workflow/dispatch/type';
|
||||
import type { AiChatQuoteRoleType } from '../template/system/aiChat/type';
|
||||
import type { OpenaiAccountType } from '../../../support/user/team/type';
|
||||
import { LafAccountType } from '../../../support/user/team/type';
|
||||
import type { ChatCompletionMessageParam, CompletionFinishReason } from '../../ai/type';
|
||||
import type { CompletionFinishReason } from '../../ai/type';
|
||||
import type {
|
||||
InteractiveNodeResponseType,
|
||||
WorkflowInteractiveResponseType
|
||||
|
|
@ -31,6 +25,10 @@ import type {
|
|||
import type { SearchDataResponseItemType } from '../../dataset/type';
|
||||
import type { localeType } from '../../../common/i18n/type';
|
||||
import { type UserChatItemValueItemType } from '../../chat/type';
|
||||
import { z } from 'zod';
|
||||
import type { DatasetSearchModeEnum } from '../../dataset/constants';
|
||||
import type { ChatRoleEnum } from '../../chat/constants';
|
||||
import type { MCPClient } from '../../../../service/core/app/mcp';
|
||||
|
||||
export type ExternalProviderType = {
|
||||
openaiAccount?: OpenaiAccountType;
|
||||
|
|
@ -70,7 +68,7 @@ export type ChatDispatchProps = {
|
|||
variables: Record<string, any>; // global variable
|
||||
cloneVariables: Record<string, any>;
|
||||
query: UserChatItemValueItemType[]; // trigger query
|
||||
chatConfig: AppSchema['chatConfig'];
|
||||
chatConfig: AppSchemaType['chatConfig'];
|
||||
lastInteractive?: WorkflowInteractiveResponseType; // last interactive response
|
||||
stream: boolean;
|
||||
retainDatasetCite?: boolean;
|
||||
|
|
@ -131,10 +129,6 @@ export type RuntimeNodeItemType = {
|
|||
catchError?: boolean;
|
||||
};
|
||||
|
||||
export type RuntimeEdgeItemType = StoreEdgeItemType & {
|
||||
status: 'waiting' | 'active' | 'skipped';
|
||||
};
|
||||
|
||||
export type DispatchNodeResponseType = {
|
||||
// common
|
||||
moduleLogo?: string;
|
||||
|
|
@ -14,11 +14,11 @@ import {
|
|||
type InteractiveNodeResponseType,
|
||||
type WorkflowInteractiveResponseType
|
||||
} from '../template/system/interactive/type';
|
||||
import type { StoreEdgeItemType } from '../type/edge';
|
||||
import type { RuntimeEdgeItemType, StoreEdgeItemType } from '../type/edge';
|
||||
import type { FlowNodeOutputItemType, ReferenceValueType } from '../type/io';
|
||||
import type { StoreNodeItemType } from '../type/node';
|
||||
import { isValidReferenceValueFormat } from '../utils';
|
||||
import type { RuntimeEdgeItemType, RuntimeNodeItemType } from './type';
|
||||
import type { RuntimeNodeItemType } from './type';
|
||||
import { isSecretValue } from '../../../common/secret/utils';
|
||||
import { isChildInteractive } from '../template/system/interactive/constants';
|
||||
|
||||
|
|
@ -633,7 +633,7 @@ export const textAdaptGptResponse = ({
|
|||
/* Update runtimeNode's outputs with interactive data from history */
|
||||
export function rewriteNodeOutputByHistories(
|
||||
runtimeNodes: RuntimeNodeItemType[],
|
||||
lastInteractive?: InteractiveNodeResponseType
|
||||
lastInteractive?: WorkflowInteractiveResponseType
|
||||
) {
|
||||
const interactive = lastInteractive;
|
||||
if (!interactive?.nodeOutputs) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { FlowNodeOutputItemType } from '../type/io.d';
|
||||
import type { FlowNodeOutputItemType } from '../type/io';
|
||||
import { NodeOutputKeyEnum } from '../constants';
|
||||
import { FlowNodeOutputTypeEnum } from '../node/constant';
|
||||
import { WorkflowIOValueTypeEnum } from '../constants';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../type/node';
|
||||
import {
|
||||
WorkflowIOValueTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { FlowNodeTypeEnum } from '../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../type/node';
|
||||
import {
|
||||
FlowNodeTemplateTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../type/node';
|
||||
import {
|
||||
WorkflowIOValueTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
FlowNodeTemplateTypeEnum
|
||||
} from '../../constants';
|
||||
import { getNanoid } from '../../../../common/string/tools';
|
||||
import { type FlowNodeInputItemType } from '../../type/io.d';
|
||||
import { type FlowNodeInputItemType } from '../../type/io';
|
||||
import { i18nT } from '../../../../../web/i18n/utils';
|
||||
|
||||
export const getOneQuoteInputTemplate = ({
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../type/node';
|
||||
import {
|
||||
WorkflowIOValueTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
|
|
|
|||
|
|
@ -1,31 +1,52 @@
|
|||
import type { NodeOutputItemType } from '../../../../chat/type';
|
||||
import type { FlowNodeInputTypeEnum } from '../../../../../core/workflow/node/constant';
|
||||
import type { WorkflowIOValueTypeEnum } from '../../../../../core/workflow/constants';
|
||||
import { NodeOutputItemSchema } from '../../../../chat/type';
|
||||
import { FlowNodeInputTypeEnum } from '../../../../../core/workflow/node/constant';
|
||||
import { WorkflowIOValueTypeEnum } from '../../../../../core/workflow/constants';
|
||||
import type { ChatCompletionMessageParam } from '../../../../ai/type';
|
||||
import type { AppFileSelectConfigType } from '../../../../app/type';
|
||||
import type { RuntimeEdgeItemType } from '../../../type/edge';
|
||||
import { AppFileSelectConfigTypeSchema } from '../../../../app/type';
|
||||
import { RuntimeEdgeItemTypeSchema } from '../../../type/edge';
|
||||
import z from 'zod';
|
||||
|
||||
export type InteractiveBasicType = {
|
||||
entryNodeIds: string[];
|
||||
memoryEdges: RuntimeEdgeItemType[];
|
||||
nodeOutputs: NodeOutputItemType[];
|
||||
skipNodeQueue?: { id: string; skippedNodeIdList: string[] }[]; // 需要记录目前在 queue 里的节点
|
||||
export const InteractiveBasicTypeSchema = z.object({
|
||||
entryNodeIds: z.array(z.string()),
|
||||
memoryEdges: z.array(RuntimeEdgeItemTypeSchema),
|
||||
nodeOutputs: z.array(NodeOutputItemSchema),
|
||||
skipNodeQueue: z
|
||||
.array(z.object({ id: z.string(), skippedNodeIdList: z.array(z.string()) }))
|
||||
.optional(), // 需要记录目前在 queue 里的节点
|
||||
usageId: z.string().optional()
|
||||
});
|
||||
export type InteractiveBasicType = z.infer<typeof InteractiveBasicTypeSchema>;
|
||||
|
||||
usageId?: string;
|
||||
};
|
||||
|
||||
type InteractiveNodeType = {
|
||||
entryNodeIds?: string[];
|
||||
memoryEdges?: RuntimeEdgeItemType[];
|
||||
nodeOutputs?: NodeOutputItemType[];
|
||||
};
|
||||
const InteractiveNodeTypeSchema = z.object({
|
||||
entryNodeIds: z.array(z.string()).optional(),
|
||||
memoryEdges: z.array(RuntimeEdgeItemTypeSchema).optional(),
|
||||
nodeOutputs: z.array(NodeOutputItemSchema).optional()
|
||||
});
|
||||
export type InteractiveNodeType = z.infer<typeof InteractiveNodeTypeSchema>;
|
||||
|
||||
export const ChildrenInteractiveSchema = z.object({
|
||||
type: z.literal('childrenInteractive'),
|
||||
params: z.object({
|
||||
childrenResponse: z.any()
|
||||
})
|
||||
});
|
||||
export type ChildrenInteractive = InteractiveNodeType & {
|
||||
type: 'childrenInteractive';
|
||||
params: {
|
||||
childrenResponse: WorkflowInteractiveResponseType;
|
||||
};
|
||||
};
|
||||
|
||||
export const ToolCallChildrenInteractiveSchema = z.object({
|
||||
type: z.literal('toolChildrenInteractive'),
|
||||
params: z.object({
|
||||
childrenResponse: z.any(),
|
||||
toolParams: z.object({
|
||||
memoryRequestMessages: z.array(z.any()), // 这轮工具中,产生的新的 messages
|
||||
toolCallId: z.string() // 记录对应 tool 的id,用于后续交互节点可以替换掉 tool 的 response
|
||||
})
|
||||
})
|
||||
});
|
||||
export type ToolCallChildrenInteractive = InteractiveNodeType & {
|
||||
type: 'toolChildrenInteractive';
|
||||
params: {
|
||||
|
|
@ -38,6 +59,14 @@ export type ToolCallChildrenInteractive = InteractiveNodeType & {
|
|||
};
|
||||
|
||||
// Loop bode
|
||||
export const LoopInteractiveSchema = z.object({
|
||||
type: z.literal('loopInteractive'),
|
||||
params: z.object({
|
||||
loopResult: z.array(z.any()),
|
||||
childrenResponse: z.any(),
|
||||
currentIndex: z.number()
|
||||
})
|
||||
});
|
||||
export type LoopInteractive = InteractiveNodeType & {
|
||||
type: 'loopInteractive';
|
||||
params: {
|
||||
|
|
@ -48,85 +77,91 @@ export type LoopInteractive = InteractiveNodeType & {
|
|||
};
|
||||
|
||||
// Agent Interactive
|
||||
export type AgentPlanCheckInteractive = InteractiveNodeType & {
|
||||
type: 'agentPlanCheck';
|
||||
params: {
|
||||
confirmed?: boolean;
|
||||
};
|
||||
};
|
||||
export type AgentPlanAskQueryInteractive = InteractiveNodeType & {
|
||||
type: 'agentPlanAskQuery';
|
||||
params: {
|
||||
content: string;
|
||||
};
|
||||
};
|
||||
export const AgentPlanCheckInteractiveSchema = z.object({
|
||||
type: z.literal('agentPlanCheck'),
|
||||
params: z.object({
|
||||
confirmed: z.boolean().optional()
|
||||
})
|
||||
});
|
||||
export type AgentPlanCheckInteractive = z.infer<typeof AgentPlanCheckInteractiveSchema>;
|
||||
|
||||
export type UserSelectOptionItemType = {
|
||||
key: string;
|
||||
value: string;
|
||||
};
|
||||
export type UserSelectInteractive = InteractiveNodeType & {
|
||||
type: 'userSelect' | 'agentPlanAskUserSelect';
|
||||
params: {
|
||||
description: string;
|
||||
userSelectOptions: UserSelectOptionItemType[];
|
||||
userSelectedVal?: string;
|
||||
};
|
||||
};
|
||||
export const AgentPlanAskQueryInteractiveSchema = z.object({
|
||||
type: z.literal('agentPlanAskQuery'),
|
||||
params: z.object({
|
||||
content: z.string()
|
||||
})
|
||||
});
|
||||
export type AgentPlanAskQueryInteractive = z.infer<typeof AgentPlanAskQueryInteractiveSchema>;
|
||||
|
||||
export type UserInputFormItemType = {
|
||||
type: FlowNodeInputTypeEnum;
|
||||
key: string;
|
||||
label: string;
|
||||
value: any;
|
||||
valueType: WorkflowIOValueTypeEnum;
|
||||
description?: string;
|
||||
defaultValue?: any;
|
||||
required: boolean;
|
||||
// User selector
|
||||
export const UserSelectOptionItemSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.string()
|
||||
});
|
||||
export type UserSelectOptionItemType = z.infer<typeof UserSelectOptionItemSchema>;
|
||||
export const UserSelectInteractiveSchema = z.object({
|
||||
type: z.literal('userSelect').or(z.literal('agentPlanAskUserSelect')),
|
||||
params: z.object({
|
||||
description: z.string(),
|
||||
userSelectOptions: z.array(UserSelectOptionItemSchema),
|
||||
userSelectedVal: z.string().optional()
|
||||
})
|
||||
});
|
||||
export type UserSelectInteractive = z.infer<typeof UserSelectInteractiveSchema>;
|
||||
|
||||
// input & textarea
|
||||
maxLength?: number;
|
||||
// User input
|
||||
export const UserInputFormItemSchema = AppFileSelectConfigTypeSchema.extend(
|
||||
z.object({
|
||||
type: z.enum(FlowNodeInputTypeEnum),
|
||||
key: z.string(),
|
||||
label: z.string(),
|
||||
value: z.any(),
|
||||
valueType: z.enum(WorkflowIOValueTypeEnum),
|
||||
description: z.string().optional(),
|
||||
defaultValue: z.any().optional(),
|
||||
required: z.boolean(),
|
||||
|
||||
// password
|
||||
minLength?: number;
|
||||
|
||||
// numberInput
|
||||
max?: number;
|
||||
min?: number;
|
||||
// select
|
||||
list?: { label: string; value: string }[];
|
||||
|
||||
// File
|
||||
canLocalUpload?: boolean;
|
||||
canUrlUpload?: boolean;
|
||||
} & AppFileSelectConfigType;
|
||||
|
||||
export type UserInputInteractive = InteractiveNodeType & {
|
||||
type: 'userInput' | 'agentPlanAskUserForm';
|
||||
params: {
|
||||
description: string;
|
||||
inputForm: UserInputFormItemType[];
|
||||
submitted?: boolean;
|
||||
};
|
||||
};
|
||||
maxLength: z.number().optional(), // input & textarea
|
||||
minLength: z.number().optional(), // password
|
||||
max: z.number().optional(), // numberInput
|
||||
min: z.number().optional(), // numberInput
|
||||
list: z.array(z.object({ label: z.string(), value: z.string() })).optional() // select
|
||||
})
|
||||
);
|
||||
export type UserInputFormItemType = z.infer<typeof UserInputFormItemSchema>;
|
||||
export const UserInputInteractiveSchema = z.object({
|
||||
type: z.literal('userInput').or(z.literal('agentPlanAskUserForm')),
|
||||
params: z.object({
|
||||
description: z.string(),
|
||||
inputForm: z.array(UserInputFormItemSchema),
|
||||
submitted: z.boolean().optional()
|
||||
})
|
||||
});
|
||||
export type UserInputInteractive = z.infer<typeof UserInputInteractiveSchema>;
|
||||
|
||||
// 欠费暂停交互
|
||||
export type PaymentPauseInteractive = InteractiveNodeType & {
|
||||
type: 'paymentPause';
|
||||
params: {
|
||||
description?: string;
|
||||
continue?: boolean;
|
||||
};
|
||||
};
|
||||
export const PaymentPauseInteractiveSchema = z.object({
|
||||
type: z.literal('paymentPause'),
|
||||
params: z.object({
|
||||
description: z.string().optional(),
|
||||
continue: z.boolean().optional()
|
||||
})
|
||||
});
|
||||
export type PaymentPauseInteractive = z.infer<typeof PaymentPauseInteractiveSchema>;
|
||||
|
||||
export type InteractiveNodeResponseType =
|
||||
| UserSelectInteractive
|
||||
| UserInputInteractive
|
||||
| ChildrenInteractive
|
||||
| ToolCallChildrenInteractive
|
||||
| LoopInteractive
|
||||
| PaymentPauseInteractive
|
||||
| AgentPlanCheckInteractive
|
||||
| AgentPlanAskQueryInteractive;
|
||||
export const InteractiveNodeResponseTypeSchema = z.union([
|
||||
UserSelectInteractiveSchema,
|
||||
UserInputInteractiveSchema,
|
||||
ChildrenInteractiveSchema,
|
||||
ToolCallChildrenInteractiveSchema,
|
||||
LoopInteractiveSchema,
|
||||
PaymentPauseInteractiveSchema,
|
||||
AgentPlanCheckInteractiveSchema,
|
||||
AgentPlanAskQueryInteractiveSchema
|
||||
]);
|
||||
export type InteractiveNodeResponseType = z.infer<typeof InteractiveNodeResponseTypeSchema>;
|
||||
|
||||
export type WorkflowInteractiveResponseType = InteractiveBasicType & InteractiveNodeResponseType;
|
||||
export const WorkflowInteractiveResponseTypeSchema = InteractiveBasicTypeSchema.and(
|
||||
InteractiveNodeResponseTypeSchema
|
||||
);
|
||||
export type WorkflowInteractiveResponseType = z.infer<typeof WorkflowInteractiveResponseTypeSchema>;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../../type/node';
|
||||
|
||||
export const UserSelectNode: FlowNodeTemplateType = {
|
||||
id: FlowNodeTypeEnum.userSelect,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../type/node';
|
||||
import {
|
||||
WorkflowIOValueTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../../type/node';
|
||||
import {
|
||||
FlowNodeTemplateTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { FlowNodeTypeEnum } from '../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../type/node';
|
||||
import { FlowNodeTemplateTypeEnum } from '../../constants';
|
||||
import { i18nT } from '../../../../../web/i18n/utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../type/node';
|
||||
import {
|
||||
WorkflowIOValueTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { FlowNodeTypeEnum } from '../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../type/node';
|
||||
import { FlowNodeTemplateTypeEnum } from '../../constants';
|
||||
import { i18nT } from '../../../../../web/i18n/utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../type/node';
|
||||
import {
|
||||
WorkflowIOValueTypeEnum,
|
||||
NodeOutputKeyEnum,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from '../../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../../type/node';
|
||||
import {
|
||||
FlowNodeTemplateTypeEnum,
|
||||
NodeInputKeyEnum,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from '../../node/constant';
|
||||
import { type FlowNodeTemplateType } from '../../type/node.d';
|
||||
import { type FlowNodeTemplateType } from '../../type/node';
|
||||
import {
|
||||
WorkflowIOValueTypeEnum,
|
||||
NodeOutputKeyEnum,
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
import type { RuntimeEdgeStatusEnum } from '../constants';
|
||||
|
||||
export type StoreEdgeItemType = {
|
||||
source: string;
|
||||
sourceHandle: string;
|
||||
target: string;
|
||||
targetHandle: string;
|
||||
};
|
||||
|
||||
export type RuntimeEdgeItemType = StoreEdgeItemType & {
|
||||
status: `${RuntimeEdgeStatusEnum}`;
|
||||
};
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
export const StoreEdgeItemTypeSchema = z.object({
|
||||
source: z.string(),
|
||||
sourceHandle: z.string(),
|
||||
target: z.string(),
|
||||
targetHandle: z.string()
|
||||
});
|
||||
export type StoreEdgeItemType = z.infer<typeof StoreEdgeItemTypeSchema>;
|
||||
|
||||
export const RuntimeEdgeItemTypeSchema = StoreEdgeItemTypeSchema.and(
|
||||
z.object({
|
||||
status: z.enum(['waiting', 'active', 'skipped'])
|
||||
})
|
||||
);
|
||||
export type RuntimeEdgeItemType = z.infer<typeof RuntimeEdgeItemTypeSchema>;
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
import { FlowNodeTypeEnum } from '../node/constant';
|
||||
import {
|
||||
WorkflowIOValueTypeEnum,
|
||||
NodeOutputKeyEnum,
|
||||
FlowNodeTemplateTypeEnum,
|
||||
VariableInputEnum
|
||||
} from '../constants';
|
||||
import { DispatchNodeResponseKeyEnum } from '../runtime/constants';
|
||||
import type { FlowNodeInputItemType, FlowNodeOutputItemType } from './io.d';
|
||||
import { CustomInputItemType } from './io.d';
|
||||
import {
|
||||
ChatHistoryItemResType,
|
||||
ChatItemType,
|
||||
ChatItemValueItemType,
|
||||
ToolRunResponseItemType
|
||||
} from '../../chat/type';
|
||||
import { ChatNodeUsageType } from '../../../support/wallet/bill/type';
|
||||
import type { StoreEdgeItemType } from './edge';
|
||||
import type { AppChatConfigType } from '../../app/type';
|
||||
import type { ParentIdType } from 'common/parentFolder/type';
|
||||
import type { AppTypeEnum } from 'core/app/constants';
|
||||
import type { StoreNodeItemType } from './node';
|
||||
import { FlowNodeTemplateType } from './node';
|
||||
import type { SecretValueType } from './../../../common/secret/type';
|
||||
import type { I18nStringType } from '../../../common/i18n/type';
|
||||
|
||||
export type WorkflowTemplateBasicType = {
|
||||
nodes: StoreNodeItemType[];
|
||||
edges: StoreEdgeItemType[];
|
||||
chatConfig?: AppChatConfigType;
|
||||
};
|
||||
export type WorkflowTemplateType = {
|
||||
id: string;
|
||||
parentId?: ParentIdType;
|
||||
isFolder?: boolean;
|
||||
|
||||
avatar?: string;
|
||||
name: I18nStringType | string;
|
||||
intro?: I18nStringType | string;
|
||||
toolDescription?: string;
|
||||
|
||||
author?: string;
|
||||
courseUrl?: string;
|
||||
weight?: number;
|
||||
|
||||
version?: string;
|
||||
workflow: WorkflowTemplateBasicType;
|
||||
};
|
||||
|
||||
// template market
|
||||
export type TemplateMarketItemType = WorkflowTemplateType & {
|
||||
tags: string[];
|
||||
type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.workflowTool;
|
||||
};
|
||||
// template market list
|
||||
export type TemplateMarketListItemType = {
|
||||
id: string;
|
||||
name: string;
|
||||
intro?: string;
|
||||
author?: string;
|
||||
tags: string[];
|
||||
type: AppTypeEnum.simple | AppTypeEnum.workflow | AppTypeEnum.workflowTool;
|
||||
avatar: string;
|
||||
};
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
import { StoreEdgeItemTypeSchema } from './edge';
|
||||
import { AppChatConfigTypeSchema } from '../../app/type';
|
||||
import { ParentIdSchema } from '../../../common/parentFolder/type';
|
||||
import { AppTypeEnum } from '../../app/constants';
|
||||
import { StoreNodeItemTypeSchema } from './node';
|
||||
import { I18nStringSchema } from '../../../common/i18n/type';
|
||||
import z from 'zod';
|
||||
|
||||
export const WorkflowTemplateBasicTypeSchema = z.object({
|
||||
nodes: z.array(StoreNodeItemTypeSchema),
|
||||
edges: z.array(StoreEdgeItemTypeSchema),
|
||||
chatConfig: AppChatConfigTypeSchema.optional()
|
||||
});
|
||||
export type WorkflowTemplateBasicType = z.infer<typeof WorkflowTemplateBasicTypeSchema>;
|
||||
|
||||
export const WorkflowTemplateTypeSchema = z.object({
|
||||
id: z.string(),
|
||||
parentId: ParentIdSchema.optional(),
|
||||
isFolder: z.boolean().optional(),
|
||||
|
||||
avatar: z.string().optional(),
|
||||
name: z.union([I18nStringSchema, z.string()]),
|
||||
intro: z.union([I18nStringSchema, z.string()]).optional(),
|
||||
toolDescription: z.string().optional(),
|
||||
|
||||
author: z.string().optional(),
|
||||
courseUrl: z.string().optional(),
|
||||
weight: z.number().optional(),
|
||||
|
||||
version: z.string().optional(),
|
||||
workflow: WorkflowTemplateBasicTypeSchema
|
||||
});
|
||||
export type WorkflowTemplateType = z.infer<typeof WorkflowTemplateTypeSchema>;
|
||||
|
||||
// template market
|
||||
export const TemplateMarketItemTypeSchema = WorkflowTemplateTypeSchema.and(
|
||||
z.object({
|
||||
tags: z.array(z.string()),
|
||||
type: z.enum([AppTypeEnum.simple, AppTypeEnum.workflow, AppTypeEnum.workflowTool])
|
||||
})
|
||||
);
|
||||
export type TemplateMarketItemType = z.infer<typeof TemplateMarketItemTypeSchema>;
|
||||
|
||||
// template market list
|
||||
export const TemplateMarketListItemTypeSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
intro: z.string().optional(),
|
||||
author: z.string().optional(),
|
||||
tags: z.array(z.string()),
|
||||
type: z.enum([AppTypeEnum.simple, AppTypeEnum.workflow, AppTypeEnum.workflowTool]),
|
||||
avatar: z.string()
|
||||
});
|
||||
export type TemplateMarketListItemType = z.infer<typeof TemplateMarketListItemTypeSchema>;
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
import type { EmbeddingModelItemType, LLMModelItemType } from '../../ai/model.d';
|
||||
import type { LLMModelTypeEnum } from '../../ai/constants';
|
||||
import type { WorkflowIOValueTypeEnum, NodeInputKeyEnum, NodeOutputKeyEnum } from '../constants';
|
||||
import type { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum } from '../node/constant';
|
||||
import type { SecretValueType } from '../../../common/secret/type';
|
||||
|
||||
// Dynamic input field configuration
|
||||
export type CustomFieldConfigType = {
|
||||
// selectInputTypeList: FlowNodeInputTypeEnum[]; // 可以选哪些输入类型, 只有1个话,则默认选择
|
||||
|
||||
// reference
|
||||
selectValueTypeList?: WorkflowIOValueTypeEnum[]; // 可以选哪个数据类型, 只有1个的话,则默认选择
|
||||
|
||||
showDefaultValue?: boolean;
|
||||
showDescription?: boolean;
|
||||
};
|
||||
export type InputComponentPropsType = {
|
||||
key: `${NodeInputKeyEnum}` | string;
|
||||
label: string;
|
||||
|
||||
valueType?: WorkflowIOValueTypeEnum; // data type
|
||||
required?: boolean;
|
||||
defaultValue?: any;
|
||||
|
||||
referencePlaceholder?: string;
|
||||
isRichText?: boolean;
|
||||
placeholder?: string; // input,textarea
|
||||
maxLength?: number; // input,textarea
|
||||
minLength?: number; // password
|
||||
|
||||
list?: { label: string; value: string }[]; // select
|
||||
|
||||
markList?: { label: string; value: number }[]; // slider
|
||||
step?: number; // slider
|
||||
max?: number; // slider, number input
|
||||
min?: number; // slider, number input
|
||||
precision?: number; // number input
|
||||
|
||||
llmModelType?: `${LLMModelTypeEnum}`;
|
||||
|
||||
// file
|
||||
canSelectFile?: boolean;
|
||||
canSelectImg?: boolean;
|
||||
canSelectVideo?: boolean;
|
||||
canSelectAudio?: boolean;
|
||||
canSelectCustomFileExtension?: boolean;
|
||||
customFileExtensionList?: string[];
|
||||
canLocalUpload?: boolean;
|
||||
canUrlUpload?: boolean;
|
||||
maxFiles?: number;
|
||||
|
||||
// Time
|
||||
timeGranularity?: 'day' | 'hour' | 'minute' | 'second';
|
||||
timeRangeStart?: string;
|
||||
timeRangeEnd?: string;
|
||||
|
||||
// dataset select
|
||||
datasetOptions?: SelectedDatasetType[];
|
||||
|
||||
// dynamic input
|
||||
customInputConfig?: CustomFieldConfigType;
|
||||
|
||||
// @deprecated
|
||||
enums?: { value: string; label: string }[];
|
||||
};
|
||||
export type InputConfigType = {
|
||||
key: string;
|
||||
label: string;
|
||||
description?: string;
|
||||
required?: boolean;
|
||||
inputType: 'input' | 'numberInput' | 'secret' | 'switch' | 'select';
|
||||
value?: SecretValueType;
|
||||
|
||||
// Selector
|
||||
list?: { label: string; value: string }[];
|
||||
};
|
||||
|
||||
export type FlowNodeInputItemType = InputComponentPropsType & {
|
||||
selectedTypeIndex?: number;
|
||||
renderTypeList: FlowNodeInputTypeEnum[]; // Node Type. Decide on a render style
|
||||
|
||||
valueDesc?: string; // data desc
|
||||
value?: any;
|
||||
debugLabel?: string;
|
||||
description?: string; // field desc
|
||||
toolDescription?: string; // If this field is not empty, it is entered as a tool
|
||||
|
||||
enum?: string;
|
||||
inputList?: InputConfigType[]; // when key === 'system_input_config', this field is used
|
||||
|
||||
// render components params
|
||||
canEdit?: boolean; // dynamic inputs
|
||||
isPro?: boolean; // Pro version field
|
||||
isToolOutput?: boolean;
|
||||
|
||||
deprecated?: boolean;
|
||||
};
|
||||
|
||||
export type FlowNodeOutputItemType = {
|
||||
id: string; // output unique id(Does not follow the key change)
|
||||
type: FlowNodeOutputTypeEnum;
|
||||
key: `${NodeOutputKeyEnum}` | string;
|
||||
valueType?: WorkflowIOValueTypeEnum;
|
||||
valueDesc?: string;
|
||||
value?: any;
|
||||
|
||||
label?: string;
|
||||
description?: string;
|
||||
defaultValue?: any;
|
||||
required?: boolean;
|
||||
|
||||
invalid?: boolean;
|
||||
invalidCondition?: (e: {
|
||||
inputs: FlowNodeInputItemType[];
|
||||
llmModelList: LLMModelItemType[];
|
||||
}) => boolean;
|
||||
|
||||
// component params
|
||||
customFieldConfig?: CustomFieldConfigType;
|
||||
|
||||
deprecated?: boolean;
|
||||
};
|
||||
|
||||
// Field value type
|
||||
export type ReferenceItemValueType = [string, string | undefined];
|
||||
export type ReferenceArrayValueType = ReferenceItemValueType[];
|
||||
export type ReferenceValueType = ReferenceItemValueType | ReferenceArrayValueType;
|
||||
|
||||
export type SelectedDatasetType = {
|
||||
datasetId: string;
|
||||
avatar: string;
|
||||
name: string;
|
||||
vectorModel: EmbeddingModelItemType;
|
||||
};
|
||||
|
||||
/* http node */
|
||||
export type HttpParamAndHeaderItemType = {
|
||||
key: string;
|
||||
type: string;
|
||||
value: string;
|
||||
};
|
||||
|
|
@ -0,0 +1,165 @@
|
|||
import { LLMModelItemSchema } from '../../ai/model';
|
||||
import { LLMModelTypeEnum } from '../../ai/constants';
|
||||
import { WorkflowIOValueTypeEnum, NodeInputKeyEnum, NodeOutputKeyEnum } from '../constants';
|
||||
import { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum } from '../node/constant';
|
||||
import { SecretValueTypeSchema } from '../../../common/secret/type';
|
||||
import z from 'zod';
|
||||
|
||||
/* Dataset node */
|
||||
export const SelectedDatasetSchema = z.object({
|
||||
datasetId: z.string(),
|
||||
avatar: z.string(),
|
||||
name: z.string(),
|
||||
vectorModel: z.object({
|
||||
model: z.string()
|
||||
})
|
||||
});
|
||||
export type SelectedDatasetType = z.infer<typeof SelectedDatasetSchema>;
|
||||
|
||||
// Dynamic input field configuration
|
||||
export const CustomFieldConfigTypeSchema = z.object({
|
||||
// reference
|
||||
selectValueTypeList: z.array(z.enum(WorkflowIOValueTypeEnum)).optional(), // 可以选哪个数据类型, 只有1个的话,则默认选择
|
||||
showDefaultValue: z.boolean().optional(),
|
||||
showDescription: z.boolean().optional()
|
||||
});
|
||||
export type CustomFieldConfigType = z.infer<typeof CustomFieldConfigTypeSchema>;
|
||||
|
||||
export const InputComponentPropsTypeSchema = z.object({
|
||||
key: z.enum(NodeInputKeyEnum).or(z.string()),
|
||||
label: z.string(),
|
||||
|
||||
valueType: z.enum(WorkflowIOValueTypeEnum).optional(),
|
||||
required: z.boolean().optional(),
|
||||
defaultValue: z.any().optional(),
|
||||
|
||||
// 不同组件的配置嘻嘻
|
||||
referencePlaceholder: z.string().optional(),
|
||||
isRichText: z.boolean().optional(), // Prompt editor
|
||||
placeholder: z.string().optional(), // input,textarea
|
||||
maxLength: z.number().optional(), // input,textarea
|
||||
minLength: z.number().optional(), // password
|
||||
list: z.array(z.object({ label: z.string(), value: z.string() })).optional(), // select
|
||||
markList: z.array(z.object({ label: z.string(), value: z.number() })).optional(), // slider
|
||||
step: z.number().optional(), // slider
|
||||
max: z.number().optional(), // slider, number input
|
||||
min: z.number().optional(), // slider, number input
|
||||
precision: z.number().optional(), // number input
|
||||
llmModelType: z.enum(LLMModelTypeEnum).optional(), // ai model select
|
||||
|
||||
canSelectFile: z.boolean().optional(), // file select
|
||||
canSelectImg: z.boolean().optional(), // file select
|
||||
canSelectVideo: z.boolean().optional(), // file select
|
||||
canSelectAudio: z.boolean().optional(), // file select
|
||||
canSelectCustomFileExtension: z.boolean().optional(), // file select
|
||||
customFileExtensionList: z.array(z.string()).optional(), // file select
|
||||
canLocalUpload: z.boolean().optional(), // file select
|
||||
canUrlUpload: z.boolean().optional(), // file select
|
||||
maxFiles: z.number().optional(), // file select
|
||||
|
||||
// Time
|
||||
timeGranularity: z.enum(['day', 'hour', 'minute', 'second']).optional(), // time point select, time range select
|
||||
timeRangeStart: z.string().optional(), // time range select
|
||||
timeRangeEnd: z.string().optional(), // time range select
|
||||
|
||||
// dataset select
|
||||
datasetOptions: z.array(SelectedDatasetSchema).optional(),
|
||||
|
||||
// dynamic input
|
||||
customInputConfig: CustomFieldConfigTypeSchema.optional(),
|
||||
|
||||
// @deprecated
|
||||
enums: z.array(z.object({ value: z.string(), label: z.string() })).optional()
|
||||
});
|
||||
export type InputComponentPropsType = z.infer<typeof InputComponentPropsTypeSchema>;
|
||||
|
||||
// 输入配置
|
||||
export const InputConfigTypeSchema = z.object({
|
||||
key: z.string(),
|
||||
label: z.string(),
|
||||
description: z.string().optional(),
|
||||
required: z.boolean().optional(),
|
||||
inputType: z.enum(['input', 'numberInput', 'secret', 'switch', 'select']),
|
||||
value: SecretValueTypeSchema.optional(),
|
||||
|
||||
// Selector
|
||||
list: z.array(z.object({ label: z.string(), value: z.string() })).optional()
|
||||
});
|
||||
export type InputConfigType = z.infer<typeof InputConfigTypeSchema>;
|
||||
|
||||
// Workflow node input
|
||||
export const FlowNodeInputItemTypeSchema = InputComponentPropsTypeSchema.and(
|
||||
z.object({
|
||||
selectedTypeIndex: z.number().optional(),
|
||||
renderTypeList: z.array(z.enum(FlowNodeInputTypeEnum)), // Node Type. Decide on a render style
|
||||
valueDesc: z.string().optional(), // data desc
|
||||
value: z.any().optional(),
|
||||
|
||||
debugLabel: z.string().optional(),
|
||||
|
||||
description: z.string().optional(), // field desc
|
||||
toolDescription: z.string().optional(), // If this field is not empty, it is entered as a tool
|
||||
|
||||
enum: z.string().optional(),
|
||||
inputList: z.array(InputConfigTypeSchema).optional(), // when key === 'system_input_config', this field is used
|
||||
|
||||
// render components params
|
||||
canEdit: z.boolean().optional(), // dynamic inputs
|
||||
isPro: z.boolean().optional(), // Pro version field
|
||||
isToolOutput: z.boolean().optional(),
|
||||
|
||||
deprecated: z.boolean().optional() // node deprecated
|
||||
})
|
||||
);
|
||||
export type FlowNodeInputItemType = z.infer<typeof FlowNodeInputItemTypeSchema>;
|
||||
|
||||
// Workflow node output
|
||||
export const FlowNodeOutputItemTypeSchema = z.object({
|
||||
id: z.string(),
|
||||
key: z.enum(NodeOutputKeyEnum).or(z.string()),
|
||||
type: z.enum(FlowNodeOutputTypeEnum),
|
||||
valueType: z.enum(WorkflowIOValueTypeEnum).optional(),
|
||||
valueDesc: z.string().optional(),
|
||||
value: z.any().optional(),
|
||||
|
||||
label: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
defaultValue: z.any().optional(),
|
||||
required: z.boolean().optional(),
|
||||
|
||||
invalid: z.boolean().optional(),
|
||||
invalidCondition: z.optional(
|
||||
z.function({
|
||||
input: z.tuple([
|
||||
z.object({
|
||||
inputs: FlowNodeInputItemTypeSchema.array(),
|
||||
llmModelList: LLMModelItemSchema.array()
|
||||
})
|
||||
]),
|
||||
output: z.boolean()
|
||||
})
|
||||
),
|
||||
|
||||
customFieldConfig: CustomFieldConfigTypeSchema.optional(),
|
||||
deprecated: z.boolean().optional()
|
||||
});
|
||||
export type FlowNodeOutputItemType = z.infer<typeof FlowNodeOutputItemTypeSchema>;
|
||||
|
||||
/* Reference */
|
||||
export const ReferenceItemValueTypeSchema = z.tuple([z.string(), z.string().optional()]);
|
||||
export type ReferenceItemValueType = z.infer<typeof ReferenceItemValueTypeSchema>;
|
||||
export const ReferenceArrayValueTypeSchema = z.array(ReferenceItemValueTypeSchema);
|
||||
export type ReferenceArrayValueType = z.infer<typeof ReferenceArrayValueTypeSchema>;
|
||||
export const ReferenceValueTypeSchema = z.union([
|
||||
ReferenceItemValueTypeSchema,
|
||||
ReferenceArrayValueTypeSchema
|
||||
]);
|
||||
export type ReferenceValueType = z.infer<typeof ReferenceValueTypeSchema>;
|
||||
|
||||
/* http node */
|
||||
export const HttpParamAndHeaderItemTypeSchema = z.object({
|
||||
key: z.string(),
|
||||
type: z.string(),
|
||||
value: z.string()
|
||||
});
|
||||
export type HttpParamAndHeaderItemType = z.infer<typeof HttpParamAndHeaderItemTypeSchema>;
|
||||
|
|
@ -1,194 +0,0 @@
|
|||
import type { FlowNodeTypeEnum } from '../node/constant';
|
||||
import {
|
||||
WorkflowIOValueTypeEnum,
|
||||
NodeOutputKeyEnum,
|
||||
FlowNodeTemplateTypeEnum,
|
||||
VariableInputEnum
|
||||
} from '../constants';
|
||||
import { DispatchNodeResponseKeyEnum } from '../runtime/constants';
|
||||
import type { FlowNodeInputItemType, FlowNodeOutputItemType } from './io.d';
|
||||
import { UserModelSchema } from '../../../support/user/type';
|
||||
import type { ChatHistoryItemResType } from '../../chat/type';
|
||||
import {
|
||||
ChatItemType,
|
||||
ChatItemValueItemType,
|
||||
ToolRunResponseItemType,
|
||||
UserChatItemValueItemType
|
||||
} from '../../chat/type';
|
||||
import { ChatNodeUsageType } from '../../../support/wallet/bill/type';
|
||||
import { RuntimeNodeItemType } from '../runtime/type';
|
||||
import { RuntimeEdgeItemType, StoreEdgeItemType } from './edge';
|
||||
import { NextApiResponse } from 'next';
|
||||
import type { AppDetailType, AppSchema, HttpToolConfigType } from '../../app/type';
|
||||
import type { McpToolConfigType } from '../../app/tool/mcpTool/type';
|
||||
import type { ParentIdType } from '../../../common/parentFolder/type';
|
||||
import { AppTypeEnum } from '../../app/constants';
|
||||
import type { WorkflowInteractiveResponseType } from '../template/system/interactive/type';
|
||||
import type { StoreSecretValueType } from '../../../common/secret/type';
|
||||
import type { PluginStatusType } from '../../plugin/type';
|
||||
|
||||
export type NodeToolConfigType = {
|
||||
mcpToolSet?: {
|
||||
toolId: string; // ObjectId of the MCP App
|
||||
url: string;
|
||||
headerSecret?: StoreSecretValueType;
|
||||
toolList: McpToolConfigType[];
|
||||
};
|
||||
mcpTool?: {
|
||||
toolId: string;
|
||||
};
|
||||
systemTool?: {
|
||||
toolId: string;
|
||||
};
|
||||
systemToolSet?: {
|
||||
toolId: string;
|
||||
toolList: {
|
||||
toolId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
}[];
|
||||
};
|
||||
httpToolSet?: {
|
||||
toolList: HttpToolConfigType[];
|
||||
baseUrl?: string;
|
||||
apiSchemaStr?: string;
|
||||
customHeaders?: string;
|
||||
headerSecret?: StoreSecretValueType;
|
||||
};
|
||||
httpTool?: {
|
||||
toolId: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type FlowNodeCommonType = {
|
||||
parentNodeId?: string;
|
||||
flowNodeType: FlowNodeTypeEnum; // render node card
|
||||
abandon?: boolean; // abandon node
|
||||
|
||||
avatar?: string;
|
||||
name: string;
|
||||
intro?: string; // template list intro
|
||||
toolDescription?: string;
|
||||
showStatus?: boolean; // chatting response step status
|
||||
|
||||
version?: string;
|
||||
versionLabel?: string; // Just ui show
|
||||
isLatestVersion?: boolean; // Just ui show
|
||||
|
||||
// data
|
||||
catchError?: boolean;
|
||||
inputs: FlowNodeInputItemType[];
|
||||
outputs: FlowNodeOutputItemType[];
|
||||
|
||||
// plugin data
|
||||
pluginId?: string;
|
||||
isFolder?: boolean;
|
||||
pluginData?: PluginDataType;
|
||||
|
||||
// tool data
|
||||
toolConfig?: NodeToolConfigType;
|
||||
|
||||
// Not store, just computed
|
||||
currentCost?: number;
|
||||
systemKeyCost?: number;
|
||||
hasTokenFee?: boolean;
|
||||
hasSystemSecret?: boolean;
|
||||
};
|
||||
|
||||
export type PluginDataType = {
|
||||
diagram?: string;
|
||||
userGuide?: string;
|
||||
courseUrl?: string;
|
||||
name?: string;
|
||||
avatar?: string;
|
||||
error?: string;
|
||||
status?: PluginStatusType;
|
||||
};
|
||||
|
||||
type HandleType = {
|
||||
left: boolean;
|
||||
right: boolean;
|
||||
top: boolean;
|
||||
bottom: boolean;
|
||||
};
|
||||
// system template
|
||||
export type FlowNodeTemplateType = FlowNodeCommonType & {
|
||||
id: string; // node id, unique
|
||||
templateType: string;
|
||||
status?: PluginStatusType;
|
||||
|
||||
showSourceHandle?: boolean;
|
||||
showTargetHandle?: boolean;
|
||||
|
||||
// info
|
||||
isTool?: boolean; // can be connected by tool
|
||||
|
||||
// action
|
||||
forbidDelete?: boolean; // forbid delete
|
||||
unique?: boolean;
|
||||
|
||||
diagram?: string; // diagram url
|
||||
courseUrl?: string; // course url
|
||||
userGuide?: string; // user guide
|
||||
tags?: string[] | null;
|
||||
|
||||
// @deprecated
|
||||
sourceHandle?: HandleType;
|
||||
targetHandle?: HandleType;
|
||||
};
|
||||
|
||||
export type NodeTemplateListItemType = {
|
||||
id: string; // 系统节点-系统节点的 id, 系统插件-插件的 id,团队应用的 id
|
||||
flowNodeType: FlowNodeTypeEnum; // render node card
|
||||
parentId?: ParentIdType;
|
||||
isFolder?: boolean;
|
||||
templateType?: string;
|
||||
tags?: string[] | null;
|
||||
avatar?: string;
|
||||
name: string;
|
||||
intro?: string; // template list intro
|
||||
isTool?: boolean;
|
||||
authorAvatar?: string;
|
||||
author?: string;
|
||||
unique?: boolean; // 唯一的
|
||||
currentCost?: number; // 当前积分消耗
|
||||
systemKeyCost?: number; // 系统密钥费用,统一为数字
|
||||
hasTokenFee?: boolean; // 是否配置积分
|
||||
instructions?: string; // 使用说明
|
||||
courseUrl?: string; // 教程链接
|
||||
sourceMember?: SourceMember;
|
||||
toolSource?: 'uploaded' | 'built-in'; // Plugin source type
|
||||
};
|
||||
|
||||
export type NodeTemplateListType = {
|
||||
type: string;
|
||||
label: string;
|
||||
list: NodeTemplateListItemType[];
|
||||
}[];
|
||||
|
||||
// react flow node type
|
||||
export type FlowNodeItemType = FlowNodeTemplateType & {
|
||||
nodeId: string;
|
||||
parentNodeId?: string;
|
||||
isError?: boolean;
|
||||
searchedText?: string;
|
||||
debugResult?: {
|
||||
status: 'running' | 'success' | 'skipped' | 'failed';
|
||||
message?: string;
|
||||
showResult?: boolean; // show and hide result modal
|
||||
response?: ChatHistoryItemResType;
|
||||
isExpired?: boolean;
|
||||
workflowInteractiveResponse?: WorkflowInteractiveResponseType;
|
||||
};
|
||||
isFolded?: boolean;
|
||||
};
|
||||
|
||||
// store node type
|
||||
export type StoreNodeItemType = FlowNodeCommonType & {
|
||||
nodeId: string;
|
||||
// isEntry: boolean;
|
||||
position?: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,212 @@
|
|||
import { FlowNodeTypeEnum } from '../node/constant';
|
||||
import { FlowNodeInputItemTypeSchema, FlowNodeOutputItemTypeSchema } from './io';
|
||||
import { HttpToolConfigTypeSchema } from '../../app/tool/httpTool/type';
|
||||
import { McpToolConfigSchema } from '../../app/tool/mcpTool/type';
|
||||
import { ParentIdSchema } from '../../../common/parentFolder/type';
|
||||
import { InteractiveNodeResponseTypeSchema } from '../template/system/interactive/type';
|
||||
import { StoreSecretValueTypeSchema } from '../../../common/secret/type';
|
||||
import { PluginStatusSchema } from '../../plugin/type';
|
||||
import { SourceMemberSchema } from '../../../support/user/type';
|
||||
import z from 'zod';
|
||||
|
||||
export const NodeToolConfigTypeSchema = z.object({
|
||||
mcpToolSet: z
|
||||
.object({
|
||||
toolId: z.string(),
|
||||
url: z.string(),
|
||||
headerSecret: StoreSecretValueTypeSchema.optional(),
|
||||
toolList: z.array(McpToolConfigSchema)
|
||||
})
|
||||
.optional(),
|
||||
mcpTool: z
|
||||
.object({
|
||||
toolId: z.string()
|
||||
})
|
||||
.optional(),
|
||||
systemTool: z
|
||||
.object({
|
||||
toolId: z.string()
|
||||
})
|
||||
.optional(),
|
||||
systemToolSet: z
|
||||
.object({
|
||||
toolId: z.string(),
|
||||
toolList: z.array(
|
||||
z.object({
|
||||
toolId: z.string(),
|
||||
name: z.string(),
|
||||
description: z.string()
|
||||
})
|
||||
)
|
||||
})
|
||||
.optional(),
|
||||
httpToolSet: z
|
||||
.object({
|
||||
toolList: z.array(HttpToolConfigTypeSchema),
|
||||
baseUrl: z.string().optional(),
|
||||
apiSchemaStr: z.string().optional(),
|
||||
customHeaders: z.string().optional(),
|
||||
headerSecret: StoreSecretValueTypeSchema.optional()
|
||||
})
|
||||
.optional(),
|
||||
httpTool: z
|
||||
.object({
|
||||
toolId: z.string()
|
||||
})
|
||||
.optional()
|
||||
});
|
||||
export type NodeToolConfigType = z.infer<typeof NodeToolConfigTypeSchema>;
|
||||
|
||||
export const ToolDataSchema = z.object({
|
||||
diagram: z.string().optional(),
|
||||
userGuide: z.string().optional(),
|
||||
courseUrl: z.string().optional(),
|
||||
name: z.string().optional(),
|
||||
avatar: z.string().optional(),
|
||||
error: z.string().optional(),
|
||||
status: PluginStatusSchema.optional()
|
||||
});
|
||||
|
||||
export const FlowNodeCommonTypeSchema = z.object({
|
||||
parentNodeId: z.string().optional(),
|
||||
flowNodeType: z.enum(FlowNodeTypeEnum), // render node card
|
||||
abandon: z.boolean().optional(), // abandon node
|
||||
|
||||
avatar: z.string().optional(), // avatar
|
||||
name: z.string(), // name
|
||||
intro: z.string().optional(), // template list intro
|
||||
toolDescription: z.string().optional(), // tool description
|
||||
showStatus: z.boolean().optional(), // chatting response step status
|
||||
|
||||
version: z.string().optional(), // version
|
||||
versionLabel: z.string().optional(), // Just ui show
|
||||
isLatestVersion: z.boolean().optional(), // Just ui show
|
||||
|
||||
// data
|
||||
catchError: z.boolean().optional(),
|
||||
inputs: z.array(FlowNodeInputItemTypeSchema), // inputs
|
||||
outputs: z.array(FlowNodeOutputItemTypeSchema), // outputs
|
||||
|
||||
// plugin data
|
||||
pluginId: z.string().optional(), // plugin id
|
||||
isFolder: z.boolean().optional(),
|
||||
pluginData: ToolDataSchema.optional(),
|
||||
|
||||
// tool data
|
||||
toolConfig: NodeToolConfigTypeSchema.optional(),
|
||||
|
||||
// Not store, just computed
|
||||
currentCost: z.number().optional(),
|
||||
systemKeyCost: z.number().optional(),
|
||||
hasTokenFee: z.boolean().optional(),
|
||||
hasSystemSecret: z.boolean().optional()
|
||||
});
|
||||
export type FlowNodeCommonType = z.infer<typeof FlowNodeCommonTypeSchema>;
|
||||
|
||||
const HandleTypeSchema = z.object({
|
||||
left: z.boolean(),
|
||||
right: z.boolean(),
|
||||
top: z.boolean(),
|
||||
bottom: z.boolean()
|
||||
});
|
||||
|
||||
// system template
|
||||
export const FlowNodeTemplateTypeSchema = FlowNodeCommonTypeSchema.and(
|
||||
z.object({
|
||||
id: z.string(),
|
||||
templateType: z.string(),
|
||||
status: PluginStatusSchema.optional(),
|
||||
|
||||
showSourceHandle: z.boolean().optional(),
|
||||
showTargetHandle: z.boolean().optional(),
|
||||
|
||||
// Info
|
||||
isTool: z.boolean().optional(), // can be connected by tool
|
||||
|
||||
// Action
|
||||
forbidDelete: z.boolean().optional(), // forbid delete
|
||||
unique: z.boolean().optional(),
|
||||
|
||||
diagram: z.string().optional(),
|
||||
courseUrl: z.string().optional(),
|
||||
userGuide: z.string().optional(),
|
||||
tags: z.array(z.string()).nullish(),
|
||||
|
||||
// @deprecated
|
||||
sourceHandle: HandleTypeSchema.optional(),
|
||||
targetHandle: HandleTypeSchema.optional()
|
||||
})
|
||||
);
|
||||
export type FlowNodeTemplateType = z.infer<typeof FlowNodeTemplateTypeSchema>;
|
||||
|
||||
// Api response
|
||||
export const NodeTemplateListItemTypeSchema = z.object({
|
||||
id: z.string(), // 系统节点-系统节点的 id, 系统插件-插件的 id,团队应用的 id
|
||||
flowNodeType: z.enum(FlowNodeTypeEnum), // render node card
|
||||
parentId: ParentIdSchema.optional(),
|
||||
isFolder: z.boolean().optional(),
|
||||
templateType: z.string().optional(),
|
||||
tags: z.array(z.string()).nullish(),
|
||||
avatar: z.string().optional(),
|
||||
name: z.string(),
|
||||
intro: z.string().optional(), // template list intro
|
||||
isTool: z.boolean().optional(),
|
||||
|
||||
authorAvatar: z.string().optional(),
|
||||
author: z.string().optional(),
|
||||
|
||||
unique: z.boolean().optional(),
|
||||
|
||||
currentCost: z.number().optional(), // 当前积分消耗
|
||||
systemKeyCost: z.number().optional(), // 系统密钥费用,统一为数字
|
||||
hasTokenFee: z.boolean().optional(),
|
||||
instructions: z.string().optional(), // 使用说明
|
||||
courseUrl: z.string().optional(),
|
||||
sourceMember: SourceMemberSchema.optional(),
|
||||
toolSource: z.enum(['uploaded', 'built-in']).optional()
|
||||
});
|
||||
export type NodeTemplateListItemType = z.infer<typeof NodeTemplateListItemTypeSchema>;
|
||||
export const NodeTemplateListTypeSchema = z.array(
|
||||
z.object({
|
||||
type: z.string(),
|
||||
label: z.string(),
|
||||
list: z.array(NodeTemplateListItemTypeSchema)
|
||||
})
|
||||
);
|
||||
export type NodeTemplateListType = z.infer<typeof NodeTemplateListTypeSchema>;
|
||||
|
||||
// react flow node type
|
||||
export const FlowNodeItemSchema = FlowNodeTemplateTypeSchema.and(
|
||||
z.object({
|
||||
nodeId: z.string(),
|
||||
parentNodeId: z.string().optional(),
|
||||
isError: z.boolean().optional(),
|
||||
searchedText: z.string().optional(),
|
||||
debugResult: z
|
||||
.object({
|
||||
status: z.enum(['running', 'success', 'skipped', 'failed']),
|
||||
message: z.string().optional(),
|
||||
showResult: z.boolean().optional(),
|
||||
response: z.any().optional(),
|
||||
isExpired: z.boolean().optional(),
|
||||
interactiveResponse: InteractiveNodeResponseTypeSchema.optional()
|
||||
})
|
||||
.optional(),
|
||||
isFolded: z.boolean().optional()
|
||||
})
|
||||
);
|
||||
export type FlowNodeItemType = z.infer<typeof FlowNodeItemSchema>;
|
||||
|
||||
// store node type
|
||||
export const StoreNodeItemTypeSchema = FlowNodeCommonTypeSchema.and(
|
||||
z.object({
|
||||
nodeId: z.string(),
|
||||
position: z
|
||||
.object({
|
||||
x: z.number(),
|
||||
y: z.number()
|
||||
})
|
||||
.optional()
|
||||
})
|
||||
);
|
||||
export type StoreNodeItemType = z.infer<typeof StoreNodeItemTypeSchema>;
|
||||
|
|
@ -17,7 +17,7 @@ import {
|
|||
type FlowNodeOutputItemType,
|
||||
type ReferenceArrayValueType,
|
||||
type ReferenceItemValueType
|
||||
} from './type/io.d';
|
||||
} from './type/io';
|
||||
import { type StoreNodeItemType } from './type/node';
|
||||
import type {
|
||||
VariableItemType,
|
||||
|
|
@ -28,7 +28,7 @@ import type {
|
|||
AppChatConfigType,
|
||||
AppAutoExecuteConfigType,
|
||||
AppQGConfigType,
|
||||
AppSchema
|
||||
AppSchemaType
|
||||
} from '../app/type';
|
||||
import { type EditorVariablePickerType } from '../../../web/components/common/Textarea/PromptEditor/type';
|
||||
import {
|
||||
|
|
@ -428,7 +428,7 @@ export const removeUnauthModels = async ({
|
|||
modules,
|
||||
allowedModels = new Set()
|
||||
}: {
|
||||
modules: AppSchema['modules'];
|
||||
modules: AppSchemaType['modules'];
|
||||
allowedModels?: Set<string>;
|
||||
}) => {
|
||||
if (modules) {
|
||||
|
|
|
|||
|
|
@ -12,18 +12,22 @@ export type MarketplaceToolListItemType = ToolSimpleType & {
|
|||
downloadCount: number;
|
||||
};
|
||||
|
||||
export const MarketplaceToolDetailItemSchema = formatToolDetailSchema.extend({
|
||||
readme: z.string().optional()
|
||||
});
|
||||
export const MarketplaceToolDetailItemSchema = formatToolDetailSchema.and(
|
||||
z.object({
|
||||
readme: z.string().optional()
|
||||
})
|
||||
);
|
||||
export const MarketplaceToolDetailSchema = z.object({
|
||||
tools: z.array(MarketplaceToolDetailItemSchema)
|
||||
});
|
||||
|
||||
// List
|
||||
export const GetMarketplaceToolsBodySchema = PaginationSchema.extend({
|
||||
searchKey: z.string().optional(),
|
||||
tags: z.array(z.string()).nullish()
|
||||
});
|
||||
export const GetMarketplaceToolsBodySchema = PaginationSchema.and(
|
||||
z.object({
|
||||
searchKey: z.string().optional(),
|
||||
tags: z.array(z.string()).nullish()
|
||||
})
|
||||
);
|
||||
export type GetMarketplaceToolsBodyType = z.infer<typeof GetMarketplaceToolsBodySchema>;
|
||||
|
||||
export const MarketplaceToolsResponseSchema = z.object({
|
||||
|
|
|
|||
|
|
@ -17,17 +17,21 @@ export const DiscountCouponSchema = z.object({
|
|||
|
||||
export type DiscountCouponSchemaType = z.infer<typeof DiscountCouponSchema>;
|
||||
|
||||
export const DiscountCouponItemSchema = DiscountCouponSchema.extend({
|
||||
name: z.string().meta({ description: '优惠券名称' }),
|
||||
description: z.string().meta({ description: '优惠券描述' }),
|
||||
discount: z.number().min(0).max(1).meta({ description: '折扣率' }),
|
||||
iconZh: z.string().meta({ description: '中文图标路径' }),
|
||||
iconEn: z.string().meta({ description: '英文图标路径' }),
|
||||
status: z.enum(DiscountCouponStatusEnum).meta({ description: '优惠券状态' }),
|
||||
billId: ObjectIdSchema.optional().meta({
|
||||
description: '关联的订单 ID, 被使用后该值存在'
|
||||
export const DiscountCouponItemSchema = DiscountCouponSchema.and(
|
||||
z.object({
|
||||
name: z.string().meta({ description: '优惠券名称' }),
|
||||
description: z.string().meta({ description: '优惠券描述' }),
|
||||
discount: z.number().min(0).max(1).meta({ description: '折扣率' }),
|
||||
iconZh: z.string().meta({ description: '中文图标路径' }),
|
||||
iconEn: z.string().meta({ description: '英文图标路径' }),
|
||||
status: z.enum(DiscountCouponStatusEnum).meta({ description: '优惠券状态' }),
|
||||
billId: ObjectIdSchema.optional().meta({
|
||||
description: '关联的订单 ID, 被使用后该值存在'
|
||||
})
|
||||
})
|
||||
});
|
||||
export const DiscountCouponListResponseSchema = z.array(DiscountCouponItemSchema);
|
||||
);
|
||||
export const DiscountCouponListResponseSchema = z
|
||||
.array(DiscountCouponItemSchema)
|
||||
.meta({ description: '优惠券列表' });
|
||||
|
||||
export type DiscountCouponListResponseType = z.infer<typeof DiscountCouponListResponseSchema>;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { AppSchema } from '../../core/app/type';
|
||||
import { AppSchemaType } from '../../core/app/type';
|
||||
import type { PublishChannelEnum } from './constant';
|
||||
import { RequireOnlyOne } from '../../common/type/utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import z from 'zod';
|
||||
import type { LangEnum } from '../../common/i18n/type';
|
||||
import type { TeamPermission } from '../permission/user/controller';
|
||||
import type { UserStatusEnum } from './constant';
|
||||
import { TeamMemberStatusEnum } from './team/constant';
|
||||
import type { TeamTmbItemType } from './team/type';
|
||||
import z from 'zod';
|
||||
|
||||
export type UserModelSchema = {
|
||||
_id: string;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ export class S3HelperBotSource {
|
|||
|
||||
// 获取文件流
|
||||
getFileStream(key: string) {
|
||||
return this.bucket.getObject(key);
|
||||
return this.bucket.getFileStream(key);
|
||||
}
|
||||
|
||||
// 获取文件状态
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { ObVectorCtrl } from './oceanbase';
|
|||
import { getVectorsByText } from '../../core/ai/embedding';
|
||||
import type { EmbeddingRecallCtrlProps } from './controller.d';
|
||||
import { type DelDatasetVectorCtrlProps, type InsertVectorProps } from './controller.d';
|
||||
import { type EmbeddingModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { type EmbeddingModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import { MILVUS_ADDRESS, PG_ADDRESS, OCEANBASE_ADDRESS } from './constants';
|
||||
import { MilvusCtrl } from './milvus';
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import type fs from 'fs';
|
|||
import { getAxiosConfig } from '../config';
|
||||
import axios from 'axios';
|
||||
import FormData from 'form-data';
|
||||
import { type STTModelType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { type STTModelType } from '@fastgpt/global/core/ai/model';
|
||||
import { UserError } from '@fastgpt/global/common/error/utils';
|
||||
|
||||
export const aiTranscriptions = async ({
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { SystemDefaultModelType, SystemModelItemType } from '../type';
|
||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||
import { ModelTypeEnum } from '@fastgpt/global/core/ai/constants';
|
||||
import { MongoSystemModel } from './schema';
|
||||
import {
|
||||
type LLMModelItemType,
|
||||
|
|
@ -7,7 +7,7 @@ import {
|
|||
type TTSModelType,
|
||||
type STTModelType,
|
||||
type RerankModelItemType
|
||||
} from '@fastgpt/global/core/ai/model.d';
|
||||
} from '@fastgpt/global/core/ai/model';
|
||||
import { debounce } from 'lodash';
|
||||
import { getModelProvider } from '../../../core/app/provider/controller';
|
||||
import { findModelFromAlldata } from '../model';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { type EmbeddingModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { type EmbeddingModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import { getAIApi } from '../config';
|
||||
import { countPromptTokens } from '../../../common/string/tiktoken/index';
|
||||
import { EmbeddingTypeEnm } from '@fastgpt/global/core/ai/constants';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type.d';
|
||||
import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type';
|
||||
import {
|
||||
QuestionGuidePrompt,
|
||||
QuestionGuideFooterPrompt
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import { countGptMessagesTokens } from '../../../../common/string/tiktoken';
|
||||
import { addLog } from '../../../../common/system/log';
|
||||
import { calculateCompressionThresholds } from './constants';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type';
|
||||
import { calculateCompressionThresholds } from './constants';
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import { ChatCompletionRequestMessageRoleEnum } from '@fastgpt/global/core/ai/co
|
|||
import { countGptMessagesTokens } from '../../../common/string/tiktoken/index';
|
||||
import { loadRequestMessages } from './utils';
|
||||
import { addLog } from '../../../common/system/log';
|
||||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import json5 from 'json5';
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import type {
|
|||
ChatCompletionContentPartText,
|
||||
ChatCompletionMessageParam,
|
||||
SdkChatCompletionMessageParam
|
||||
} from '@fastgpt/global/core/ai/type.d';
|
||||
} from '@fastgpt/global/core/ai/type';
|
||||
import axios from 'axios';
|
||||
import { ChatCompletionRequestMessageRoleEnum } from '@fastgpt/global/core/ai/constants';
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { cloneDeep } from 'lodash';
|
||||
import { type SystemModelItemType } from './type';
|
||||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
|
||||
export const getDefaultLLMModel = () => global?.systemDefaultModel.llm!;
|
||||
export const getLLMModel = (model?: string | LLMModelItemType) => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { addLog } from '../../../common/system/log';
|
|||
import { POST } from '../../../common/api/serverRequest';
|
||||
import { getDefaultRerankModel } from '../model';
|
||||
import { getAxiosConfig } from '../config';
|
||||
import { type RerankModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { type RerankModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import { countPromptTokens } from '../../../common/string/tiktoken';
|
||||
|
||||
type PostReRankResponse = {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
import type { ModelTypeEnum } from '@fastgpt/global/core/ai/model';
|
||||
import type { ModelTypeEnum } from '@fastgpt/global/core/ai/constants';
|
||||
import type {
|
||||
STTModelType,
|
||||
RerankModelItemType,
|
||||
TTSModelType,
|
||||
EmbeddingModelItemType,
|
||||
LLMModelItemType
|
||||
} from '@fastgpt/global/core/ai/model.d';
|
||||
import type { ModelProviderListType } from '@fastgpt/global/core/app/model/type';
|
||||
} from '@fastgpt/global/core/ai/model';
|
||||
import type {
|
||||
AiproxyMapProviderType,
|
||||
I18nStringStrictType
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { type LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { type LLMModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import type { CompletionFinishReason, CompletionUsage } from '@fastgpt/global/core/ai/type';
|
||||
import { getLLMDefaultUsage } from '@fastgpt/global/core/ai/constants';
|
||||
import { removeDatasetCiteText } from '@fastgpt/global/core/ai/llm/utils';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { type AppSchema } from '@fastgpt/global/core/app/type';
|
||||
import { type AppSchemaType } from '@fastgpt/global/core/app/type';
|
||||
import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import {
|
||||
FlowNodeInputTypeEnum,
|
||||
|
|
@ -92,7 +92,7 @@ export async function findAppAndAllChildren({
|
|||
teamId: string;
|
||||
appId: string;
|
||||
fields?: string;
|
||||
}): Promise<AppSchema[]> {
|
||||
}): Promise<AppSchemaType[]> {
|
||||
const find = async (id: string) => {
|
||||
const children = await MongoApp.find(
|
||||
{
|
||||
|
|
@ -140,7 +140,7 @@ export const deleteAppDataProcessor = async ({
|
|||
app,
|
||||
teamId
|
||||
}: {
|
||||
app: AppSchema;
|
||||
app: AppSchemaType;
|
||||
teamId: string;
|
||||
}) => {
|
||||
const appId = String(app._id);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { getSecretValue } from '../../common/secret/utils';
|
|||
import axios from 'axios';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import type { RequireOnlyOne } from '@fastgpt/global/common/type/utils';
|
||||
import type { HttpToolConfigType } from '@fastgpt/global/core/app/type';
|
||||
import type { HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type';
|
||||
import { contentTypeMap, ContentTypes } from '@fastgpt/global/core/workflow/constants';
|
||||
import { replaceEditorVariable } from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
||||
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
||||
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
||||
import type { AppSchema } from '@fastgpt/global/core/app/type';
|
||||
import type { AppSchemaType } from '@fastgpt/global/core/app/type';
|
||||
import { type McpToolConfigType } from '@fastgpt/global/core/app/tool/mcpTool/type';
|
||||
import { addLog } from '../../common/system/log';
|
||||
import { retryFn } from '@fastgpt/global/common/system/utils';
|
||||
|
|
@ -154,7 +154,7 @@ export class MCPClient {
|
|||
}
|
||||
}
|
||||
|
||||
export const getMCPChildren = async (app: AppSchema) => {
|
||||
export const getMCPChildren = async (app: AppSchemaType) => {
|
||||
const isNewMcp = !!app.modules[0].toolConfig?.mcpToolSet;
|
||||
const id = String(app._id);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
|
||||
import { Schema, getMongoModel } from '../../common/mongo';
|
||||
import type { AppSchema as AppType } from '@fastgpt/global/core/app/type.d';
|
||||
import type { AppSchemaType as AppType } from '@fastgpt/global/core/app/type';
|
||||
import {
|
||||
TeamCollectionName,
|
||||
TeamMemberCollectionName
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type {
|
||||
NodeToolConfigType,
|
||||
FlowNodeTemplateType
|
||||
} from '@fastgpt/global/core/workflow/type/node.d';
|
||||
} from '@fastgpt/global/core/workflow/type/node';
|
||||
import {
|
||||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeInputTypeEnum,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { type AppSchema } from '@fastgpt/global/core/app/type';
|
||||
import { type AppSchemaType } from '@fastgpt/global/core/app/type';
|
||||
import { MongoAppVersion } from './schema';
|
||||
import { Types } from '../../../common/mongo';
|
||||
|
||||
export const getAppLatestVersion = async (appId: string, app?: AppSchema) => {
|
||||
export const getAppLatestVersion = async (appId: string, app?: AppSchemaType) => {
|
||||
const version = await MongoAppVersion.findOne({
|
||||
appId,
|
||||
isPublish: true
|
||||
|
|
@ -37,7 +37,7 @@ export const getAppVersionById = async ({
|
|||
}: {
|
||||
appId: string;
|
||||
versionId?: string;
|
||||
app?: AppSchema;
|
||||
app?: AppSchemaType;
|
||||
}) => {
|
||||
// 检查 versionId 是否符合 ObjectId 格式
|
||||
if (versionId && Types.ObjectId.isValid(versionId)) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import { MongoDatasetDataText } from '../data/dataTextSchema';
|
|||
import { type ChatItemType } from '@fastgpt/global/core/chat/type';
|
||||
import type { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { datasetSearchQueryExtension } from './utils';
|
||||
import type { RerankModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import type { RerankModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import { formatDatasetDataValue } from '../data/controller';
|
||||
import { pushTrack } from '../../../common/middle/tracks/utils';
|
||||
import { replaceS3KeyToPreviewUrl } from '../../../core/dataset/utils';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type.d';
|
||||
import type { ChatCompletionMessageParam } from '@fastgpt/global/core/ai/type';
|
||||
import { createLLMResponse, type ResponseEvents } from '../../../../../../ai/llm/request';
|
||||
import { getLLMModel } from '../../../../../../ai/model';
|
||||
import { formatModelChars2Points } from '../../../../../../../support/wallet/usage/utils';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import type {
|
||||
ChatCompletionMessageParam,
|
||||
ChatCompletionTool
|
||||
} from '@fastgpt/global/core/ai/type.d';
|
||||
import type { ChatCompletionMessageParam, ChatCompletionTool } from '@fastgpt/global/core/ai/type';
|
||||
import { createLLMResponse } from '../../../../../../ai/llm/request';
|
||||
import {
|
||||
getPlanAgentSystemPrompt,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import type { ChatItemType, UserChatItemFileItemType } from '@fastgpt/global/cor
|
|||
import { ChatRoleEnum } from '@fastgpt/global/core/chat/constants';
|
||||
import { SseResponseEventEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
import { textAdaptGptResponse } from '@fastgpt/global/core/workflow/runtime/utils';
|
||||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import type {
|
||||
ChatDispatchProps,
|
||||
DispatchNodeResultType
|
||||
|
|
@ -20,7 +20,7 @@ import {
|
|||
getQuotePrompt,
|
||||
getDocumentQuotePrompt
|
||||
} from '@fastgpt/global/core/ai/prompt/AIChat';
|
||||
import type { AIChatNodeProps } from '@fastgpt/global/core/workflow/runtime/type.d';
|
||||
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 { getLLMModel } from '../../../ai/model';
|
||||
|
|
|
|||
|
|
@ -7,14 +7,13 @@ import { NodeOutputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
|||
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { getCQSystemPrompt } from '@fastgpt/global/core/ai/prompt/agent';
|
||||
import { type LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { type LLMModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import { getLLMModel } from '../../../ai/model';
|
||||
import { getHistories } from '../utils';
|
||||
import { formatModelChars2Points } from '../../../../support/wallet/usage/utils';
|
||||
import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { getHandleId } from '@fastgpt/global/core/workflow/utils';
|
||||
import { addLog } from '../../../../common/system/log';
|
||||
import { ModelTypeEnum } from '../../../../../global/core/ai/model';
|
||||
import { createLLMResponse } from '../../../ai/llm/request';
|
||||
|
||||
type Props = ModuleDispatchProps<{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { sliceJsonStr } from '@fastgpt/global/common/string/tools';
|
||||
import { type LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import { type LLMModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import { getNodeErrResponse, getHistories } from '../utils';
|
||||
import { getLLMModel } from '../../../ai/model';
|
||||
import { formatModelChars2Points } from '../../../../support/wallet/usage/utils';
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/
|
|||
import type { DispatchFlowResponse } from '../../type';
|
||||
import type { AIChatItemValueItemType, ChatItemType } from '@fastgpt/global/core/chat/type';
|
||||
import type { ToolCallChildrenInteractive } from '@fastgpt/global/core/workflow/template/system/interactive/type';
|
||||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
import type { LLMModelItemType } from '@fastgpt/global/core/ai/model';
|
||||
import type { JSONSchemaInputType } from '@fastgpt/global/core/app/jsonschema';
|
||||
|
||||
export type DispatchToolModuleProps = ModuleDispatchProps<{
|
||||
|
|
|
|||
|
|
@ -58,7 +58,9 @@ export const dispatchRunAppNode = async (props: Props): Promise<Response> => {
|
|||
|
||||
const userInputFiles = (() => {
|
||||
if (fileUrlList) {
|
||||
return fileUrlList.map((url) => parseUrlToFileType(url)).filter(Boolean);
|
||||
return fileUrlList
|
||||
.map((url) => parseUrlToFileType(url))
|
||||
.filter((file): file is NonNullable<typeof file> => Boolean(file));
|
||||
}
|
||||
// Adapt version 4.8.13 upgrade
|
||||
return files;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
|||
import { MCPClient } from '../../../app/mcp';
|
||||
import { getSecretValue } from '../../../../common/secret/utils';
|
||||
import type { McpToolDataType } from '@fastgpt/global/core/app/tool/mcpTool/type';
|
||||
import type { HttpToolConfigType } from '@fastgpt/global/core/app/type';
|
||||
import type { HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type';
|
||||
import { APIRunSystemTool } from '../../../app/tool/api';
|
||||
import { MongoSystemTool } from '../../../plugin/tool/systemToolSchema';
|
||||
import { SystemToolSecretInputTypeEnum } from '@fastgpt/global/core/app/tool/systemTool/constants';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type.d';
|
||||
import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { formatModelChars2Points } from '../../../../support/wallet/usage/utils';
|
||||
import type { SelectedDatasetType } from '@fastgpt/global/core/workflow/type/io';
|
||||
import type { SearchDataResponseItemType } from '@fastgpt/global/core/dataset/type';
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import type {
|
|||
ModuleDispatchProps,
|
||||
SystemVariablesType
|
||||
} from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type.d';
|
||||
import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { getErrText, UserError } from '@fastgpt/global/common/error/utils';
|
||||
import { filterPublicNodeResponseData } from '@fastgpt/global/core/chat/utils';
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { ModuleDispatchProps } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type.d';
|
||||
import { type DispatchNodeResultType } from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||
|
||||
export type PluginOutputProps = ModuleDispatchProps<{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import type {
|
|||
InteractiveNodeResponseType,
|
||||
WorkflowInteractiveResponseType
|
||||
} from '@fastgpt/global/core/workflow/template/system/interactive/type';
|
||||
import type { RuntimeEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import { type RuntimeEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import type { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type';
|
||||
import z from 'zod';
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import { NodeOutputKeyEnum, VariableInputEnum } from '@fastgpt/global/core/workf
|
|||
import type { VariableItemType } from '@fastgpt/global/core/app/type';
|
||||
import { encryptSecret } from '../../../common/secret/aes256gcm';
|
||||
import {
|
||||
type RuntimeEdgeItemType,
|
||||
type RuntimeNodeItemType,
|
||||
type SystemVariablesType
|
||||
} from '@fastgpt/global/core/workflow/runtime/type';
|
||||
import type { RuntimeEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import { responseWrite } from '../../../common/response';
|
||||
import { type NextApiResponse } from 'next';
|
||||
import {
|
||||
|
|
@ -24,7 +24,7 @@ import { MongoApp } from '../../../core/app/schema';
|
|||
import { getMCPChildren } from '../../../core/app/mcp';
|
||||
import { getSystemToolRunTimeNodeFromSystemToolset } from '../utils';
|
||||
import type { localeType } from '@fastgpt/global/common/i18n/type';
|
||||
import type { HttpToolConfigType } from '@fastgpt/global/core/app/type';
|
||||
import type { HttpToolConfigType } from '@fastgpt/global/core/app/tool/httpTool/type';
|
||||
import type { WorkflowResponseType } from './type';
|
||||
|
||||
export const getWorkflowResponseWrite = ({
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Auth app permission */
|
||||
import { MongoApp } from '../../../core/app/schema';
|
||||
import { type AppDetailType } from '@fastgpt/global/core/app/type.d';
|
||||
import { type AppDetailType } from '@fastgpt/global/core/app/type';
|
||||
import {
|
||||
NullRoleVal,
|
||||
PerResourceTypeEnum,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
STTModelType,
|
||||
EmbeddingModelItemType,
|
||||
LLMModelItemType
|
||||
} from '@fastgpt/global/core/ai/model.d';
|
||||
} from '@fastgpt/global/core/ai/model';
|
||||
import type { SubPlanType } from '@fastgpt/global/support/wallet/sub/type';
|
||||
import type { WorkerNameEnum, WorkerPool } from './worker/utils';
|
||||
import { Worker } from 'worker_threads';
|
||||
|
|
|
|||
|
|
@ -24590,4 +24590,4 @@ snapshots:
|
|||
immer: 9.0.21
|
||||
react: 18.3.1
|
||||
|
||||
zwitch@2.0.4: {}
|
||||
zwitch@2.0.4: {}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React, { useState } from 'react';
|
||||
import MyModal from '@fastgpt/web/components/common/MyModal';
|
||||
import { Box, Button, Flex, Grid, useTheme } from '@chakra-ui/react';
|
||||
import { type PromptTemplateItem } from '@fastgpt/global/core/ai/type.d';
|
||||
import { type PromptTemplateItem } from '@fastgpt/global/core/ai/type';
|
||||
import { ModalBody, ModalFooter } from '@chakra-ui/react';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
const PromptTemplate = ({
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import { Box, type BoxProps, Flex } from '@chakra-ui/react';
|
||||
import { type ParentTreePathItemType } from '@fastgpt/global/common/parentFolder/type';
|
||||
import type {
|
||||
ParentIdType,
|
||||
ParentTreePathItemType
|
||||
} from '@fastgpt/global/common/parentFolder/type';
|
||||
import React, { useMemo } from 'react';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
|
|
@ -10,7 +13,7 @@ const FolderPath = (props: {
|
|||
paths: ParentTreePathItemType[];
|
||||
rootName?: string;
|
||||
FirstPathDom?: React.ReactNode;
|
||||
onClick: (parentId: string) => void;
|
||||
onClick: (parentId: ParentIdType) => void;
|
||||
fontSize?: string;
|
||||
hoverStyle?: BoxProps;
|
||||
forbidLastClick?: boolean;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue