mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
优化建议模式;修复多索引训练失败问题 (#1043)
* doc * Optimize possible null Pointers and parts of Ux * fix: mulity index training error
This commit is contained in:
@@ -9,7 +9,6 @@ import { getCollectionWithDataset } from '../controller';
|
||||
import { TrainingModeEnum } from '@fastgpt/global/core/dataset/constants';
|
||||
import { simpleText } from '@fastgpt/global/common/string/tools';
|
||||
import { countPromptTokens } from '@fastgpt/global/common/string/tiktoken';
|
||||
import type { VectorModelItemType, LLMModelItemType } from '@fastgpt/global/core/ai/model.d';
|
||||
|
||||
export const lockTrainingDataByTeamId = async (teamId: string): Promise<any> => {
|
||||
try {
|
||||
|
@@ -164,6 +164,15 @@ export const runToolWithPromptCall = async (
|
||||
parseAnswerResult.toolName = toolModule.name;
|
||||
parseAnswerResult.toolAvatar = toolModule.avatar;
|
||||
|
||||
// run tool flow
|
||||
const startParams = (() => {
|
||||
try {
|
||||
return json5.parse(parseAnswerResult.arguments);
|
||||
} catch (error) {
|
||||
return {};
|
||||
}
|
||||
})();
|
||||
|
||||
// SSE response to client
|
||||
if (stream && detail) {
|
||||
responseWrite({
|
||||
@@ -182,15 +191,6 @@ export const runToolWithPromptCall = async (
|
||||
});
|
||||
}
|
||||
|
||||
// run tool flow
|
||||
const startParams = (() => {
|
||||
try {
|
||||
return json5.parse(parseAnswerResult.arguments);
|
||||
} catch (error) {
|
||||
return {};
|
||||
}
|
||||
})();
|
||||
|
||||
const moduleRunResponse = await dispatchWorkFlow({
|
||||
...props,
|
||||
runtimeModules: runtimeModules.map((module) => ({
|
||||
@@ -374,7 +374,7 @@ const parseAnswer = (str: string): FunctionCallCompletion | string => {
|
||||
return {
|
||||
id: getNanoid(),
|
||||
name: toolCall.toolId,
|
||||
arguments: JSON.stringify(toolCall.arguments)
|
||||
arguments: JSON.stringify(toolCall.arguments || toolCall.parameters)
|
||||
};
|
||||
} catch (error) {
|
||||
return str;
|
||||
|
@@ -332,8 +332,8 @@ async function streamResponse({
|
||||
|
||||
const responseChoice = part.choices?.[0]?.delta;
|
||||
// console.log(JSON.stringify(responseChoice, null, 2));
|
||||
if (responseChoice.content) {
|
||||
const content = responseChoice?.content || '';
|
||||
if (responseChoice?.content) {
|
||||
const content = responseChoice.content || '';
|
||||
textAnswer += content;
|
||||
|
||||
responseWrite({
|
||||
@@ -343,7 +343,7 @@ async function streamResponse({
|
||||
text: content
|
||||
})
|
||||
});
|
||||
} else if (responseChoice.tool_calls?.[0]) {
|
||||
} else if (responseChoice?.tool_calls?.[0]) {
|
||||
const toolCall: ChatCompletionMessageToolCall = responseChoice.tool_calls[0];
|
||||
|
||||
// 流响应中,每次只会返回一个工具. 如果带了 id,说明是执行一个工具
|
||||
|
Reference in New Issue
Block a user