Skip to content

Commit 6d4b331

Browse files
authored
Fix history in classifyQuestion and extract modules (FlowiseAI#1012)
* Fix history in classifyQuestion and extract modules * Add chatValue2RuntimePrompt import and update text formatting
1 parent a6bb554 commit 6d4b331

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

projects/app/src/service/moduleDispatch/agent/classifyQuestion.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
ChatCompletionTool
2525
} from '@fastgpt/global/core/ai/type';
2626
import { DispatchNodeResultType } from '@fastgpt/global/core/module/runtime/type';
27+
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';
2728

2829
type Props = ModuleDispatchProps<{
2930
[ModuleInputKeyEnum.aiModel]: string;
@@ -125,7 +126,7 @@ const getFunctionCallSchema = ({
125126
? `<背景知识>
126127
${systemPrompt}
127128
</背景知识>
128-
129+
129130
问题: "${userChatInput}"
130131
`
131132
: userChatInput
@@ -284,7 +285,9 @@ const completions = async ({
284285
typeList: agents
285286
.map((item) => `{"questionType": "${item.value}", "typeId": "${item.key}"}`)
286287
.join('\n'),
287-
history: histories.map((item) => `${item.obj}:${item.value}`).join('\n'),
288+
history: histories
289+
.map((item) => `${item.obj}:${chatValue2RuntimePrompt(item.value).text}`)
290+
.join('\n'),
288291
question: userChatInput
289292
})
290293
}

projects/app/src/service/moduleDispatch/agent/extract.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from '@fastgpt/global/core/ai/type';
2626
import { ChatCompletionRequestMessageRoleEnum } from '@fastgpt/global/core/ai/constants';
2727
import { DispatchNodeResultType } from '@fastgpt/global/core/module/runtime/type';
28+
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';
2829

2930
type Props = ModuleDispatchProps<{
3031
[ModuleInputKeyEnum.history]?: ChatItemType[];
@@ -160,7 +161,7 @@ const getFunctionCallSchema = ({
160161
- 字符串不要换行。
161162
- 结合上下文和当前问题进行获取。
162163
"""
163-
164+
164165
当前问题: "${content}"`
165166
}
166167
}
@@ -325,8 +326,8 @@ const completions = async ({
325326
}}`
326327
)
327328
.join('\n'),
328-
text: `${histories.map((item) => `${item.obj}:${item.value}`).join('\n')}
329-
Human: ${content}`
329+
text: `${histories.map((item) => `${item.obj}:${chatValue2RuntimePrompt(item.value).text}`).join('\n')}
330+
Human: ${content}`
330331
})
331332
}
332333
}

0 commit comments

Comments
 (0)