优化建议模式;修复多索引训练失败问题 (#1043)

* doc

* Optimize possible null Pointers and parts of Ux

* fix: mulity index training error
This commit is contained in:
Archer
2024-03-21 19:48:57 +08:00
committed by GitHub
parent 9d27de154b
commit a63467d751
11 changed files with 407 additions and 28 deletions

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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说明是执行一个工具