@fastgpt-plugin/helpers 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/fn.d.ts +18 -0
- package/dist/common/fn.js +48 -0
- package/dist/common/fs.d.ts +12 -0
- package/dist/common/fs.js +24 -0
- package/dist/common/schemas/i18n.d.ts +17 -0
- package/dist/common/schemas/i18n.js +3 -0
- package/dist/common/schemas/s3.d.ts +2 -0
- package/dist/common/schemas/s3.js +14 -0
- package/dist/common/zip.d.ts +15 -0
- package/dist/common/zip.js +4 -0
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.js +1 -0
- package/dist/events/schemas.d.ts +3 -0
- package/dist/events/schemas.js +50 -0
- package/dist/events/type.d.ts +3 -0
- package/dist/events/type.js +1 -0
- package/dist/fastgpt-ATrPZt7b.js +122 -0
- package/dist/i18n-CEMsaKK_.js +16 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/models/schemas.d.ts +234 -0
- package/dist/models/schemas.js +74 -0
- package/dist/req-Cgf43aEm.js +55 -0
- package/dist/s3-CkZHJIa9.d.ts +14 -0
- package/dist/schemas-CMeQg8vV.d.ts +137 -0
- package/dist/tools/constants.d.ts +75 -0
- package/dist/tools/constants.js +72 -0
- package/dist/tools/helper.d.ts +260 -0
- package/dist/tools/helper.js +55 -0
- package/dist/tools/schemas/fastgpt.d.ts +203 -0
- package/dist/tools/schemas/fastgpt.js +3 -0
- package/dist/tools/schemas/req.d.ts +3 -0
- package/dist/tools/schemas/req.js +3 -0
- package/dist/tools/schemas/tool.d.ts +2157 -0
- package/dist/tools/schemas/tool.js +132 -0
- package/dist/workflows/schemas.d.ts +45 -0
- package/dist/workflows/schemas.js +26 -0
- package/dist/zip-DjBhByRt.js +8857 -0
- package/package.json +36 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z as z$1 } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/models/schemas.ts
|
|
4
|
+
let ModelTypeEnum = /* @__PURE__ */ function(ModelTypeEnum) {
|
|
5
|
+
ModelTypeEnum["llm"] = "llm";
|
|
6
|
+
ModelTypeEnum["embedding"] = "embedding";
|
|
7
|
+
ModelTypeEnum["rerank"] = "rerank";
|
|
8
|
+
ModelTypeEnum["tts"] = "tts";
|
|
9
|
+
ModelTypeEnum["stt"] = "stt";
|
|
10
|
+
return ModelTypeEnum;
|
|
11
|
+
}({});
|
|
12
|
+
const PriceSchema = z$1.object({
|
|
13
|
+
charsPointsPrice: z$1.number().optional(),
|
|
14
|
+
inputPrice: z$1.number().optional(),
|
|
15
|
+
outputPrice: z$1.number().optional()
|
|
16
|
+
});
|
|
17
|
+
const BaseModelItemSchema = z$1.object({
|
|
18
|
+
provider: z$1.string(),
|
|
19
|
+
model: z$1.string(),
|
|
20
|
+
name: z$1.string()
|
|
21
|
+
});
|
|
22
|
+
const LLMModelItemSchema = PriceSchema.extend(BaseModelItemSchema.shape).extend({
|
|
23
|
+
type: z$1.literal(ModelTypeEnum.llm),
|
|
24
|
+
maxContext: z$1.number(),
|
|
25
|
+
maxTokens: z$1.number(),
|
|
26
|
+
quoteMaxToken: z$1.number(),
|
|
27
|
+
maxTemperature: z$1.union([z$1.number(), z$1.null()]),
|
|
28
|
+
showTopP: z$1.boolean().optional(),
|
|
29
|
+
responseFormatList: z$1.array(z$1.string()).optional(),
|
|
30
|
+
showStopSign: z$1.boolean().optional(),
|
|
31
|
+
censor: z$1.boolean().optional(),
|
|
32
|
+
vision: z$1.boolean(),
|
|
33
|
+
reasoning: z$1.boolean(),
|
|
34
|
+
toolChoice: z$1.boolean(),
|
|
35
|
+
datasetProcess: z$1.boolean().optional(),
|
|
36
|
+
usedInClassify: z$1.boolean().optional(),
|
|
37
|
+
usedInExtractFields: z$1.boolean().optional(),
|
|
38
|
+
usedInToolCall: z$1.boolean().optional(),
|
|
39
|
+
useInEvaluation: z$1.boolean().optional(),
|
|
40
|
+
defaultSystemChatPrompt: z$1.string().optional(),
|
|
41
|
+
defaultConfig: z$1.record(z$1.string(), z$1.any()).optional(),
|
|
42
|
+
fieldMap: z$1.record(z$1.string(), z$1.string()).optional()
|
|
43
|
+
});
|
|
44
|
+
const EmbeddingModelItemSchema = PriceSchema.extend(BaseModelItemSchema.shape).extend({
|
|
45
|
+
type: z$1.literal(ModelTypeEnum.embedding),
|
|
46
|
+
defaultToken: z$1.number(),
|
|
47
|
+
maxToken: z$1.number(),
|
|
48
|
+
weight: z$1.number().optional(),
|
|
49
|
+
hidden: z$1.boolean().optional(),
|
|
50
|
+
normalization: z$1.boolean().optional(),
|
|
51
|
+
defaultConfig: z$1.record(z$1.string(), z$1.any()).optional(),
|
|
52
|
+
dbConfig: z$1.record(z$1.string(), z$1.any()).optional(),
|
|
53
|
+
queryConfig: z$1.record(z$1.string(), z$1.any()).optional()
|
|
54
|
+
});
|
|
55
|
+
const RerankModelItemSchema = PriceSchema.extend(BaseModelItemSchema.shape).extend({ type: z$1.literal(ModelTypeEnum.rerank) });
|
|
56
|
+
const TTSModelSchema = PriceSchema.extend(BaseModelItemSchema.shape).extend({
|
|
57
|
+
type: z$1.literal(ModelTypeEnum.tts),
|
|
58
|
+
voices: z$1.array(z$1.object({
|
|
59
|
+
label: z$1.string(),
|
|
60
|
+
value: z$1.string()
|
|
61
|
+
}))
|
|
62
|
+
});
|
|
63
|
+
const STTModelSchema = PriceSchema.extend(BaseModelItemSchema.shape).extend({ type: z$1.literal(ModelTypeEnum.stt) });
|
|
64
|
+
const ModelItemSchema = z$1.discriminatedUnion("type", [
|
|
65
|
+
LLMModelItemSchema,
|
|
66
|
+
EmbeddingModelItemSchema,
|
|
67
|
+
RerankModelItemSchema,
|
|
68
|
+
TTSModelSchema,
|
|
69
|
+
STTModelSchema
|
|
70
|
+
]);
|
|
71
|
+
const ListModelsSchema = z$1.array(ModelItemSchema);
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
export { EmbeddingModelItemSchema, LLMModelItemSchema, ListModelsSchema, ModelItemSchema, ModelTypeEnum, RerankModelItemSchema, STTModelSchema, TTSModelSchema };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z as z$1 } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/tools/schemas/req.ts
|
|
4
|
+
const ToolHandlerReturnSchema = z$1.object({
|
|
5
|
+
error: z$1.union([z$1.string(), z$1.record(z$1.string(), z$1.any())]).optional(),
|
|
6
|
+
output: z$1.record(z$1.string(), z$1.any()).optional()
|
|
7
|
+
});
|
|
8
|
+
const SystemVarSchema = z$1.object({
|
|
9
|
+
user: z$1.object({
|
|
10
|
+
id: z$1.string(),
|
|
11
|
+
username: z$1.string(),
|
|
12
|
+
contact: z$1.string(),
|
|
13
|
+
membername: z$1.string(),
|
|
14
|
+
teamName: z$1.string(),
|
|
15
|
+
teamId: z$1.string(),
|
|
16
|
+
name: z$1.string()
|
|
17
|
+
}),
|
|
18
|
+
app: z$1.object({
|
|
19
|
+
id: z$1.string(),
|
|
20
|
+
name: z$1.string()
|
|
21
|
+
}),
|
|
22
|
+
tool: z$1.object({
|
|
23
|
+
id: z$1.string(),
|
|
24
|
+
version: z$1.string(),
|
|
25
|
+
prefix: z$1.string().optional()
|
|
26
|
+
}),
|
|
27
|
+
time: z$1.string()
|
|
28
|
+
});
|
|
29
|
+
const StreamMessageTypeEnum = z$1.enum([
|
|
30
|
+
"response",
|
|
31
|
+
"error",
|
|
32
|
+
"stream"
|
|
33
|
+
]);
|
|
34
|
+
const StreamDataAnswerTypeEnum = z$1.enum(["answer", "fastAnswer"]);
|
|
35
|
+
const StreamDataSchema = z$1.object({
|
|
36
|
+
type: StreamDataAnswerTypeEnum,
|
|
37
|
+
content: z$1.string()
|
|
38
|
+
});
|
|
39
|
+
const StreamMessageSchema = z$1.discriminatedUnion("type", [
|
|
40
|
+
z$1.object({
|
|
41
|
+
type: StreamMessageTypeEnum.enum.response,
|
|
42
|
+
data: ToolHandlerReturnSchema
|
|
43
|
+
}),
|
|
44
|
+
z$1.object({
|
|
45
|
+
type: StreamMessageTypeEnum.enum.stream,
|
|
46
|
+
data: StreamDataSchema
|
|
47
|
+
}),
|
|
48
|
+
z$1.object({
|
|
49
|
+
type: StreamMessageTypeEnum.enum.error,
|
|
50
|
+
data: z$1.string()
|
|
51
|
+
})
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { SystemVarSchema as a, StreamMessageTypeEnum as i, StreamDataSchema as n, ToolHandlerReturnSchema as o, StreamMessageSchema as r, StreamDataAnswerTypeEnum as t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/common/schemas/s3.d.ts
|
|
4
|
+
declare const FileMetadataSchema: z.ZodObject<{
|
|
5
|
+
originalFilename: z.ZodString;
|
|
6
|
+
contentType: z.ZodString;
|
|
7
|
+
size: z.ZodNumber;
|
|
8
|
+
uploadTime: z.ZodDate;
|
|
9
|
+
accessUrl: z.ZodString;
|
|
10
|
+
objectName: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type FileMetadata = z.infer<typeof FileMetadataSchema>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { FileMetadataSchema as n, FileMetadata as t };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { t as FileMetadata } from "./s3-CkZHJIa9.js";
|
|
2
|
+
import z, { z as z$1 } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/events/type.d.ts
|
|
5
|
+
interface EventEmitter {
|
|
6
|
+
uploadFile(input: FileInput): Promise<FileMetadata>;
|
|
7
|
+
streamResponse(input: StreamMessageType): void;
|
|
8
|
+
html2md(html: string): Promise<string>;
|
|
9
|
+
cherrio2md(input: Cherrio2MdInput): Promise<Cherrio2MdResult>;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/tools/schemas/req.d.ts
|
|
13
|
+
declare const ToolHandlerReturnSchema: z$1.ZodObject<{
|
|
14
|
+
error: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>]>>;
|
|
15
|
+
output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
16
|
+
}, z$1.core.$strip>;
|
|
17
|
+
type ToolHandlerReturnType = z$1.infer<typeof ToolHandlerReturnSchema>;
|
|
18
|
+
declare const SystemVarSchema: z$1.ZodObject<{
|
|
19
|
+
user: z$1.ZodObject<{
|
|
20
|
+
id: z$1.ZodString;
|
|
21
|
+
username: z$1.ZodString;
|
|
22
|
+
contact: z$1.ZodString;
|
|
23
|
+
membername: z$1.ZodString;
|
|
24
|
+
teamName: z$1.ZodString;
|
|
25
|
+
teamId: z$1.ZodString;
|
|
26
|
+
name: z$1.ZodString;
|
|
27
|
+
}, z$1.core.$strip>;
|
|
28
|
+
app: z$1.ZodObject<{
|
|
29
|
+
id: z$1.ZodString;
|
|
30
|
+
name: z$1.ZodString;
|
|
31
|
+
}, z$1.core.$strip>;
|
|
32
|
+
tool: z$1.ZodObject<{
|
|
33
|
+
id: z$1.ZodString;
|
|
34
|
+
version: z$1.ZodString;
|
|
35
|
+
prefix: z$1.ZodOptional<z$1.ZodString>;
|
|
36
|
+
}, z$1.core.$strip>;
|
|
37
|
+
time: z$1.ZodString;
|
|
38
|
+
}, z$1.core.$strip>;
|
|
39
|
+
type SystemVarType = z$1.infer<typeof SystemVarSchema>;
|
|
40
|
+
declare const StreamMessageTypeEnum: z$1.ZodEnum<{
|
|
41
|
+
error: "error";
|
|
42
|
+
response: "response";
|
|
43
|
+
stream: "stream";
|
|
44
|
+
}>;
|
|
45
|
+
declare const StreamDataAnswerTypeEnum: z$1.ZodEnum<{
|
|
46
|
+
answer: "answer";
|
|
47
|
+
fastAnswer: "fastAnswer";
|
|
48
|
+
}>;
|
|
49
|
+
declare const StreamDataSchema: z$1.ZodObject<{
|
|
50
|
+
type: z$1.ZodEnum<{
|
|
51
|
+
answer: "answer";
|
|
52
|
+
fastAnswer: "fastAnswer";
|
|
53
|
+
}>;
|
|
54
|
+
content: z$1.ZodString;
|
|
55
|
+
}, z$1.core.$strip>;
|
|
56
|
+
type StreamDataType = z$1.infer<typeof StreamDataSchema>;
|
|
57
|
+
declare const StreamMessageSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
58
|
+
type: "response";
|
|
59
|
+
data: z$1.ZodObject<{
|
|
60
|
+
error: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>]>>;
|
|
61
|
+
output: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
62
|
+
}, z$1.core.$strip>;
|
|
63
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
64
|
+
type: "stream";
|
|
65
|
+
data: z$1.ZodObject<{
|
|
66
|
+
type: z$1.ZodEnum<{
|
|
67
|
+
answer: "answer";
|
|
68
|
+
fastAnswer: "fastAnswer";
|
|
69
|
+
}>;
|
|
70
|
+
content: z$1.ZodString;
|
|
71
|
+
}, z$1.core.$strip>;
|
|
72
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
73
|
+
type: "error";
|
|
74
|
+
data: z$1.ZodString;
|
|
75
|
+
}, z$1.core.$strip>], "type">;
|
|
76
|
+
type StreamMessageType = z$1.infer<typeof StreamMessageSchema>;
|
|
77
|
+
type ToolContextType = {
|
|
78
|
+
emitter: EventEmitter;
|
|
79
|
+
systemVar: SystemVarType;
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
};
|
|
82
|
+
type ToolHandlerFunctionType = (input: Record<string, unknown>, ctx: ToolContextType) => Promise<ToolHandlerReturnType>;
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/events/schemas.d.ts
|
|
85
|
+
declare const EventEnumSchema: z.ZodEnum<{
|
|
86
|
+
"file-upload": "file-upload";
|
|
87
|
+
"stream-response": "stream-response";
|
|
88
|
+
html2md: "html2md";
|
|
89
|
+
cherrio2md: "cherrio2md";
|
|
90
|
+
}>;
|
|
91
|
+
declare const EventEnum: {
|
|
92
|
+
"file-upload": "file-upload";
|
|
93
|
+
"stream-response": "stream-response";
|
|
94
|
+
html2md: "html2md";
|
|
95
|
+
cherrio2md: "cherrio2md";
|
|
96
|
+
};
|
|
97
|
+
type EventEnumType = z.infer<typeof EventEnumSchema>;
|
|
98
|
+
declare const FileInputSchema: z.ZodObject<{
|
|
99
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
100
|
+
path: z.ZodOptional<z.ZodString>;
|
|
101
|
+
base64: z.ZodOptional<z.ZodString>;
|
|
102
|
+
buffer: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>]>, z.ZodTransform<Buffer<any>, Uint8Array<ArrayBuffer> | Buffer<ArrayBufferLike>>>>;
|
|
103
|
+
defaultFilename: z.ZodOptional<z.ZodString>;
|
|
104
|
+
prefix: z.ZodOptional<z.ZodString>;
|
|
105
|
+
keepRawFilename: z.ZodOptional<z.ZodBoolean>;
|
|
106
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
107
|
+
expireMins: z.ZodOptional<z.ZodNumber>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
type FileInput = z.infer<typeof FileInputSchema>;
|
|
110
|
+
/**
|
|
111
|
+
* Cheerio 转 Markdown 参数
|
|
112
|
+
*/
|
|
113
|
+
declare const Cherrio2MdInputSchema: z.ZodObject<{
|
|
114
|
+
fetchUrl: z.ZodURL;
|
|
115
|
+
html: z.ZodString;
|
|
116
|
+
selector: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
117
|
+
}, z.core.$strip>;
|
|
118
|
+
type Cherrio2MdInput = z.infer<typeof Cherrio2MdInputSchema>;
|
|
119
|
+
/**
|
|
120
|
+
* Cheerio 转 Markdown 结果
|
|
121
|
+
*/
|
|
122
|
+
declare const Cherrio2MdResultSchema: z.ZodObject<{
|
|
123
|
+
markdown: z.ZodString;
|
|
124
|
+
title: z.ZodString;
|
|
125
|
+
usedSelector: z.ZodString;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
type Cherrio2MdResult = z.infer<typeof Cherrio2MdResultSchema>;
|
|
128
|
+
type EventDataType<T extends EventEnumType> = T extends 'file-upload' ? FileInput : T extends 'stream-response' ? StreamDataType : T extends 'html2md' ? {
|
|
129
|
+
html: string;
|
|
130
|
+
} : T extends 'cherrio2md' ? {
|
|
131
|
+
fetchUrl: string;
|
|
132
|
+
html: string;
|
|
133
|
+
selector?: string;
|
|
134
|
+
} : never;
|
|
135
|
+
type EventResponseType<T extends EventEnumType> = T extends 'file-upload' ? FileMetadata : T extends 'stream-response' ? void : T extends 'html2md' ? string : T extends 'cherrio2md' ? Cherrio2MdResult : never;
|
|
136
|
+
//#endregion
|
|
137
|
+
export { ToolHandlerReturnType as C, ToolHandlerReturnSchema as S, StreamMessageTypeEnum as _, EventDataType as a, ToolContextType as b, EventEnumType as c, FileInputSchema as d, StreamDataAnswerTypeEnum as f, StreamMessageType as g, StreamMessageSchema as h, Cherrio2MdResultSchema as i, EventResponseType as l, StreamDataType as m, Cherrio2MdInputSchema as n, EventEnum as o, StreamDataSchema as p, Cherrio2MdResult as r, EventEnumSchema as s, Cherrio2MdInput as t, FileInput as u, SystemVarSchema as v, EventEmitter as w, ToolHandlerFunctionType as x, SystemVarType as y };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import "../s3-CkZHJIa9.js";
|
|
2
|
+
import "../schemas-CMeQg8vV.js";
|
|
3
|
+
import { ToolTagEnum } from "./schemas/tool.js";
|
|
4
|
+
import { z as z$1 } from "zod";
|
|
5
|
+
|
|
6
|
+
//#region src/tools/constants.d.ts
|
|
7
|
+
declare const ToolTagsNameMap: {
|
|
8
|
+
readonly tools: {
|
|
9
|
+
readonly en: "tools";
|
|
10
|
+
readonly 'zh-CN': "工具";
|
|
11
|
+
readonly 'zh-Hant': "工具";
|
|
12
|
+
};
|
|
13
|
+
readonly search: {
|
|
14
|
+
readonly en: "search";
|
|
15
|
+
readonly 'zh-CN': "搜索";
|
|
16
|
+
readonly 'zh-Hant': "搜尋";
|
|
17
|
+
};
|
|
18
|
+
readonly multimodal: {
|
|
19
|
+
readonly en: "multimodal";
|
|
20
|
+
readonly 'zh-CN': "多模态";
|
|
21
|
+
readonly 'zh-Hant': "多模態";
|
|
22
|
+
};
|
|
23
|
+
readonly communication: {
|
|
24
|
+
readonly en: "communication";
|
|
25
|
+
readonly 'zh-CN': "通信";
|
|
26
|
+
readonly 'zh-Hant': "通訊";
|
|
27
|
+
};
|
|
28
|
+
readonly finance: {
|
|
29
|
+
readonly en: "finance";
|
|
30
|
+
readonly 'zh-CN': "金融";
|
|
31
|
+
readonly 'zh-Hant': "金融";
|
|
32
|
+
};
|
|
33
|
+
readonly design: {
|
|
34
|
+
readonly en: "design";
|
|
35
|
+
readonly 'zh-CN': "设计";
|
|
36
|
+
readonly 'zh-Hant': "設計";
|
|
37
|
+
};
|
|
38
|
+
readonly productivity: {
|
|
39
|
+
readonly en: "productivity";
|
|
40
|
+
readonly 'zh-CN': "生产力";
|
|
41
|
+
readonly 'zh-Hant': "生產力";
|
|
42
|
+
};
|
|
43
|
+
readonly news: {
|
|
44
|
+
readonly en: "news";
|
|
45
|
+
readonly 'zh-CN': "新闻";
|
|
46
|
+
readonly 'zh-Hant': "新聞";
|
|
47
|
+
};
|
|
48
|
+
readonly entertainment: {
|
|
49
|
+
readonly en: "entertainment";
|
|
50
|
+
readonly 'zh-CN': "娱乐";
|
|
51
|
+
readonly 'zh-Hant': "娛樂";
|
|
52
|
+
};
|
|
53
|
+
readonly social: {
|
|
54
|
+
readonly en: "social";
|
|
55
|
+
readonly 'zh-CN': "社交";
|
|
56
|
+
readonly 'zh-Hant': "社群";
|
|
57
|
+
};
|
|
58
|
+
readonly scientific: {
|
|
59
|
+
readonly en: "scientific";
|
|
60
|
+
readonly 'zh-CN': "科学";
|
|
61
|
+
readonly 'zh-Hant': "科學";
|
|
62
|
+
};
|
|
63
|
+
readonly other: {
|
|
64
|
+
readonly en: "other";
|
|
65
|
+
readonly 'zh-CN': "其他";
|
|
66
|
+
readonly 'zh-Hant': "其他";
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
type ToolTagsType = { [key in z$1.infer<typeof ToolTagEnum>]: {
|
|
70
|
+
en: string;
|
|
71
|
+
'zh-CN': string;
|
|
72
|
+
'zh-Hant': string;
|
|
73
|
+
} };
|
|
74
|
+
//#endregion
|
|
75
|
+
export { ToolTagsNameMap, ToolTagsType };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import "../i18n-CEMsaKK_.js";
|
|
2
|
+
import "../req-Cgf43aEm.js";
|
|
3
|
+
import "../fastgpt-ATrPZt7b.js";
|
|
4
|
+
import { ToolTagEnum } from "./schemas/tool.js";
|
|
5
|
+
import { z as z$1 } from "zod";
|
|
6
|
+
|
|
7
|
+
//#region src/tools/constants.ts
|
|
8
|
+
const ToolTagsNameMap = {
|
|
9
|
+
[ToolTagEnum.enum.tools]: {
|
|
10
|
+
en: "tools",
|
|
11
|
+
"zh-CN": "工具",
|
|
12
|
+
"zh-Hant": "工具"
|
|
13
|
+
},
|
|
14
|
+
[ToolTagEnum.enum.search]: {
|
|
15
|
+
en: "search",
|
|
16
|
+
"zh-CN": "搜索",
|
|
17
|
+
"zh-Hant": "搜尋"
|
|
18
|
+
},
|
|
19
|
+
[ToolTagEnum.enum.multimodal]: {
|
|
20
|
+
en: "multimodal",
|
|
21
|
+
"zh-CN": "多模态",
|
|
22
|
+
"zh-Hant": "多模態"
|
|
23
|
+
},
|
|
24
|
+
[ToolTagEnum.enum.communication]: {
|
|
25
|
+
en: "communication",
|
|
26
|
+
"zh-CN": "通信",
|
|
27
|
+
"zh-Hant": "通訊"
|
|
28
|
+
},
|
|
29
|
+
[ToolTagEnum.enum.finance]: {
|
|
30
|
+
en: "finance",
|
|
31
|
+
"zh-CN": "金融",
|
|
32
|
+
"zh-Hant": "金融"
|
|
33
|
+
},
|
|
34
|
+
[ToolTagEnum.enum.design]: {
|
|
35
|
+
en: "design",
|
|
36
|
+
"zh-CN": "设计",
|
|
37
|
+
"zh-Hant": "設計"
|
|
38
|
+
},
|
|
39
|
+
[ToolTagEnum.enum.productivity]: {
|
|
40
|
+
en: "productivity",
|
|
41
|
+
"zh-CN": "生产力",
|
|
42
|
+
"zh-Hant": "生產力"
|
|
43
|
+
},
|
|
44
|
+
[ToolTagEnum.enum.news]: {
|
|
45
|
+
en: "news",
|
|
46
|
+
"zh-CN": "新闻",
|
|
47
|
+
"zh-Hant": "新聞"
|
|
48
|
+
},
|
|
49
|
+
[ToolTagEnum.enum.entertainment]: {
|
|
50
|
+
en: "entertainment",
|
|
51
|
+
"zh-CN": "娱乐",
|
|
52
|
+
"zh-Hant": "娛樂"
|
|
53
|
+
},
|
|
54
|
+
[ToolTagEnum.enum.social]: {
|
|
55
|
+
en: "social",
|
|
56
|
+
"zh-CN": "社交",
|
|
57
|
+
"zh-Hant": "社群"
|
|
58
|
+
},
|
|
59
|
+
[ToolTagEnum.enum.scientific]: {
|
|
60
|
+
en: "scientific",
|
|
61
|
+
"zh-CN": "科学",
|
|
62
|
+
"zh-Hant": "科學"
|
|
63
|
+
},
|
|
64
|
+
[ToolTagEnum.enum.other]: {
|
|
65
|
+
en: "other",
|
|
66
|
+
"zh-CN": "其他",
|
|
67
|
+
"zh-Hant": "其他"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { ToolTagsNameMap };
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import "../s3-CkZHJIa9.js";
|
|
2
|
+
import { b as ToolContextType } from "../schemas-CMeQg8vV.js";
|
|
3
|
+
import { ToolConfigSchema, ToolConfigType, ToolSetConfigSchema, ToolSetConfigType } from "./schemas/tool.js";
|
|
4
|
+
import z, { ZodType } from "zod";
|
|
5
|
+
|
|
6
|
+
//#region src/tools/helper.d.ts
|
|
7
|
+
declare function defineTool(tool: z.input<typeof ToolConfigSchema>): z.output<typeof ToolConfigSchema>;
|
|
8
|
+
declare function defineToolSet(toolset: z.input<typeof ToolSetConfigSchema>): z.output<typeof ToolSetConfigSchema>;
|
|
9
|
+
declare const exportTool: <TInput, TOutput>({
|
|
10
|
+
toolCb,
|
|
11
|
+
InputType,
|
|
12
|
+
OutputType,
|
|
13
|
+
config
|
|
14
|
+
}: {
|
|
15
|
+
toolCb: (props: TInput, e: ToolContextType) => Promise<Record<string, any>>;
|
|
16
|
+
InputType: ZodType<TInput>;
|
|
17
|
+
OutputType: ZodType<TOutput>;
|
|
18
|
+
config: ToolConfigType;
|
|
19
|
+
}) => {
|
|
20
|
+
cb: (props: TInput, e: ToolContextType) => Promise<{
|
|
21
|
+
output: TOutput;
|
|
22
|
+
error?: never;
|
|
23
|
+
} | {
|
|
24
|
+
error: unknown;
|
|
25
|
+
output?: never;
|
|
26
|
+
}>;
|
|
27
|
+
toolDescription: string | {
|
|
28
|
+
en: string;
|
|
29
|
+
'zh-CN'?: string | undefined;
|
|
30
|
+
'zh-Hant'?: string | undefined;
|
|
31
|
+
};
|
|
32
|
+
versionList: {
|
|
33
|
+
value: string;
|
|
34
|
+
inputs: {
|
|
35
|
+
key: string;
|
|
36
|
+
label: string;
|
|
37
|
+
renderTypeList: ("reference" | "input" | "textarea" | "numberInput" | "switch" | "select" | "multipleSelect" | "JSONEditor" | "addInputParam" | "selectApp" | "customVariable" | "selectLLMModel" | "settingLLMModel" | "selectDataset" | "selectDatasetParamsModal" | "settingDatasetQuotePrompt" | "hidden" | "custom" | "fileSelect")[];
|
|
38
|
+
valueType: "string" | "number" | "boolean" | "object" | "selectApp" | "selectDataset" | "arrayString" | "arrayNumber" | "arrayBoolean" | "arrayObject" | "arrayAny" | "any" | "chatHistory" | "datasetQuote" | "dynamic";
|
|
39
|
+
referencePlaceholder?: string | undefined;
|
|
40
|
+
placeholder?: string | undefined;
|
|
41
|
+
defaultValue?: any;
|
|
42
|
+
selectedTypeIndex?: number | undefined;
|
|
43
|
+
valueDesc?: string | undefined;
|
|
44
|
+
value?: unknown;
|
|
45
|
+
description?: string | undefined;
|
|
46
|
+
required?: boolean | undefined;
|
|
47
|
+
toolDescription?: string | undefined;
|
|
48
|
+
canEdit?: boolean | undefined;
|
|
49
|
+
isPro?: boolean | undefined;
|
|
50
|
+
maxLength?: number | undefined;
|
|
51
|
+
canSelectFile?: boolean | undefined;
|
|
52
|
+
canSelectImg?: boolean | undefined;
|
|
53
|
+
maxFiles?: number | undefined;
|
|
54
|
+
inputList?: {
|
|
55
|
+
key: string;
|
|
56
|
+
label: string;
|
|
57
|
+
inputType: "input" | "numberInput" | "switch" | "select" | "secret";
|
|
58
|
+
description?: string | undefined;
|
|
59
|
+
required?: boolean | undefined;
|
|
60
|
+
defaultValue?: any;
|
|
61
|
+
list?: {
|
|
62
|
+
label: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}[] | undefined;
|
|
65
|
+
}[] | undefined;
|
|
66
|
+
llmModelType?: "all" | "classify" | "extractFields" | "toolCall" | undefined;
|
|
67
|
+
list?: {
|
|
68
|
+
label: string;
|
|
69
|
+
value: string;
|
|
70
|
+
}[] | undefined;
|
|
71
|
+
markList?: {
|
|
72
|
+
label: string;
|
|
73
|
+
value: number;
|
|
74
|
+
}[] | undefined;
|
|
75
|
+
step?: number | undefined;
|
|
76
|
+
max?: number | undefined;
|
|
77
|
+
min?: number | undefined;
|
|
78
|
+
precision?: number | undefined;
|
|
79
|
+
}[];
|
|
80
|
+
outputs: {
|
|
81
|
+
key: string;
|
|
82
|
+
valueType: "string" | "number" | "boolean" | "object" | "selectApp" | "selectDataset" | "arrayString" | "arrayNumber" | "arrayBoolean" | "arrayObject" | "arrayAny" | "any" | "chatHistory" | "datasetQuote" | "dynamic";
|
|
83
|
+
id?: string | undefined;
|
|
84
|
+
type?: "hidden" | "dynamic" | "source" | "static" | "error" | undefined;
|
|
85
|
+
valueDesc?: string | undefined;
|
|
86
|
+
value?: unknown;
|
|
87
|
+
label?: string | undefined;
|
|
88
|
+
description?: string | undefined;
|
|
89
|
+
defaultValue?: any;
|
|
90
|
+
required?: boolean | undefined;
|
|
91
|
+
}[];
|
|
92
|
+
description?: string | undefined;
|
|
93
|
+
}[];
|
|
94
|
+
description: {
|
|
95
|
+
en: string;
|
|
96
|
+
'zh-CN'?: string | undefined;
|
|
97
|
+
'zh-Hant'?: string | undefined;
|
|
98
|
+
};
|
|
99
|
+
name: {
|
|
100
|
+
en: string;
|
|
101
|
+
'zh-CN'?: string | undefined;
|
|
102
|
+
'zh-Hant'?: string | undefined;
|
|
103
|
+
};
|
|
104
|
+
toolId?: string | undefined;
|
|
105
|
+
tags?: ("tools" | "search" | "multimodal" | "communication" | "finance" | "design" | "productivity" | "news" | "entertainment" | "social" | "scientific" | "other")[] | undefined;
|
|
106
|
+
icon?: string | undefined;
|
|
107
|
+
author?: string | undefined;
|
|
108
|
+
tutorialLink?: string | undefined;
|
|
109
|
+
secretInputConfig?: {
|
|
110
|
+
key: string;
|
|
111
|
+
label: string;
|
|
112
|
+
inputType: "input" | "numberInput" | "switch" | "select" | "secret";
|
|
113
|
+
description?: string | undefined;
|
|
114
|
+
required?: boolean | undefined;
|
|
115
|
+
defaultValue?: any;
|
|
116
|
+
list?: {
|
|
117
|
+
label: string;
|
|
118
|
+
value: string;
|
|
119
|
+
}[] | undefined;
|
|
120
|
+
}[] | undefined;
|
|
121
|
+
parentId?: string | undefined;
|
|
122
|
+
tutorialUrl?: string | undefined;
|
|
123
|
+
etag?: string | undefined;
|
|
124
|
+
};
|
|
125
|
+
declare const exportToolSet: ({
|
|
126
|
+
config
|
|
127
|
+
}: {
|
|
128
|
+
config: ToolSetConfigType;
|
|
129
|
+
}) => {
|
|
130
|
+
children: {
|
|
131
|
+
toolId: string;
|
|
132
|
+
name: {
|
|
133
|
+
en: string;
|
|
134
|
+
'zh-CN'?: string | undefined;
|
|
135
|
+
'zh-Hant'?: string | undefined;
|
|
136
|
+
};
|
|
137
|
+
description: {
|
|
138
|
+
en: string;
|
|
139
|
+
'zh-CN'?: string | undefined;
|
|
140
|
+
'zh-Hant'?: string | undefined;
|
|
141
|
+
};
|
|
142
|
+
toolDescription: string;
|
|
143
|
+
icon: string;
|
|
144
|
+
filename: string;
|
|
145
|
+
parentId?: string | undefined;
|
|
146
|
+
versionList?: {
|
|
147
|
+
value: string;
|
|
148
|
+
inputs: {
|
|
149
|
+
key: string;
|
|
150
|
+
label: string;
|
|
151
|
+
renderTypeList: ("reference" | "input" | "textarea" | "numberInput" | "switch" | "select" | "multipleSelect" | "JSONEditor" | "addInputParam" | "selectApp" | "customVariable" | "selectLLMModel" | "settingLLMModel" | "selectDataset" | "selectDatasetParamsModal" | "settingDatasetQuotePrompt" | "hidden" | "custom" | "fileSelect")[];
|
|
152
|
+
valueType: "string" | "number" | "boolean" | "object" | "selectApp" | "selectDataset" | "arrayString" | "arrayNumber" | "arrayBoolean" | "arrayObject" | "arrayAny" | "any" | "chatHistory" | "datasetQuote" | "dynamic";
|
|
153
|
+
referencePlaceholder?: string | undefined;
|
|
154
|
+
placeholder?: string | undefined;
|
|
155
|
+
defaultValue?: any;
|
|
156
|
+
selectedTypeIndex?: number | undefined;
|
|
157
|
+
valueDesc?: string | undefined;
|
|
158
|
+
value?: unknown;
|
|
159
|
+
description?: string | undefined;
|
|
160
|
+
required?: boolean | undefined;
|
|
161
|
+
toolDescription?: string | undefined;
|
|
162
|
+
canEdit?: boolean | undefined;
|
|
163
|
+
isPro?: boolean | undefined;
|
|
164
|
+
maxLength?: number | undefined;
|
|
165
|
+
canSelectFile?: boolean | undefined;
|
|
166
|
+
canSelectImg?: boolean | undefined;
|
|
167
|
+
maxFiles?: number | undefined;
|
|
168
|
+
inputList?: {
|
|
169
|
+
key: string;
|
|
170
|
+
label: string;
|
|
171
|
+
inputType: "input" | "numberInput" | "switch" | "select" | "secret";
|
|
172
|
+
description?: string | undefined;
|
|
173
|
+
required?: boolean | undefined;
|
|
174
|
+
defaultValue?: any;
|
|
175
|
+
list?: {
|
|
176
|
+
label: string;
|
|
177
|
+
value: string;
|
|
178
|
+
}[] | undefined;
|
|
179
|
+
}[] | undefined;
|
|
180
|
+
llmModelType?: "all" | "classify" | "extractFields" | "toolCall" | undefined;
|
|
181
|
+
list?: {
|
|
182
|
+
label: string;
|
|
183
|
+
value: string;
|
|
184
|
+
}[] | undefined;
|
|
185
|
+
markList?: {
|
|
186
|
+
label: string;
|
|
187
|
+
value: number;
|
|
188
|
+
}[] | undefined;
|
|
189
|
+
step?: number | undefined;
|
|
190
|
+
max?: number | undefined;
|
|
191
|
+
min?: number | undefined;
|
|
192
|
+
precision?: number | undefined;
|
|
193
|
+
}[];
|
|
194
|
+
outputs: {
|
|
195
|
+
key: string;
|
|
196
|
+
valueType: "string" | "number" | "boolean" | "object" | "selectApp" | "selectDataset" | "arrayString" | "arrayNumber" | "arrayBoolean" | "arrayObject" | "arrayAny" | "any" | "chatHistory" | "datasetQuote" | "dynamic";
|
|
197
|
+
id?: string | undefined;
|
|
198
|
+
type?: "hidden" | "dynamic" | "source" | "static" | "error" | undefined;
|
|
199
|
+
valueDesc?: string | undefined;
|
|
200
|
+
value?: unknown;
|
|
201
|
+
label?: string | undefined;
|
|
202
|
+
description?: string | undefined;
|
|
203
|
+
defaultValue?: any;
|
|
204
|
+
required?: boolean | undefined;
|
|
205
|
+
}[];
|
|
206
|
+
description?: string | undefined;
|
|
207
|
+
}[] | undefined;
|
|
208
|
+
tags?: ("tools" | "search" | "multimodal" | "communication" | "finance" | "design" | "productivity" | "news" | "entertainment" | "social" | "scientific" | "other")[] | undefined;
|
|
209
|
+
author?: string | undefined;
|
|
210
|
+
tutorialUrl?: string | undefined;
|
|
211
|
+
readmeUrl?: string | undefined;
|
|
212
|
+
secretInputConfig?: {
|
|
213
|
+
key: string;
|
|
214
|
+
label: string;
|
|
215
|
+
inputType: "input" | "numberInput" | "switch" | "select" | "secret";
|
|
216
|
+
description?: string | undefined;
|
|
217
|
+
required?: boolean | undefined;
|
|
218
|
+
defaultValue?: any;
|
|
219
|
+
list?: {
|
|
220
|
+
label: string;
|
|
221
|
+
value: string;
|
|
222
|
+
}[] | undefined;
|
|
223
|
+
}[] | undefined;
|
|
224
|
+
etag?: string | undefined;
|
|
225
|
+
}[];
|
|
226
|
+
description: {
|
|
227
|
+
en: string;
|
|
228
|
+
'zh-CN'?: string | undefined;
|
|
229
|
+
'zh-Hant'?: string | undefined;
|
|
230
|
+
};
|
|
231
|
+
name: {
|
|
232
|
+
en: string;
|
|
233
|
+
'zh-CN'?: string | undefined;
|
|
234
|
+
'zh-Hant'?: string | undefined;
|
|
235
|
+
};
|
|
236
|
+
filename: string;
|
|
237
|
+
tutorialUrl?: string | undefined;
|
|
238
|
+
readmeUrl?: string | undefined;
|
|
239
|
+
etag?: string | undefined;
|
|
240
|
+
toolId?: string | undefined;
|
|
241
|
+
toolDescription?: string | undefined;
|
|
242
|
+
tags?: ("tools" | "search" | "multimodal" | "communication" | "finance" | "design" | "productivity" | "news" | "entertainment" | "social" | "scientific" | "other")[] | undefined;
|
|
243
|
+
icon?: string | undefined;
|
|
244
|
+
author?: string | undefined;
|
|
245
|
+
tutorialLink?: string | undefined;
|
|
246
|
+
secretInputConfig?: {
|
|
247
|
+
key: string;
|
|
248
|
+
label: string;
|
|
249
|
+
inputType: "input" | "numberInput" | "switch" | "select" | "secret";
|
|
250
|
+
description?: string | undefined;
|
|
251
|
+
required?: boolean | undefined;
|
|
252
|
+
defaultValue?: any;
|
|
253
|
+
list?: {
|
|
254
|
+
label: string;
|
|
255
|
+
value: string;
|
|
256
|
+
}[] | undefined;
|
|
257
|
+
}[] | undefined;
|
|
258
|
+
};
|
|
259
|
+
//#endregion
|
|
260
|
+
export { defineTool, defineToolSet, exportTool, exportToolSet };
|