mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
Some checks failed
Deploy doc image to cf / deploy-production (push) Has been cancelled
Deploy doc image by kubeconfig / build-fastgpt-docs-images (push) Has been cancelled
Build FastGPT images in Personal warehouse / get-vars (push) Has been cancelled
Deploy doc image by kubeconfig / update-docs-image (push) Has been cancelled
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
Build FastGPT images in Personal warehouse / release-fastgpt-images (push) Has been cancelled
* Match SSE for FastGPT (#5168) * Match SSE for FastGPT * Modify the judgment * Optimize logic for SSE transmission * Refactor imports * directly use workflowStreamResponse from props * improve error handling and streamline onStreamData logic * Refactor API client configuration * perf: system tool support sse * update doc --------- Co-authored-by: Zhuangzai fa <143257420+ctrlz526@users.noreply.github.com>
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import createClient, { RunToolWithStream } from '@fastgpt-sdk/plugin';
|
|
import { PluginSourceEnum } from '@fastgpt/global/core/app/plugin/constants';
|
|
|
|
const BASE_URL = process.env.PLUGIN_BASE_URL || '';
|
|
const TOKEN = process.env.PLUGIN_TOKEN || '';
|
|
|
|
const client = createClient({
|
|
baseUrl: BASE_URL,
|
|
token: TOKEN
|
|
});
|
|
|
|
export async function getSystemToolList() {
|
|
const res = await client.tool.list();
|
|
|
|
if (res.status === 200) {
|
|
return res.body.map((item) => {
|
|
return {
|
|
...item,
|
|
id: `${PluginSourceEnum.systemTool}-${item.id}`,
|
|
parentId: item.parentId ? `${PluginSourceEnum.systemTool}-${item.parentId}` : undefined,
|
|
avatar:
|
|
item.avatar && item.avatar.startsWith('/imgs/tools/')
|
|
? `/api/system/pluginImgs/${item.avatar.replace('/imgs/tools/', '')}`
|
|
: item.avatar
|
|
};
|
|
});
|
|
}
|
|
|
|
return Promise.reject(res.body);
|
|
}
|
|
|
|
const runToolInstance = new RunToolWithStream({
|
|
baseUrl: BASE_URL,
|
|
token: TOKEN
|
|
});
|
|
export const runSystemTool = runToolInstance.run.bind(runToolInstance);
|