Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions modules/tool/api/runStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Request, Response, NextFunction } from 'express';
import { getTool } from '@tool/controller';
import { dispatchWithNewWorker } from '@/worker';
import { StreamManager } from '../utils/stream';
import { StreamMessageTypeEnum } from '../type/tool';
import { StreamMessageTypeEnum, type RunToolSecondParamsType } from '../type/tool';
import { addLog } from '@/utils/log';
import { getErrText } from '@tool/utils/err';
import { recordToolExecution } from '@/utils/signoz';
Expand All @@ -25,18 +25,37 @@ export const runToolStreamHandler = async (
}
const streamManager = new StreamManager(res);
try {
addLog.debug(`Run tool start`, { toolId, inputs, systemVar });

const result = await dispatchWithNewWorker({
toolId,
inputs,
systemVar,
onMessage: (e) =>
const result = await (async () => {
const streamResponse: RunToolSecondParamsType['streamResponse'] = (e) =>
streamManager.sendMessage({
type: StreamMessageTypeEnum.stream,
data: e
})
});
});

if (tool.isWorkerRun === false) {
addLog.debug(`Run tool start`, { toolId, inputs, systemVar });
return tool
.cb(inputs, {
systemVar,
streamResponse
})
.then((res) => {
if (res.error) {
return Promise.reject(res.error);
}
return res;
});
}

addLog.debug(`Run tool start in worker`, { toolId, inputs, systemVar });

return dispatchWithNewWorker({
toolId,
inputs,
systemVar,
onMessage: streamResponse
});
})();

