Skip to content

Commit

Permalink
Fix history in classifyQuestion and extract modules (labring#1012)
Browse files Browse the repository at this point in the history
* Fix history in classifyQuestion and extract modules

* Add chatValue2RuntimePrompt import and update text formatting
  • Loading branch information
Fengrui-Liu authored and c121914yu committed Mar 19, 2024
1 parent 232bf05 commit 8de4c93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
ChatCompletionTool
} from '@fastgpt/global/core/ai/type';
import { DispatchNodeResultType } from '@fastgpt/global/core/module/runtime/type';
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';

type Props = ModuleDispatchProps<{
[ModuleInputKeyEnum.aiModel]: string;
Expand Down Expand Up @@ -125,7 +126,7 @@ const getFunctionCallSchema = ({
? `<背景知识>
${systemPrompt}
</背景知识>
问题: "${userChatInput}"
`
: userChatInput
Expand Down Expand Up @@ -284,7 +285,9 @@ const completions = async ({
typeList: agents
.map((item) => `{"questionType": "${item.value}", "typeId": "${item.key}"}`)
.join('\n'),
history: histories.map((item) => `${item.obj}:${item.value}`).join('\n'),
history: histories
.map((item) => `${item.obj}:${chatValue2RuntimePrompt(item.value).text}`)
.join('\n'),
question: userChatInput
})
}
Expand Down
7 changes: 4 additions & 3 deletions projects/app/src/service/moduleDispatch/agent/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '@fastgpt/global/core/ai/type';
import { ChatCompletionRequestMessageRoleEnum } from '@fastgpt/global/core/ai/constants';
import { DispatchNodeResultType } from '@fastgpt/global/core/module/runtime/type';
import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';

type Props = ModuleDispatchProps<{
[ModuleInputKeyEnum.history]?: ChatItemType[];
Expand Down Expand Up @@ -160,7 +161,7 @@ const getFunctionCallSchema = ({
- 字符串不要换行。
- 结合上下文和当前问题进行获取。
"""
当前问题: "${content}"`
}
}
Expand Down Expand Up @@ -325,8 +326,8 @@ const completions = async ({
}}`
)
.join('\n'),
text: `${histories.map((item) => `${item.obj}:${item.value}`).join('\n')}
Human: ${content}`
text: `${histories.map((item) => `${item.obj}:${chatValue2RuntimePrompt(item.value).text}`).join('\n')}
Human: ${content}`
})
}
}
Expand Down

0 comments on commit 8de4c93

Please sign in to comment.