Skip to content

Commit bcdf318

Browse files
c121914yuFinleyGectrlz526dreamer6680samqin123
authored
V0.2 dev (#192)
* feat: hot swapping (#171) * implement upload and delete API for tools (#126) * implement upload and delete API for tools * update .env.template for MongoDB configuration and refactor S3 file handling * refactor: simplify plugin model and schema * feat: implement upload and delete functionality for tools with MongoDB integration * refactor: update S3 configuration and improve tool API error handling * refactor: enhance tool API with improved error handling and S3 configuration updates (#148) * fix:change url of doc (#136) * feat: support system-toolset (#114) (#132) * feat: support system-toolset (#114) * feat: support system-toolset * chore: remove pnpm-lock.yaml * chore: update lock file * chore: extract secretInputConfig out of inputs for tools * chore: adjust * chore: npm release v0.1.3 * feat: integrate Signoz for monitoring and logging tools (#140) * feat: integrate Signoz for monitoring and logging tools * refactor: restructure Signoz metrics handling into a class for improved initialization and recording * fix bun.lock * feat(tool): metaso (#143) * feat: add metaso plugin (#138) * feat: metaso toolset * fix: vitest coverage * 更新了KnowS插件,以及xiaoyibao插件/Clinicaltrials插件 (#123) * feat(plugin): add xiaoyibao assistant tool - Add xiaoyibao cancer patient assistant tool - Provide professional medical consultation and personalized advice - Support workflow global variables for flexible configuration * chore: update dependencies and ignore local config * Add xiaoyibao plugin files * feat: 添加临床试验查询插件 - 实现临床试验查询功能,支持疾病、基因、药物等多维度搜索 - 修复KRAS查询API参数问题,使用query.cond格式 - 提供三层结构化输出:概述、统计、详情 - 支持中英文查询,智能参数解析 - 完善错误处理和超时机制 - 添加详细的使用说明和工作流配置示例 - 包含FastGPT插件配置方法和最佳实践 * chore: 更新.gitignore并删除辅助开发yml文件,添加测试文件 * docs: 添加本地开发和PR提交指导文档 * docs: 添加基于临床试验插件的完整开发指南 * docs: 优化FastGPT插件开发框架指南和专家提示词 - 更新AI_coding_guide.md为专门的FastGPT插件开发框架 - 重构developer_prompt.md为专业的插件开发专家助手 - 涵盖完整的开发工作流、代码规范和最佳实践 - 提供实用的工具函数和调试技巧 * docs: 完善FastGPT插件开发PRD模板,以临床试验插件为示例 * fix(knows): 修复summary工具answerType参数问题 - 修复summary工具配置,将answerType从多选改为单选 - 移除'全部'选项,只保留CLINICAL、RESEARCH、POPULAR_SCIENCE三种类型 - 修复shared/types.ts中AnswerRequest接口的answer_type字段类型 - 添加详细的调试日志,类似search工具的日志格式 - 增加兼容性处理,支持数组输入的向后兼容 - 修复history工具的API方法名错误(listQuestion -> listQuestions) - 统一所有工具的错误处理和日志格式 主要修改文件: - modules/tool/packages/knows/children/summary/config.ts - modules/tool/packages/knows/children/summary/src/index.ts - modules/tool/packages/knows/children/history/src/index.ts - modules/tool/packages/knows/shared/types.ts - modules/tool/packages/knows/shared/api.ts * feat: 修正工具图标配置路径格式 - 修正 xiaoyibao 工具图标路径为 /imgs/tools/xiaoyibao.svg - 修正 clinicalTrials 工具图标路径为 /imgs/tools/clinicalTrials.svg - 确认 knows 工具图标路径配置正确 - 更新开发日志记录图标配置修正过程 - 构建并复制图标文件到 public/imgs/tools/ 目录 修复了之前使用 plugins/ 格式导致图标无法显示的问题, 现在使用正确的 /imgs/tools/ 路径格式符合 FastGPT 规范。 --------- Co-authored-by: Finley Ge <[email protected]> * feat(tool): xiaoyibao, knows * pnpm-lock.yaml --------- Co-authored-by: samqin123 <[email protected]> * fix: mathExprVal (#144) * fix: support link & codeblock (#145) fix: #141 * fix: markdown transform (#146) * fix: markdown transform * fix: type error fix: labring/FastGPT#5348 * feat: model config (#147) * lock * feat: model config * implement upload and delete API for tools * update .env.template for MongoDB configuration and refactor S3 file handling * refactor: simplify plugin model and schema * feat: implement upload and delete functionality for tools with MongoDB integration * refactor: update S3 configuration and improve tool API error handling * refactor: enhance tool API with improved error handling and S3 configuration updates --------- Co-authored-by: dreamer6680 <[email protected]> Co-authored-by: Finley Ge <[email protected]> Co-authored-by: samqin123 <[email protected]> Co-authored-by: Archer <[email protected]> * refactor: plugin tool upload * feat: support multi-node cache & hot-swapping tools * chore: update .env.template * fix(type): type error * chore: adjust code * chore: adjust * perf(acid): upload/delete acid * chore: upload could overwrite * chore: sdk export upload tools path * chore: remove default mongo connect url * fix: build dist remove mongo relative code * chore: upgrade sdk --------- Co-authored-by: Ctrlz <[email protected]> Co-authored-by: dreamer6680 <[email protected]> Co-authored-by: samqin123 <[email protected]> Co-authored-by: Archer <[email protected]> * perf: s3 rename * fix: plugin upload bug * perf: hot swapping (#187) * chore: adjust * feat: auto clean orphan plugins, redis distrubute lock * deps: remove @types/node-cron * fix: prod tool init/run * perf: download file error catch (#188) * perf: s3 checker * chore: throw error (#189) * chore: update sdk version to v0.1.19 (#191) * fix: use external base url when generate post url (#193) * fix: use external base url when generate post url * fix: download tool file return toolid, when undefined returned, do not add the plugin * chore: refresh uploaded tools when starting * fix: redis prefix * rename bucket * rename bucket * rename bucket * limit fetch url size * limit fetch url size --------- Co-authored-by: Finley Ge <[email protected]> Co-authored-by: Ctrlz <[email protected]> Co-authored-by: dreamer6680 <[email protected]> Co-authored-by: samqin123 <[email protected]>
1 parent aa7b389 commit bcdf318

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1404
-326
lines changed

.env.template

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,28 @@ LOG_LEVEL=info
77
# Model provider sort
88
MODEL_PROVIDER_PRIORITY=
99

10-
# MinIO Config
11-
# Customize MinIO Endpoint. Such as https://example.com The URL returned will be rewrite by this Endpoint: https://example.com/{{filename}}
12-
MINIO_CUSTOM_ENDPOINT=
13-
MINIO_ENDPOINT=localhost
14-
MINIO_PORT=9000
15-
MINIO_USE_SSL=false
16-
MINIO_ACCESS_KEY=minioadmin
17-
MINIO_SECRET_KEY=minioadmin
18-
MINIO_BUCKET=files
10+
# Signoz
11+
SIGNOZ_BASE_URL=
12+
SIGNOZ_SERVICE_NAME=fastgpt-plugin
13+
14+
# S3 Config
15+
# Customize S3 Base URL, for example: https://s3.example.com, make sure you can access your files via https://s3.example.com/[bucket]/[objectname]
16+
S3_EXTERNAL_BASE_URL=
17+
S3_ENDPOINT=localhost
18+
S3_PORT=9000
19+
S3_USE_SSL=false
20+
S3_ACCESS_KEY=minioadmin
21+
S3_SECRET_KEY=minioadmin
22+
S3_TOOL_BUCKET=fastgpt-tool # 系统工具,创建的临时文件,存储的桶,要求公开读私有写。
23+
S3_PLUGIN_BUCKET=fastgpt-plugin # 系统插件热安装文件的桶,私有读写。
24+
RETENTION_DAYS=15 # 系统工具临时文件保存天数
1925

2026
# Signoz
2127
SIGNOZ_BASE_URL=
2228
SIGNOZ_SERVICE_NAME=fastgpt-plugin
29+
30+
# MongoDB connection string
31+
# Replace 'myusername' and 'mypassword' with your actual MongoDB credentials and ensure the database 'fastgpt' exists.
32+
MONGODB_URI=mongodb://myusername:mypassword@localhost:27017/fastgpt?authSource=admin&directConnection=true
33+
34+
REDIS_URL=redis://default:[email protected]:6379

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ node_modules
77
public/imgs/
88
.local
99
pnpm-lock.yaml
10+
local/

bun.lock

Lines changed: 73 additions & 4 deletions
Large diffs are not rendered by default.

env.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
declare namespace NodeJS {
22
interface ProcessEnv {
3-
MINIO_CUSTOM_ENDPOINT: string;
4-
MINIO_ENDPOINT: string;
5-
MINIO_PORT: string;
6-
MINIO_USE_SSL: string;
7-
MINIO_ACCESS_KEY: string;
8-
MINIO_SECRET_KEY: string;
9-
MINIO_BUCKET: string;
3+
S3_EXTERNAL_BASE_URL: string;
4+
S3_ENDPOINT: string;
5+
S3_PORT: string;
6+
S3_USE_SSL: string;
7+
S3_ACCESS_KEY: string;
8+
S3_SECRET_KEY: string;
9+
S3_BUCKET: string;
1010
MAX_FILE_SIZE: string;
1111
RETENTION_DAYS: string;
1212
}

modules/model/init.ts

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,44 @@
1-
import alicloud from './provider/AliCloud/index';
2-
import baai from './provider/BAAI/index';
3-
import baichuan from './provider/Baichuan/index';
4-
import chatglm from './provider/ChatGLM/index';
5-
import claude from './provider/Claude/index';
6-
import deepseek from './provider/DeepSeek/index';
7-
import doubao from './provider/Doubao/index';
8-
import ernie from './provider/Ernie/index';
9-
import fishaudio from './provider/FishAudio/index';
10-
import gemini from './provider/Gemini/index';
11-
import grok from './provider/Grok/index';
12-
import groq from './provider/Groq/index';
13-
import hunyuan from './provider/Hunyuan/index';
14-
import intern from './provider/InternLM/index';
15-
import jina from './provider/Jina/index';
16-
import meta from './provider/Meta/index';
17-
import minimax from './provider/MiniMax/index';
18-
import mistralai from './provider/MistralAI/index';
19-
import moka from './provider/Moka/index';
20-
import moonshot from './provider/Moonshot/index';
21-
import ollama from './provider/Ollama/index';
22-
import openai from './provider/OpenAI/index';
23-
import other from './provider/Other/index';
24-
import ppio from './provider/PPIO/index';
25-
import qwen from './provider/Qwen/index';
26-
import siliconflow from './provider/Siliconflow/index';
27-
import sparkdesk from './provider/SparkDesk/index';
28-
import stepfun from './provider/StepFun/index';
29-
import yi from './provider/Yi/index';
1+
import alicloud from './provider/AliCloud';
2+
import baai from './provider/BAAI';
3+
import baichuan from './provider/Baichuan';
4+
import chatglm from './provider/ChatGLM';
5+
import claude from './provider/Claude';
6+
import deepseek from './provider/DeepSeek';
7+
import doubao from './provider/Doubao';
8+
import ernie from './provider/Ernie';
9+
import fishaudio from './provider/FishAudio';
10+
import gemini from './provider/Gemini';
11+
import grok from './provider/Grok';
12+
import groq from './provider/Groq';
13+
import hunyuan from './provider/Hunyuan';
14+
import intern from './provider/InternLM';
15+
import jina from './provider/Jina';
16+
import meta from './provider/Meta';
17+
import minimax from './provider/MiniMax';
18+
import mistralai from './provider/MistralAI';
19+
import moka from './provider/Moka';
20+
import moonshot from './provider/Moonshot';
21+
import ollama from './provider/Ollama';
22+
import openai from './provider/OpenAI';
23+
import other from './provider/Other';
24+
import ppio from './provider/PPIO';
25+
import qwen from './provider/Qwen';
26+
import siliconflow from './provider/Siliconflow';
27+
import sparkdesk from './provider/SparkDesk';
28+
import stepfun from './provider/StepFun';
29+
import yi from './provider/Yi';
30+
import ai360 from './provider/ai360';
31+
import huggingface from './provider/HuggingFace';
32+
import novita from './provider/novita';
33+
import openrouter from './provider/OpenRouter';
3034

3135
import { ModelItemSchema, ModelTypeEnum, type ProviderConfigType } from './type';
3236
import { modelsBuffer } from './constants';
3337
import { addLog } from '@/utils/log';
3438

3539
// All providers array in alphabetical order
3640
const allProviders: ProviderConfigType[] = [
41+
ai360,
3742
alicloud,
3843
baai,
3944
baichuan,
@@ -46,6 +51,7 @@ const allProviders: ProviderConfigType[] = [
4651
gemini,
4752
grok,
4853
groq,
54+
huggingface,
4955
hunyuan,
5056
intern,
5157
jina,
@@ -54,8 +60,10 @@ const allProviders: ProviderConfigType[] = [
5460
mistralai,
5561
moka,
5662
moonshot,
63+
novita,
5764
ollama,
5865
openai,
66+
openrouter,
5967
other,
6068
ppio,
6169
qwen,

modules/tool/api/list.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { s } from '@/router/init';
22
import { contract } from '@/contract';
3-
import { tools } from '@tool/constants';
43
import { formatToolList } from '@tool/utils/tool';
4+
import { builtinTools } from '@tool/constants';
5+
import { getCachedData } from '@/cache';
6+
import { SystemCacheKeyEnum } from '@/cache/type';
57

68
export const getToolsHandler = s.route(contract.tool.list, async () => {
9+
// this list will only be called when syncKey is changed.
10+
const uploadedTools = await getCachedData(SystemCacheKeyEnum.systemTool);
711
return {
812
status: 200,
9-
body: formatToolList(tools)
13+
body: formatToolList([...builtinTools, ...uploadedTools])
1014
};
1115
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { s } from '@/router/init';
2+
import { contract } from '@/contract';
3+
import { mongoSessionRun } from '@/mongo/utils';
4+
import { downloadTool } from '@tool/controller';
5+
import { MongoPluginModel, pluginTypeEnum } from '@/mongo/models/plugins';
6+
import { refreshVersionKey } from '@/cache';
7+
import { SystemCacheKeyEnum } from '@/cache/type';
8+
import { addLog } from '@/utils/log';
9+
import { pluginFileS3Server } from '@/s3';
10+
11+
export default s.route(contract.tool.upload.confirmUpload, async ({ body }) => {
12+
const { objectName } = body;
13+
14+
await mongoSessionRun(async (session) => {
15+
const toolId = await downloadTool(objectName);
16+
if (!toolId) return Promise.reject('Can not parse ToolId from the tool, installation failed.');
17+
const oldTool = await MongoPluginModel.findOneAndUpdate(
18+
{
19+
toolId
20+
},
21+
{
22+
objectName,
23+
type: pluginTypeEnum.Enum.tool
24+
},
25+
{
26+
session,
27+
upsert: true
28+
}
29+
);
30+
if (oldTool?.objectName) pluginFileS3Server.removeFile(oldTool.objectName);
31+
await refreshVersionKey(SystemCacheKeyEnum.systemTool);
32+
addLog.info(`Upload tool success: ${toolId}`);
33+
});
34+
35+
return {
36+
status: 200,
37+
body: {
38+
message: 'ok'
39+
}
40+
};
41+
});

modules/tool/api/upload/delete.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { contract } from '@/contract';
2+
import { MongoPluginModel } from '@/mongo/models/plugins';
3+
import { mongoSessionRun } from '@/mongo/utils';
4+
import { s } from '@/router/init';
5+
import { pluginFileS3Server } from '@/s3';
6+
import { refreshVersionKey } from '@/cache';
7+
import { SystemCacheKeyEnum } from '@/cache/type';
8+
9+
export default s.route(contract.tool.upload.delete, async ({ query: { toolId: rawToolId } }) => {
10+
const toolId = rawToolId.split('-').slice(1).join('-');
11+
await mongoSessionRun(async (session) => {
12+
const result = await MongoPluginModel.findOneAndDelete({ toolId }).session(session);
13+
if (!result) {
14+
return {
15+
status: 404,
16+
body: {
17+
error: `Tool with toolId ${toolId} not found in MongoDB`
18+
}
19+
};
20+
}
21+
await pluginFileS3Server.removeFile(result.objectName);
22+
await refreshVersionKey(SystemCacheKeyEnum.systemTool);
23+
});
24+
25+
return {
26+
status: 200,
27+
body: {
28+
message: 'Tool deleted successfully'
29+
}
30+
};
31+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { s } from '@/router/init';
2+
import { contract } from '@/contract';
3+
import { pluginFileS3Server } from '@/s3';
4+
import { UploadToolsS3Path } from '@tool/constants';
5+
import { mimeMap } from '@/s3/const';
6+
7+
export default s.route(contract.tool.upload.getUploadURL, async ({ query: { filename } }) => {
8+
return {
9+
status: 200,
10+
body: await pluginFileS3Server.generateUploadPresignedURL({
11+
filepath: UploadToolsS3Path,
12+
contentType: mimeMap['.js'],
13+
filename
14+
})
15+
};
16+
});

modules/tool/api/upload/router.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { contract } from '@/contract';
2+
import { s } from '@/router/init';
3+
import confirmUpload from './confirmUpload';
4+
import getUploadURL from './getUploadURL';
5+
import deleteHandler from './delete';
6+
7+
export default s.router(contract.tool.upload, {
8+
confirmUpload,
9+
getUploadURL,
10+
delete: deleteHandler
11+
});

0 commit comments

Comments
 (0)