Skip to content

Commit 81593b5

Browse files
committed
feat: Support reasoning content(WIP)
1 parent 85e6760 commit 81593b5

File tree

13 files changed

+175
-89
lines changed

13 files changed

+175
-89
lines changed

ui/src/components/ai-chat/component/answer-content/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
></MdRenderer>
1717
<template v-else-if="answer_text.length > 0">
1818
<MdRenderer
19-
v-for="answer in answer_text"
19+
v-for="(answer, index) in answer_text"
20+
:key="index"
2021
:chat_record_id="answer.chat_record_id"
2122
:child_node="answer.child_node"
2223
:runtime_node_id="answer.runtime_node_id"

ui/src/components/markdown/MdRenderer.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<template>
22
<div>
3-
<!-- todo 推理过程组件需要完善,目前用span占位 -->
4-
<span style="color: red">
5-
{{ reasoning_content }}
6-
</span>
3+
<!-- 推理过程组件 -->
4+
<ReasoningRander :content="reasoning_content" v-if="reasoning_content" />
75
<template v-for="(item, index) in md_view_list" :key="index">
86
<div
97
v-if="item.type === 'question'"
@@ -48,6 +46,7 @@ import { config } from 'md-editor-v3'
4846
import HtmlRander from './HtmlRander.vue'
4947
import EchartsRander from './EchartsRander.vue'
5048
import FormRander from './FormRander.vue'
49+
import ReasoningRander from './ReasoningRander.vue'
5150
config({
5251
markdownItConfig(md) {
5352
md.renderer.rules.image = (tokens, idx, options, env, self) => {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<template>
2+
<div class="reasoning">
3+
<el-button link>
4+
{{ $t('views.applicationWorkflow.nodes.aiChatNode.think') }}
5+
</el-button>
6+
<div class="border-l">
7+
<MdPreview
8+
noIconfont
9+
ref="editorRef"
10+
editorId="preview-only"
11+
:modelValue="content"
12+
class="reasoning-md"
13+
/>
14+
</div>
15+
</div>
16+
</template>
17+
<script lang="ts" setup>
18+
const props = defineProps<{ content?: string }>()
19+
</script>
20+
<style lang="scss" scoped>
21+
.reasoning {
22+
padding-left: 8px;
23+
.reasoning-md {
24+
--md-color: var(--app-text-color-secondary) !important;
25+
}
26+
}
27+
</style>

ui/src/locales/lang/en-US/views/application-workflow.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export default {
105105
tooltip: `If turned off, the content of this node will not be output to the user.
106106
If you want the user to see the output of this node, please turn on the switch.`
107107
},
108-
defaultPrompt: 'Known Information'
108+
defaultPrompt: 'Known Information',
109+
think: 'Thinking Process',
109110
},
110111
searchDatasetNode: {
111112
label: 'Knowledge Search',

ui/src/locales/lang/en-US/views/application.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ export default {
6262
references: ' (References Knowledge)',
6363
placeholder: 'Please enter prompt',
6464
requiredMessage: 'Please enter prompt',
65-
tooltip:'By adjusting the content of the prompt, you can guide the direction of the large model chat.',
66-
65+
tooltip:
66+
'By adjusting the content of the prompt, you can guide the direction of the large model chat.',
67+
6768
noReferencesTooltip:
6869
'By adjusting the content of the prompt, you can guide the direction of the large model chat. This prompt will be fixed at the beginning of the context. Variables used: {question} is the question posed by the user.',
6970
referencesTooltip:
@@ -108,9 +109,11 @@ export default {
108109
listeningTest: 'Preview'
109110
},
110111
reasoningContent: {
111-
enable: 'Show Reasoning',
112+
label: 'Output Thinking',
113+
tooltip:
114+
'According to the thinking tags set by the model, the content between the tags will be considered as the thought process.',
112115
start: 'Start',
113-
end: 'End',
116+
end: 'End'
114117
}
115118
},
116119
buttons: {

ui/src/locales/lang/zh-CN/views/application-workflow.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ export default {
106106
tooltip: `关闭后该节点的内容则不输出给用户。
107107
如果你想让用户看到该节点的输出内容,请打开开关。`
108108
},
109-
defaultPrompt: '已知信息'
109+
defaultPrompt: '已知信息',
110+
think: '思考过程',
110111
},
111112
searchDatasetNode: {
112113
label: '知识库检索',

ui/src/locales/lang/zh-CN/views/application.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export default {
5656
references: ' (引用知识库)',
5757
placeholder: '请输入提示词',
5858
requiredMessage: '请输入提示词',
59-
tooltip:'通过调整提示词内容,可以引导大模型聊天方向,该提示词会被固定在上下文的开头,可以使用变量。',
59+
tooltip:
60+
'通过调整提示词内容,可以引导大模型聊天方向,该提示词会被固定在上下文的开头,可以使用变量。',
6061
noReferencesTooltip:
6162
'通过调整提示词内容,可以引导大模型聊天方向,该提示词会被固定在上下文的开头。可以使用变量:{question} 是用户提出问题的占位符。',
6263
referencesTooltip:
@@ -99,9 +100,10 @@ export default {
99100
listeningTest: '试听'
100101
},
101102
reasoningContent: {
102-
enable: '输出思考',
103+
label: '输出思考',
104+
tooltip: '请根据模型返回的思考标签设置,标签中间的内容将为认定为思考过程',
103105
start: '开始',
104-
end: '结束',
106+
end: '结束'
105107
}
106108
},
107109
buttons: {
@@ -201,6 +203,5 @@ export default {
201203
text: '针对用户提问调试段落匹配情况,保障回答效果。',
202204
emptyMessage1: '命中段落显示在这里',
203205
emptyMessage2: '没有命中的分段'
204-
},
205-
206+
}
206207
}

ui/src/locales/lang/zh-Hant/views/application-workflow.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ export default {
106106
tooltip: `關閉後該節點的內容則不輸出給用戶。
107107
如果你想讓用戶看到該節點的輸出內容,請打開開關。`
108108
},
109-
defaultPrompt: '已知信息'
109+
defaultPrompt: '已知信息',
110+
think: '思考過程',
110111
},
111112
searchDatasetNode: {
112113
label: '知識庫檢索',

ui/src/locales/lang/zh-Hant/views/application.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ export default {
100100
listeningTest: '試聽'
101101
},
102102
reasoningContent: {
103-
enable: '输出思考',
104-
start: '开始',
105-
end: '结束',
103+
label: '輸出思考',
104+
tooltip:'請根據模型返回的思考標簽設置,標簽中間的內容將爲認定爲思考過程',
105+
start: '開始',
106+
end: '結束',
106107
}
107108
},
108109
buttons: {

ui/src/views/application/ApplicationSetting.vue

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,7 @@
6565
<template #label>
6666
<div class="flex-between">
6767
<span>{{ $t('views.application.applicationForm.form.aiModel.label') }}</span>
68-
<el-button
69-
type="primary"
70-
link
71-
@click="openReasoningParamSettingDialog"
72-
:disabled="!applicationForm.model_id"
73-
>
74-
{{ $t('common.setting') }}
75-
</el-button>
68+
7669
<el-button
7770
type="primary"
7871
link
@@ -284,6 +277,27 @@
284277
@submitDialog="submitPrologueDialog"
285278
/>
286279
</el-form-item>
280+
<el-form-item @click.prevent>
281+
<template #label>
282+
<div class="flex-between">
283+
<span class="mr-4">
284+
{{ $t('views.application.applicationForm.form.reasoningContent.label') }}
285+
</span>
286+
287+
<div class="flex">
288+
<el-button type="primary" link @click="openReasoningParamSettingDialog">
289+
<el-icon><Setting /></el-icon>
290+
</el-button>
291+
<el-switch
292+
class="ml-8"
293+
size="small"
294+
v-model="applicationForm.model_setting.reasoning_content_enable"
295+
@change="sttModelEnableChange"
296+
/>
297+
</div>
298+
</div>
299+
</template>
300+
</el-form-item>
287301

288302
<el-form-item
289303
prop="stt_model_id"
@@ -461,7 +475,10 @@
461475
/>
462476

463477
<EditAvatarDialog ref="EditAvatarDialogRef" @refresh="refreshIcon" />
464-
<ReasoningParamSettingDialog ref="ReasoningParamSettingDialogRef" @refresh="submitReasoningDialog"/>
478+
<ReasoningParamSettingDialog
479+
ref="ReasoningParamSettingDialogRef"
480+
@refresh="submitReasoningDialog"
481+
/>
465482
</LayoutContainer>
466483
</template>
467484
<script setup lang="ts">
@@ -533,7 +550,8 @@ const applicationForm = ref<ApplicationFormType>({
533550
model_setting: {
534551
prompt: defaultPrompt,
535552
system: t('views.application.applicationForm.form.roleSettings.placeholder'),
536-
no_references_prompt: '{question}'
553+
no_references_prompt: '{question}',
554+
reasoning_content_enable: false,
537555
},
538556
model_params_setting: {},
539557
problem_optimization: false,
@@ -574,7 +592,6 @@ function submitSystemDialog(val: string) {
574592
applicationForm.value.model_setting.system = val
575593
}
576594
function submitReasoningDialog(val: any) {
577-
console.log(val)
578595
applicationForm.value.model_setting = {
579596
...applicationForm.value.model_setting,
580597
...val
@@ -610,9 +627,7 @@ const openAIParamSettingDialog = () => {
610627
}
611628
612629
const openReasoningParamSettingDialog = () => {
613-
if (applicationForm.value.model_id) {
614-
ReasoningParamSettingDialogRef.value?.open(applicationForm.value.model_setting)
615-
}
630+
ReasoningParamSettingDialogRef.value?.open(applicationForm.value.model_setting)
616631
}
617632
618633
const openTTSParamSettingDialog = () => {

0 commit comments

Comments
 (0)