@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,18 @@
|
|
|
1
|
+
//#region src/common/fn.d.ts
|
|
2
|
+
declare const delay: (ms: number) => Promise<unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* Golang style error handling
|
|
5
|
+
* @param fn
|
|
6
|
+
* @returns [result, error]
|
|
7
|
+
*/
|
|
8
|
+
declare function catchError<T>(fn: () => T): Promise<[Awaited<T> | null, unknown]>;
|
|
9
|
+
declare const retryFn: <T>(fn: () => Promise<T>, retryTimes?: number) => Promise<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Run batch tasks concurrently with a maximum number of concurrent tasks.
|
|
12
|
+
* @param batchSize Maximum number of concurrent tasks.
|
|
13
|
+
* @param funclist List of functions to run in batches.
|
|
14
|
+
* @returns Array of results from the functions.
|
|
15
|
+
*/
|
|
16
|
+
declare function batch<T>(batchSize: number, funclist: (() => Promise<T>)[]): Promise<T[]>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { batch, catchError, delay, retryFn };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/common/fn.ts
|
|
2
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
3
|
+
/**
|
|
4
|
+
* Golang style error handling
|
|
5
|
+
* @param fn
|
|
6
|
+
* @returns [result, error]
|
|
7
|
+
*/
|
|
8
|
+
async function catchError(fn) {
|
|
9
|
+
try {
|
|
10
|
+
return [await fn(), null];
|
|
11
|
+
} catch (e) {
|
|
12
|
+
return [null, e];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const retryFn = async (fn, retryTimes = 3) => {
|
|
16
|
+
try {
|
|
17
|
+
return await fn();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (retryTimes > 0) {
|
|
20
|
+
await delay(500);
|
|
21
|
+
return retryFn(fn, retryTimes - 1);
|
|
22
|
+
}
|
|
23
|
+
return Promise.reject(error);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Run batch tasks concurrently with a maximum number of concurrent tasks.
|
|
28
|
+
* @param batchSize Maximum number of concurrent tasks.
|
|
29
|
+
* @param funclist List of functions to run in batches.
|
|
30
|
+
* @returns Array of results from the functions.
|
|
31
|
+
*/
|
|
32
|
+
async function batch(batchSize, funclist) {
|
|
33
|
+
const results = [];
|
|
34
|
+
const executing = [];
|
|
35
|
+
for (const func of funclist) {
|
|
36
|
+
const promise = func().then((result) => {
|
|
37
|
+
results.push(result);
|
|
38
|
+
executing.splice(executing.indexOf(promise), 1);
|
|
39
|
+
});
|
|
40
|
+
executing.push(promise);
|
|
41
|
+
if (executing.length >= batchSize) await Promise.race(executing);
|
|
42
|
+
}
|
|
43
|
+
await Promise.all(executing);
|
|
44
|
+
return results;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { batch, catchError, delay, retryFn };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/common/fs.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Ensure a directory exists
|
|
4
|
+
* @param path
|
|
5
|
+
*/
|
|
6
|
+
declare const ensureDir: (path: string) => Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* remove the dir and then create a new one
|
|
9
|
+
*/
|
|
10
|
+
declare function refreshDir(dir: string): Promise<void>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ensureDir, refreshDir };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mkdir, rm } from "fs/promises";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
|
|
4
|
+
//#region src/common/fs.ts
|
|
5
|
+
/**
|
|
6
|
+
* Ensure a directory exists
|
|
7
|
+
* @param path
|
|
8
|
+
*/
|
|
9
|
+
const ensureDir = async (path) => {
|
|
10
|
+
if (!existsSync(path)) await mkdir(path, { recursive: true });
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* remove the dir and then create a new one
|
|
14
|
+
*/
|
|
15
|
+
async function refreshDir(dir) {
|
|
16
|
+
await rm(dir, {
|
|
17
|
+
recursive: true,
|
|
18
|
+
force: true
|
|
19
|
+
});
|
|
20
|
+
await ensureDir(dir);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ensureDir, refreshDir };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z as z$1 } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/common/schemas/i18n.d.ts
|
|
4
|
+
declare const I18nStringSchema: z$1.ZodObject<{
|
|
5
|
+
en: z$1.ZodString;
|
|
6
|
+
'zh-CN': z$1.ZodOptional<z$1.ZodString>;
|
|
7
|
+
'zh-Hant': z$1.ZodOptional<z$1.ZodString>;
|
|
8
|
+
}, z$1.core.$strip>;
|
|
9
|
+
declare const I18nStringStrictSchema: z$1.ZodObject<{
|
|
10
|
+
en: z$1.ZodString;
|
|
11
|
+
'zh-CN': z$1.ZodString;
|
|
12
|
+
'zh-Hant': z$1.ZodString;
|
|
13
|
+
}, z$1.core.$strip>;
|
|
14
|
+
type I18nStringType = z$1.infer<typeof I18nStringSchema>;
|
|
15
|
+
type I18nStringStrictType = z$1.infer<typeof I18nStringStrictSchema>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { I18nStringSchema, I18nStringStrictSchema, I18nStringStrictType, I18nStringType };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/common/schemas/s3.ts
|
|
4
|
+
const FileMetadataSchema = z.object({
|
|
5
|
+
originalFilename: z.string(),
|
|
6
|
+
contentType: z.string(),
|
|
7
|
+
size: z.number(),
|
|
8
|
+
uploadTime: z.date(),
|
|
9
|
+
accessUrl: z.string(),
|
|
10
|
+
objectName: z.string()
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { FileMetadataSchema };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/common/zip.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Pack a directory into a .pkg file
|
|
4
|
+
* @param dir - Source directory path to pack
|
|
5
|
+
* @param dist - Destination path for the .pkg file
|
|
6
|
+
*/
|
|
7
|
+
declare const pkg: (dir: string, dist: string) => Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* Unpack a .pkg file to a directory
|
|
10
|
+
* @param pkgPath - Path to the .pkg file to unpack
|
|
11
|
+
* @param dist - Destination directory to extract files to
|
|
12
|
+
*/
|
|
13
|
+
declare const unpkg: (pkgPath: string, dist: string) => Promise<void>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { pkg, unpkg };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import "../s3-CkZHJIa9.js";
|
|
2
|
+
import { a as EventDataType, c as EventEnumType, d as FileInputSchema, i as Cherrio2MdResultSchema, l as EventResponseType, n as Cherrio2MdInputSchema, o as EventEnum, r as Cherrio2MdResult, s as EventEnumSchema, t as Cherrio2MdInput, u as FileInput } from "../schemas-CMeQg8vV.js";
|
|
3
|
+
export { Cherrio2MdInput, Cherrio2MdInputSchema, Cherrio2MdResult, Cherrio2MdResultSchema, EventDataType, EventEnum, EventEnumSchema, EventEnumType, EventResponseType, FileInput, FileInputSchema };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/events/schemas.ts
|
|
4
|
+
const EventEnumSchema = z.enum([
|
|
5
|
+
"file-upload",
|
|
6
|
+
"stream-response",
|
|
7
|
+
"html2md",
|
|
8
|
+
"cherrio2md"
|
|
9
|
+
]);
|
|
10
|
+
const EventEnum = EventEnumSchema.enum;
|
|
11
|
+
const FileInputSchema = z.object({
|
|
12
|
+
url: z.url("Invalid URL format").optional(),
|
|
13
|
+
path: z.string().min(1, "File path cannot be empty").optional(),
|
|
14
|
+
base64: z.string().min(1, "Base64 data cannot be empty").optional(),
|
|
15
|
+
buffer: z.union([z.instanceof(Buffer, { error: "Buffer is required" }), z.instanceof(Uint8Array, { error: "Uint8Array is required" })]).transform((data) => {
|
|
16
|
+
if (data instanceof Uint8Array && !(data instanceof Buffer)) return Buffer.from(data);
|
|
17
|
+
return data;
|
|
18
|
+
}).optional(),
|
|
19
|
+
defaultFilename: z.string().optional(),
|
|
20
|
+
prefix: z.string().optional(),
|
|
21
|
+
keepRawFilename: z.boolean().optional(),
|
|
22
|
+
contentType: z.string().optional(),
|
|
23
|
+
expireMins: z.number().optional()
|
|
24
|
+
}).refine((data) => {
|
|
25
|
+
return [
|
|
26
|
+
data.url,
|
|
27
|
+
data.path,
|
|
28
|
+
data.base64,
|
|
29
|
+
data.buffer
|
|
30
|
+
].filter(Boolean).length === 1 && (!(data.base64 || data.buffer) || data.defaultFilename);
|
|
31
|
+
}, { error: "Provide exactly one input method. Filename required for base64/buffer inputs." });
|
|
32
|
+
/**
|
|
33
|
+
* Cheerio 转 Markdown 参数
|
|
34
|
+
*/
|
|
35
|
+
const Cherrio2MdInputSchema = z.object({
|
|
36
|
+
fetchUrl: z.url("Invalid URL format"),
|
|
37
|
+
html: z.string().min(1, "HTML content cannot be empty"),
|
|
38
|
+
selector: z.string().optional().default("body")
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Cheerio 转 Markdown 结果
|
|
42
|
+
*/
|
|
43
|
+
const Cherrio2MdResultSchema = z.object({
|
|
44
|
+
markdown: z.string(),
|
|
45
|
+
title: z.string(),
|
|
46
|
+
usedSelector: z.string()
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { Cherrio2MdInputSchema, Cherrio2MdResultSchema, EventEnum, EventEnumSchema, FileInputSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/tools/schemas/fastgpt.ts
|
|
4
|
+
const FlowNodeInputTypeEnum = z.enum([
|
|
5
|
+
"reference",
|
|
6
|
+
"input",
|
|
7
|
+
"textarea",
|
|
8
|
+
"numberInput",
|
|
9
|
+
"switch",
|
|
10
|
+
"select",
|
|
11
|
+
"multipleSelect",
|
|
12
|
+
"JSONEditor",
|
|
13
|
+
"addInputParam",
|
|
14
|
+
"selectApp",
|
|
15
|
+
"customVariable",
|
|
16
|
+
"selectLLMModel",
|
|
17
|
+
"settingLLMModel",
|
|
18
|
+
"selectDataset",
|
|
19
|
+
"selectDatasetParamsModal",
|
|
20
|
+
"settingDatasetQuotePrompt",
|
|
21
|
+
"hidden",
|
|
22
|
+
"custom",
|
|
23
|
+
"fileSelect"
|
|
24
|
+
]);
|
|
25
|
+
const WorkflowIOValueTypeEnum = z.enum([
|
|
26
|
+
"string",
|
|
27
|
+
"number",
|
|
28
|
+
"boolean",
|
|
29
|
+
"object",
|
|
30
|
+
"arrayString",
|
|
31
|
+
"arrayNumber",
|
|
32
|
+
"arrayBoolean",
|
|
33
|
+
"arrayObject",
|
|
34
|
+
"arrayAny",
|
|
35
|
+
"any",
|
|
36
|
+
"chatHistory",
|
|
37
|
+
"datasetQuote",
|
|
38
|
+
"dynamic",
|
|
39
|
+
"selectDataset",
|
|
40
|
+
"selectApp"
|
|
41
|
+
]);
|
|
42
|
+
const LLMModelTypeEnum = z.enum([
|
|
43
|
+
"all",
|
|
44
|
+
"classify",
|
|
45
|
+
"extractFields",
|
|
46
|
+
"toolCall"
|
|
47
|
+
]);
|
|
48
|
+
const FlowNodeOutputTypeEnum = z.enum([
|
|
49
|
+
"hidden",
|
|
50
|
+
"source",
|
|
51
|
+
"static",
|
|
52
|
+
"dynamic",
|
|
53
|
+
"error"
|
|
54
|
+
]);
|
|
55
|
+
const SecretInputItemSchema = z.object({
|
|
56
|
+
key: z.string(),
|
|
57
|
+
label: z.string(),
|
|
58
|
+
description: z.string().optional(),
|
|
59
|
+
required: z.boolean().optional(),
|
|
60
|
+
inputType: z.enum([
|
|
61
|
+
"input",
|
|
62
|
+
"numberInput",
|
|
63
|
+
"secret",
|
|
64
|
+
"switch",
|
|
65
|
+
"select"
|
|
66
|
+
]),
|
|
67
|
+
defaultValue: z.any().optional(),
|
|
68
|
+
list: z.array(z.object({
|
|
69
|
+
label: z.string(),
|
|
70
|
+
value: z.string()
|
|
71
|
+
})).optional()
|
|
72
|
+
});
|
|
73
|
+
const InputSchema = z.object({
|
|
74
|
+
key: z.string(),
|
|
75
|
+
label: z.string(),
|
|
76
|
+
referencePlaceholder: z.string().optional(),
|
|
77
|
+
placeholder: z.string().optional(),
|
|
78
|
+
defaultValue: z.any().optional(),
|
|
79
|
+
selectedTypeIndex: z.number().optional(),
|
|
80
|
+
renderTypeList: z.array(FlowNodeInputTypeEnum),
|
|
81
|
+
valueType: WorkflowIOValueTypeEnum,
|
|
82
|
+
valueDesc: z.string().optional(),
|
|
83
|
+
value: z.unknown().optional(),
|
|
84
|
+
description: z.string().optional(),
|
|
85
|
+
required: z.boolean().optional(),
|
|
86
|
+
toolDescription: z.string().optional(),
|
|
87
|
+
canEdit: z.boolean().optional(),
|
|
88
|
+
isPro: z.boolean().optional(),
|
|
89
|
+
maxLength: z.number().optional(),
|
|
90
|
+
canSelectFile: z.boolean().optional(),
|
|
91
|
+
canSelectImg: z.boolean().optional(),
|
|
92
|
+
maxFiles: z.number().optional(),
|
|
93
|
+
inputList: z.array(SecretInputItemSchema).optional(),
|
|
94
|
+
llmModelType: LLMModelTypeEnum.optional(),
|
|
95
|
+
list: z.array(z.object({
|
|
96
|
+
label: z.string(),
|
|
97
|
+
value: z.string()
|
|
98
|
+
})).optional(),
|
|
99
|
+
markList: z.array(z.object({
|
|
100
|
+
label: z.string(),
|
|
101
|
+
value: z.number()
|
|
102
|
+
})).optional(),
|
|
103
|
+
step: z.number().optional(),
|
|
104
|
+
max: z.number().optional(),
|
|
105
|
+
min: z.number().optional(),
|
|
106
|
+
precision: z.number().optional()
|
|
107
|
+
});
|
|
108
|
+
const OutputSchema = z.object({
|
|
109
|
+
id: z.string().optional(),
|
|
110
|
+
type: FlowNodeOutputTypeEnum.optional(),
|
|
111
|
+
key: z.string(),
|
|
112
|
+
valueType: WorkflowIOValueTypeEnum,
|
|
113
|
+
valueDesc: z.string().optional(),
|
|
114
|
+
value: z.unknown().optional(),
|
|
115
|
+
label: z.string().optional(),
|
|
116
|
+
description: z.string().optional(),
|
|
117
|
+
defaultValue: z.any().optional(),
|
|
118
|
+
required: z.boolean().optional()
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
export { OutputSchema as a, LLMModelTypeEnum as i, FlowNodeOutputTypeEnum as n, SecretInputItemSchema as o, InputSchema as r, WorkflowIOValueTypeEnum as s, FlowNodeInputTypeEnum as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z as z$1 } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/common/schemas/i18n.ts
|
|
4
|
+
const I18nStringSchema = z$1.object({
|
|
5
|
+
en: z$1.string(),
|
|
6
|
+
"zh-CN": z$1.string().optional(),
|
|
7
|
+
"zh-Hant": z$1.string().optional()
|
|
8
|
+
});
|
|
9
|
+
const I18nStringStrictSchema = z$1.object({
|
|
10
|
+
en: z$1.string(),
|
|
11
|
+
"zh-CN": z$1.string(),
|
|
12
|
+
"zh-Hant": z$1.string()
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { I18nStringStrictSchema as n, I18nStringSchema as t };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { batch, catchError, delay } from "./common/fn.js";
|
|
2
|
+
import { ensureDir, refreshDir } from "./common/fs.js";
|
|
3
|
+
import { I18nStringSchema, I18nStringStrictSchema, I18nStringStrictType, I18nStringType } from "./common/schemas/i18n.js";
|
|
4
|
+
import "./s3-CkZHJIa9.js";
|
|
5
|
+
import { pkg, unpkg } from "./common/zip.js";
|
|
6
|
+
import { C as ToolHandlerReturnType, S as ToolHandlerReturnSchema, _ as StreamMessageTypeEnum, b as ToolContextType, c as EventEnumType, f as StreamDataAnswerTypeEnum, g as StreamMessageType, h as StreamMessageSchema, m as StreamDataType, p as StreamDataSchema, r as Cherrio2MdResult, t as Cherrio2MdInput, u as FileInput, v as SystemVarSchema, w as EventEmitter, x as ToolHandlerFunctionType, y as SystemVarType } from "./schemas-CMeQg8vV.js";
|
|
7
|
+
import { ToolConfigSchema, ToolDetailSchema, ToolDetailType, ToolSchema, ToolSetConfigSchema, ToolSetSchema, ToolSimpleSchema, ToolSimpleType, ToolTagEnum, UnifiedToolSchema, VersionListItemSchema, VersionListItemType } from "./tools/schemas/tool.js";
|
|
8
|
+
import { defineTool, defineToolSet } from "./tools/helper.js";
|
|
9
|
+
import { EmbeddingModelItemSchema, LLMModelItemSchema, ListModelsSchema, ListModelsType, ModelItemSchema, ModelItemType, ModelTypeEnum, RerankModelItemSchema, STTModelSchema, TTSModelSchema } from "./models/schemas.js";
|
|
10
|
+
import { TemplateItemSchema, TemplateItemType, TemplateListSchema, TemplateListType } from "./workflows/schemas.js";
|
|
11
|
+
import { ToolTagsNameMap, ToolTagsType } from "./tools/constants.js";
|
|
12
|
+
import { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum, InputSchema, LLMModelTypeEnum, OutputSchema, OutputType, SecretInputItemSchema, SecretInputItemType, WorkflowIOValueTypeEnum } from "./tools/schemas/fastgpt.js";
|
|
13
|
+
export { type Cherrio2MdInput, type Cherrio2MdResult, EmbeddingModelItemSchema, type EventEmitter, type EventEnumType, type FileInput, FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum, I18nStringSchema, I18nStringStrictSchema, type I18nStringStrictType, type I18nStringType, InputSchema, LLMModelItemSchema, LLMModelTypeEnum, ListModelsSchema, type ListModelsType, ModelItemSchema, type ModelItemType, ModelTypeEnum, OutputSchema, type OutputType, RerankModelItemSchema, STTModelSchema, SecretInputItemSchema, type SecretInputItemType, StreamDataAnswerTypeEnum, StreamDataSchema, type StreamDataType, StreamMessageSchema, type StreamMessageType, StreamMessageTypeEnum, SystemVarSchema, type SystemVarType, TTSModelSchema, TemplateItemSchema, type TemplateItemType, TemplateListSchema, type TemplateListType, ToolConfigSchema, type ToolContextType, ToolDetailSchema, type ToolDetailType, type ToolHandlerFunctionType, ToolHandlerReturnSchema, type ToolHandlerReturnType, ToolSchema, ToolSetConfigSchema, ToolSetSchema, ToolSimpleSchema, type ToolSimpleType, ToolTagEnum, ToolTagsNameMap, type ToolTagsType, UnifiedToolSchema, VersionListItemSchema, type VersionListItemType, WorkflowIOValueTypeEnum, batch, catchError, defineTool, defineToolSet, delay, ensureDir, pkg, refreshDir, unpkg };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { n as unpkg, t as pkg } from "./zip-DjBhByRt.js";
|
|
2
|
+
import { ensureDir, refreshDir } from "./common/fs.js";
|
|
3
|
+
import { batch, catchError, delay } from "./common/fn.js";
|
|
4
|
+
import { n as I18nStringStrictSchema, t as I18nStringSchema } from "./i18n-CEMsaKK_.js";
|
|
5
|
+
import { a as SystemVarSchema, i as StreamMessageTypeEnum, n as StreamDataSchema, o as ToolHandlerReturnSchema, r as StreamMessageSchema, t as StreamDataAnswerTypeEnum } from "./req-Cgf43aEm.js";
|
|
6
|
+
import { a as OutputSchema, i as LLMModelTypeEnum, n as FlowNodeOutputTypeEnum, o as SecretInputItemSchema, r as InputSchema, s as WorkflowIOValueTypeEnum, t as FlowNodeInputTypeEnum } from "./fastgpt-ATrPZt7b.js";
|
|
7
|
+
import { ToolConfigSchema, ToolDetailSchema, ToolSchema, ToolSetConfigSchema, ToolSetSchema, ToolSimpleSchema, ToolTagEnum, UnifiedToolSchema, VersionListItemSchema } from "./tools/schemas/tool.js";
|
|
8
|
+
import { defineTool, defineToolSet } from "./tools/helper.js";
|
|
9
|
+
import { EmbeddingModelItemSchema, LLMModelItemSchema, ListModelsSchema, ModelItemSchema, ModelTypeEnum, RerankModelItemSchema, STTModelSchema, TTSModelSchema } from "./models/schemas.js";
|
|
10
|
+
import { TemplateItemSchema, TemplateListSchema } from "./workflows/schemas.js";
|
|
11
|
+
import { ToolTagsNameMap } from "./tools/constants.js";
|
|
12
|
+
|
|
13
|
+
export { EmbeddingModelItemSchema, FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum, I18nStringSchema, I18nStringStrictSchema, InputSchema, LLMModelItemSchema, LLMModelTypeEnum, ListModelsSchema, ModelItemSchema, ModelTypeEnum, OutputSchema, RerankModelItemSchema, STTModelSchema, SecretInputItemSchema, StreamDataAnswerTypeEnum, StreamDataSchema, StreamMessageSchema, StreamMessageTypeEnum, SystemVarSchema, TTSModelSchema, TemplateItemSchema, TemplateListSchema, ToolConfigSchema, ToolDetailSchema, ToolHandlerReturnSchema, ToolSchema, ToolSetConfigSchema, ToolSetSchema, ToolSimpleSchema, ToolTagEnum, ToolTagsNameMap, UnifiedToolSchema, VersionListItemSchema, WorkflowIOValueTypeEnum, batch, catchError, defineTool, defineToolSet, delay, ensureDir, pkg, refreshDir, unpkg };
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { z as z$1 } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/models/schemas.d.ts
|
|
4
|
+
declare enum ModelTypeEnum {
|
|
5
|
+
llm = "llm",
|
|
6
|
+
embedding = "embedding",
|
|
7
|
+
rerank = "rerank",
|
|
8
|
+
tts = "tts",
|
|
9
|
+
stt = "stt"
|
|
10
|
+
}
|
|
11
|
+
declare const LLMModelItemSchema: z$1.ZodObject<{
|
|
12
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
13
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
14
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
15
|
+
provider: z$1.ZodString;
|
|
16
|
+
model: z$1.ZodString;
|
|
17
|
+
name: z$1.ZodString;
|
|
18
|
+
type: z$1.ZodLiteral<ModelTypeEnum.llm>;
|
|
19
|
+
maxContext: z$1.ZodNumber;
|
|
20
|
+
maxTokens: z$1.ZodNumber;
|
|
21
|
+
quoteMaxToken: z$1.ZodNumber;
|
|
22
|
+
maxTemperature: z$1.ZodUnion<readonly [z$1.ZodNumber, z$1.ZodNull]>;
|
|
23
|
+
showTopP: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
24
|
+
responseFormatList: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
25
|
+
showStopSign: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
26
|
+
censor: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
27
|
+
vision: z$1.ZodBoolean;
|
|
28
|
+
reasoning: z$1.ZodBoolean;
|
|
29
|
+
toolChoice: z$1.ZodBoolean;
|
|
30
|
+
datasetProcess: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
31
|
+
usedInClassify: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
32
|
+
usedInExtractFields: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
33
|
+
usedInToolCall: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
34
|
+
useInEvaluation: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
35
|
+
defaultSystemChatPrompt: z$1.ZodOptional<z$1.ZodString>;
|
|
36
|
+
defaultConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
37
|
+
fieldMap: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
38
|
+
}, z$1.core.$strip>;
|
|
39
|
+
declare const EmbeddingModelItemSchema: z$1.ZodObject<{
|
|
40
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
41
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
42
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
43
|
+
provider: z$1.ZodString;
|
|
44
|
+
model: z$1.ZodString;
|
|
45
|
+
name: z$1.ZodString;
|
|
46
|
+
type: z$1.ZodLiteral<ModelTypeEnum.embedding>;
|
|
47
|
+
defaultToken: z$1.ZodNumber;
|
|
48
|
+
maxToken: z$1.ZodNumber;
|
|
49
|
+
weight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
50
|
+
hidden: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
51
|
+
normalization: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
52
|
+
defaultConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
53
|
+
dbConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
54
|
+
queryConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
55
|
+
}, z$1.core.$strip>;
|
|
56
|
+
declare const RerankModelItemSchema: z$1.ZodObject<{
|
|
57
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
58
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
59
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
60
|
+
provider: z$1.ZodString;
|
|
61
|
+
model: z$1.ZodString;
|
|
62
|
+
name: z$1.ZodString;
|
|
63
|
+
type: z$1.ZodLiteral<ModelTypeEnum.rerank>;
|
|
64
|
+
}, z$1.core.$strip>;
|
|
65
|
+
declare const TTSModelSchema: z$1.ZodObject<{
|
|
66
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
67
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
68
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
69
|
+
provider: z$1.ZodString;
|
|
70
|
+
model: z$1.ZodString;
|
|
71
|
+
name: z$1.ZodString;
|
|
72
|
+
type: z$1.ZodLiteral<ModelTypeEnum.tts>;
|
|
73
|
+
voices: z$1.ZodArray<z$1.ZodObject<{
|
|
74
|
+
label: z$1.ZodString;
|
|
75
|
+
value: z$1.ZodString;
|
|
76
|
+
}, z$1.core.$strip>>;
|
|
77
|
+
}, z$1.core.$strip>;
|
|
78
|
+
declare const STTModelSchema: z$1.ZodObject<{
|
|
79
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
80
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
81
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
82
|
+
provider: z$1.ZodString;
|
|
83
|
+
model: z$1.ZodString;
|
|
84
|
+
name: z$1.ZodString;
|
|
85
|
+
type: z$1.ZodLiteral<ModelTypeEnum.stt>;
|
|
86
|
+
}, z$1.core.$strip>;
|
|
87
|
+
declare const ModelItemSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
88
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
89
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
90
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
91
|
+
provider: z$1.ZodString;
|
|
92
|
+
model: z$1.ZodString;
|
|
93
|
+
name: z$1.ZodString;
|
|
94
|
+
type: z$1.ZodLiteral<ModelTypeEnum.llm>;
|
|
95
|
+
maxContext: z$1.ZodNumber;
|
|
96
|
+
maxTokens: z$1.ZodNumber;
|
|
97
|
+
quoteMaxToken: z$1.ZodNumber;
|
|
98
|
+
maxTemperature: z$1.ZodUnion<readonly [z$1.ZodNumber, z$1.ZodNull]>;
|
|
99
|
+
showTopP: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
100
|
+
responseFormatList: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
101
|
+
showStopSign: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
102
|
+
censor: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
103
|
+
vision: z$1.ZodBoolean;
|
|
104
|
+
reasoning: z$1.ZodBoolean;
|
|
105
|
+
toolChoice: z$1.ZodBoolean;
|
|
106
|
+
datasetProcess: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
107
|
+
usedInClassify: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
108
|
+
usedInExtractFields: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
109
|
+
usedInToolCall: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
110
|
+
useInEvaluation: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
111
|
+
defaultSystemChatPrompt: z$1.ZodOptional<z$1.ZodString>;
|
|
112
|
+
defaultConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
113
|
+
fieldMap: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
114
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
115
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
116
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
117
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
118
|
+
provider: z$1.ZodString;
|
|
119
|
+
model: z$1.ZodString;
|
|
120
|
+
name: z$1.ZodString;
|
|
121
|
+
type: z$1.ZodLiteral<ModelTypeEnum.embedding>;
|
|
122
|
+
defaultToken: z$1.ZodNumber;
|
|
123
|
+
maxToken: z$1.ZodNumber;
|
|
124
|
+
weight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
125
|
+
hidden: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
126
|
+
normalization: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
127
|
+
defaultConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
128
|
+
dbConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
129
|
+
queryConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
130
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
131
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
132
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
133
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
134
|
+
provider: z$1.ZodString;
|
|
135
|
+
model: z$1.ZodString;
|
|
136
|
+
name: z$1.ZodString;
|
|
137
|
+
type: z$1.ZodLiteral<ModelTypeEnum.rerank>;
|
|
138
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
139
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
140
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
141
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
142
|
+
provider: z$1.ZodString;
|
|
143
|
+
model: z$1.ZodString;
|
|
144
|
+
name: z$1.ZodString;
|
|
145
|
+
type: z$1.ZodLiteral<ModelTypeEnum.tts>;
|
|
146
|
+
voices: z$1.ZodArray<z$1.ZodObject<{
|
|
147
|
+
label: z$1.ZodString;
|
|
148
|
+
value: z$1.ZodString;
|
|
149
|
+
}, z$1.core.$strip>>;
|
|
150
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
151
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
152
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
153
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
154
|
+
provider: z$1.ZodString;
|
|
155
|
+
model: z$1.ZodString;
|
|
156
|
+
name: z$1.ZodString;
|
|
157
|
+
type: z$1.ZodLiteral<ModelTypeEnum.stt>;
|
|
158
|
+
}, z$1.core.$strip>], "type">;
|
|
159
|
+
declare const ListModelsSchema: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
|
|
160
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
161
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
162
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
163
|
+
provider: z$1.ZodString;
|
|
164
|
+
model: z$1.ZodString;
|
|
165
|
+
name: z$1.ZodString;
|
|
166
|
+
type: z$1.ZodLiteral<ModelTypeEnum.llm>;
|
|
167
|
+
maxContext: z$1.ZodNumber;
|
|
168
|
+
maxTokens: z$1.ZodNumber;
|
|
169
|
+
quoteMaxToken: z$1.ZodNumber;
|
|
170
|
+
maxTemperature: z$1.ZodUnion<readonly [z$1.ZodNumber, z$1.ZodNull]>;
|
|
171
|
+
showTopP: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
172
|
+
responseFormatList: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
173
|
+
showStopSign: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
174
|
+
censor: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
175
|
+
vision: z$1.ZodBoolean;
|
|
176
|
+
reasoning: z$1.ZodBoolean;
|
|
177
|
+
toolChoice: z$1.ZodBoolean;
|
|
178
|
+
datasetProcess: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
179
|
+
usedInClassify: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
180
|
+
usedInExtractFields: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
181
|
+
usedInToolCall: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
182
|
+
useInEvaluation: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
183
|
+
defaultSystemChatPrompt: z$1.ZodOptional<z$1.ZodString>;
|
|
184
|
+
defaultConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
185
|
+
fieldMap: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
186
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
187
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
188
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
189
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
190
|
+
provider: z$1.ZodString;
|
|
191
|
+
model: z$1.ZodString;
|
|
192
|
+
name: z$1.ZodString;
|
|
193
|
+
type: z$1.ZodLiteral<ModelTypeEnum.embedding>;
|
|
194
|
+
defaultToken: z$1.ZodNumber;
|
|
195
|
+
maxToken: z$1.ZodNumber;
|
|
196
|
+
weight: z$1.ZodOptional<z$1.ZodNumber>;
|
|
197
|
+
hidden: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
198
|
+
normalization: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
199
|
+
defaultConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
200
|
+
dbConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
201
|
+
queryConfig: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
|
|
202
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
203
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
204
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
205
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
206
|
+
provider: z$1.ZodString;
|
|
207
|
+
model: z$1.ZodString;
|
|
208
|
+
name: z$1.ZodString;
|
|
209
|
+
type: z$1.ZodLiteral<ModelTypeEnum.rerank>;
|
|
210
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
211
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
212
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
213
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
214
|
+
provider: z$1.ZodString;
|
|
215
|
+
model: z$1.ZodString;
|
|
216
|
+
name: z$1.ZodString;
|
|
217
|
+
type: z$1.ZodLiteral<ModelTypeEnum.tts>;
|
|
218
|
+
voices: z$1.ZodArray<z$1.ZodObject<{
|
|
219
|
+
label: z$1.ZodString;
|
|
220
|
+
value: z$1.ZodString;
|
|
221
|
+
}, z$1.core.$strip>>;
|
|
222
|
+
}, z$1.core.$strip>, z$1.ZodObject<{
|
|
223
|
+
charsPointsPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
224
|
+
inputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
225
|
+
outputPrice: z$1.ZodOptional<z$1.ZodNumber>;
|
|
226
|
+
provider: z$1.ZodString;
|
|
227
|
+
model: z$1.ZodString;
|
|
228
|
+
name: z$1.ZodString;
|
|
229
|
+
type: z$1.ZodLiteral<ModelTypeEnum.stt>;
|
|
230
|
+
}, z$1.core.$strip>], "type">>;
|
|
231
|
+
type ModelItemType = z$1.infer<typeof ModelItemSchema>;
|
|
232
|
+
type ListModelsType = z$1.infer<typeof ListModelsSchema>;
|
|
233
|
+
//#endregion
|
|
234
|
+
export { EmbeddingModelItemSchema, LLMModelItemSchema, ListModelsSchema, ListModelsType, ModelItemSchema, ModelItemType, ModelTypeEnum, RerankModelItemSchema, STTModelSchema, TTSModelSchema };
|