streamManager.sendMessage({
type: StreamMessageTypeEnum.response,
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/DingTalkWebhook/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastg
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.communication,
name: {
'zh-CN': '钉钉 webhook',
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/Doc2X/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineToolSet } from '@tool/type';
import { ToolTypeEnum } from '@tool/type/tool';

export default defineToolSet({
isWorkerRun: false,
name: {
'zh-CN': 'Doc2X 服务',
en: 'Doc2X Service'
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/WeWorkWebhook/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.communication,
name: {
'zh-CN': '企业微信 webhook',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'FLUX文生图',
en: 'FLUX Text-to-Image'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': '通义万相文生图v2',
en: 'Qwen Wanx Text-to-Image'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'FLUX.1 图像编辑',
en: 'FLUX.1 Image Editing'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'FLUX.1 图像生成',
en: 'FLUX.1 Image Generation'
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/bocha/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': '博查搜索',
en: 'Bocha Search'
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/chatPPT/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastg
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
courseUrl: 'https://wiki.yoo-ai.com/api/guide.html',
name: {
'zh-CN': '必优ChatPPT',
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/dalle3/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.multimodal,
name: {
'zh-CN': 'Dalle3 绘图',
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/delay/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastg
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.tools,
name: {
'zh-CN': '流程等待',
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/duckduckgo/children/search/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'DuckDuckGo 网络搜索',
en: 'DuckDuckGo Network Search'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'DuckDuckGo 图片搜索',
en: 'DockDuckGo Image Search'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'DuckDuckGo 新闻检索',
en: 'DockDuckGo News Search'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'DuckDuckGo 视频检索',
en: 'DockDuckGo Video Search'
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/feishu/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.communication,
name: {
'zh-CN': '飞书 webhook',
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/firecrawl/children/scrape/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineTool } from '@tool/type';
import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': '抓取网页内容',
en: 'Scrape web content'
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/getTime/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { WorkflowIOValueTypeEnum } from '@tool/type/fastgpt';
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.tools,
name: {
'zh-CN': '获取当前时间',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineTool } from '@tool/type';
import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'GitHub 仓库信息查询',
en: 'GitHub Repository Info Query'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineTool } from '@tool/type';
import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'GitHub 用户信息查询',
en: 'GitHub User Info Query'
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/google/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastg
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.search,
name: {
'zh-CN': 'Google 搜索',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.tools,
name: {
'zh-CN': 'Jina AI 网页解析',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.search,
name: {
'zh-CN': 'Jina AI 搜索',
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/libulibu/children/star3/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'star3',
en: 'star3'
Expand Down
1 change: 1 addition & 0 deletions modules/tool/packages/mathExprVal/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.scientific,
name: {
'zh-CN': '数学公式执行',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastg
import { ToolTypeEnum } from '@tool/type/tool';

export default defineTool({
isWorkerRun: false,
type: ToolTypeEnum.search,
name: {
'zh-CN': '秘塔搜索',
Expand Down
4 changes: 2 additions & 2 deletions modules/tool/packages/minmax/children/tts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineTool } from '@tool/type';
import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'minmax 文本转语音',
en: 'minmax Text-to-Speech'
Expand Down Expand Up @@ -108,8 +109,7 @@ export default defineTool({
label: '情绪',
renderTypeList: [FlowNodeInputTypeEnum.select, FlowNodeInputTypeEnum.reference],
valueType: WorkflowIOValueTypeEnum.string,
required: true,
defaultValue: 'auto',
required: false,
list: [
{ label: '高兴', value: 'happy' },
{ label: '悲伤', value: 'sad' },
Expand Down
28 changes: 2 additions & 26 deletions modules/tool/packages/minmax/children/tts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { z } from 'zod';
import { POST } from '@tool/utils/request';
import { uploadFile } from '@tool/utils/uploadFile';
import { ErrorCodeMap } from '@tool/packages/minmax/constants';

export const InputType = z.object({
apiKey: z.string(),
Expand Down Expand Up @@ -56,6 +57,7 @@ export async function tool({
headers
}
);
console.log(syncData, 223232);
if (syncData.base_resp.status_code !== 0) {
return Promise.reject(
ErrorCodeMap[syncData.base_resp.status_code as keyof typeof ErrorCodeMap]
Expand All @@ -79,29 +81,3 @@ export async function tool({

return { audioUrl };
}

const ErrorCodeMap = {
1000: '未知错误/系统默认错误',
1001: '请求超时',
1002: '请求频率超限',
1004: '未授权/Token不匹配/Cookie缺失',
1008: '余额不足',
1024: '内部错误',
1026: '输入内容涉敏',
1027: '输出内容涉敏',
1033: '系统错误/下游服务错误',
1039: 'Token限制',
1041: '连接数限制',
1042: '不可见字符比例超限/非法字符超过10%',
1043: 'ASR相似度检查失败',
1044: '克隆提示词相似度检查失败',
2013: '参数错误',
20132: '语音克隆样本或voice_id参数错误',
2037: '语音时长不符合要求(太长或太短)',
2038: '用户语音克隆功能被禁用',
2039: '语音克隆voice_id重复',
2042: '无权访问该voice_id',
2045: '请求频率增长超限',
2048: '语音克隆提示音频太长',
2049: '无效的API Key'
};
25 changes: 25 additions & 0 deletions modules/tool/packages/minmax/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export const ErrorCodeMap = {
1000: '未知错误/系统默认错误',
1001: '请求超时',
1002: '请求频率超限',
1004: '未授权/Token不匹配/Cookie缺失',
1008: '余额不足',
1024: '内部错误',
1026: '输入内容涉敏',
1027: '输出内容涉敏',
1033: '系统错误/下游服务错误',
1039: 'Token限制',
1041: '连接数限制',
1042: '不可见字符比例超限/非法字符超过10%',
1043: 'ASR相似度检查失败',
1044: '克隆提示词相似度检查失败',
2013: '参数错误',
20132: '语音克隆样本或voice_id参数错误',
2037: '语音时长不符合要求(太长或太短)',
2038: '用户语音克隆功能被禁用',
2039: '语音克隆voice_id重复',
2042: '无权访问该voice_id',
2045: '请求频率增长超限',
2048: '语音克隆提示音频太长',
2049: '无效的API Key'
};
1 change: 1 addition & 0 deletions modules/tool/packages/mojiWeather/children/tool/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineTool } from '@tool/type';
import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': '每日天气',
en: 'Daily Weather'
Expand Down
2 changes: 1 addition & 1 deletion modules/tool/packages/openrouterMultiModal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"dependencies": {
"zod": "^3.24.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineTool } from '@tool/type';
import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': '网络搜索',
en: 'Network search'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineTool } from '@tool/type';
import { FlowNodeInputTypeEnum, WorkflowIOValueTypeEnum } from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': '百度搜索',
en: 'Baidu Search'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@tool/type/fastgpt';

export default defineTool({
isWorkerRun: false,
name: {
'zh-CN': 'Google 图片搜索',
en: 'Google Search'
Expand Down
Loading