Skip to content

Commit 7af880f

Browse files
feat: Consciousness recognition node
1 parent 16ade76 commit 7af880f

File tree

9 files changed

+42
-40
lines changed

9 files changed

+42
-40
lines changed

ui/src/components/ai-chat/component/knowledge-source-component/ExecutionDetailCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
v-if="
174174
data.type == WorkflowType.AiChat ||
175175
data.type == WorkflowType.Question ||
176-
data.type == WorkflowType.Application
176+
data.type == WorkflowType.Application || data.type == WorkflowType.IntentNode
177177
"
178178
>
179179
<div class="card-never border-r-6" v-if="data.type !== WorkflowType.Application">

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ export default {
329329
},
330330
intentNode: {
331331
label: 'IntentNode',
332+
text: 'Match user questions with user-defined intent classifications',
332333
other: 'other',
333334
placeholder: 'Please choose a classification option',
334335
classify: {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export default {
141141
continue: 'Continue Generating',
142142
replace: 'Replace',
143143
exit: 'Are you sure you want to exit and discard the AI-generated content?',
144+
loading: 'Generating...',
144145
},
145146
dialog: {
146147
addKnowledge: 'Add Related Knowledge',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ export default {
329329
},
330330
intentNode: {
331331
label: '意图识别',
332+
text: '将用户问题与用户预设的意图分类进行匹配',
332333
other: '其他',
333334
placeholder: '请选择分类项',
334335
classify: {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export default {
133133
continue: '继续生成',
134134
replace: '替换',
135135
exit: '确认退出并舍弃 AI 生成的内容吗?',
136+
loading: '生成中...',
136137
},
137138
dialog: {
138139
addKnowledge: '添加关联知识库',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ export default {
322322
},
323323
intentNode: {
324324
label: '意圖識別',
325+
text: '將用戶問題與用戶預設的意圖分類進行匹配',
325326
other: '其他',
326327
placeholder: '請選擇分類項',
327328
classify: {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export default {
132132
continue: '繼續生成',
133133
replace: '替換',
134134
exit: '確認退出並捨棄 AI 生成的內容嗎?',
135+
loading: '生成中...',
135136
},
136137
dialog: {
137138
addKnowledge: '新增關聯知識庫',

ui/src/views/application/component/GeneratePromptDialog.vue

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</div>
2525
<p v-else-if="loading" shadow="always" style="margin: 0.5rem 0">
2626
<el-icon class="is-loading color-primary mr-4"><Loading /></el-icon>
27-
{{ $t('chat.tip.answerLoading') }}
27+
{{ $t('views.application.generateDialog.loading') }}
2828
<span class="dotting"></span>
2929
</p>
3030
<p v-else class="flex align-center">
@@ -33,11 +33,18 @@
3333
</p>
3434
</el-scrollbar>
3535
<div v-if="answer && !loading && !isStreaming && !showContinueButton">
36-
<el-button type="primary" @click="() => emit('replace', answer)"> {{ $t('views.application.generateDialog.replace') }} </el-button>
36+
<el-button type="primary" @click="() => emit('replace', answer)">
37+
{{ $t('views.application.generateDialog.replace') }}
38+
</el-button>
3739
<el-button @click="reAnswerClick" :disabled="!answer || loading" :loading="loading">
3840
{{ $t('views.application.generateDialog.remake') }}
3941
</el-button>
4042
</div>
43+
<div class="mt-8" v-else>
44+
<el-button type="primary" v-if="showContinueButton" @click="continueStreaming" link>
45+
{{ $t('views.application.generateDialog.continue') }}
46+
</el-button>
47+
</div>
4148
</div>
4249

4350
<!-- 文本输入框 -->
@@ -49,12 +56,7 @@
4956
{{ $t('views.application.generateDialog.stop') }}
5057
</el-button>
5158
</div>
52-
<div v-if="showContinueButton" class="text-center mb-8">
53-
<el-button class="border-primary video-stop-button" @click="continueStreaming">
54-
<app-icon iconName="app-video-stop" class="mr-8"></app-icon>
55-
{{ $t('views.application.generateDialog.continue') }}
56-
</el-button>
57-
</div>
59+
5860
<div class="operate-textarea">
5961
<el-input
6062
ref="quickInputRef"
@@ -75,7 +77,11 @@
7577
:disabled="!inputValue.trim() || loading || isStreaming"
7678
@click="handleSubmit"
7779
>
78-
<img v-show="!inputValue.trim() || loading || isStreaming" src="@/assets/icon_send.svg" alt="" />
80+
<img
81+
v-show="!inputValue.trim() || loading || isStreaming"
82+
src="@/assets/icon_send.svg"
83+
alt=""
84+
/>
7985
<SendIcon v-show="inputValue.trim() && !loading && !isStreaming" />
8086
</el-button>
8187
</div>
@@ -88,7 +94,7 @@
8894
</template>
8995

9096
<script setup lang="ts">
91-
import { computed, onUnmounted,reactive, ref, nextTick, watch } from 'vue'
97+
import { computed, onUnmounted, reactive, ref, nextTick, watch } from 'vue'
9298
import { useRoute } from 'vue-router'
9399
import { MsgConfirm } from '@/utils/message'
94100
import { t } from '@/locales'
@@ -161,7 +167,6 @@ const currentDisplayIndex = ref<number>(0) // 当前显示到的字符位置
161167
let streamTimer: number | null = null // 定时器引用
162168
const isOutputComplete = ref<boolean>(false)
163169
164-
165170
// 模拟流式输出的定时器函数
166171
const startStreamingOutput = () => {
167172
if (streamTimer) {
@@ -182,9 +187,9 @@ const startStreamingOutput = () => {
182187
if (currentAnswer && currentAnswer.role === 'ai') {
183188
currentAnswer.content = fullContent.value.substring(0, currentDisplayIndex.value)
184189
}
185-
} else if (loading.value === false && currentDisplayIndex.value >= fullContent.value.length) {
186-
stopStreaming()
187-
}
190+
} else if (loading.value === false && currentDisplayIndex.value >= fullContent.value.length) {
191+
stopStreaming()
192+
}
188193
}, 50) // 每50ms输出一次
189194
}
190195
@@ -195,7 +200,7 @@ const stopStreaming = () => {
195200
streamTimer = null
196201
}
197202
isStreaming.value = false
198-
isPaused.value = false
203+
isPaused.value = false
199204
loading.value = false
200205
isOutputComplete.value = true
201206
}
@@ -204,7 +209,6 @@ const showStopButton = computed(() => {
204209
return isStreaming.value
205210
})
206211
207-
208212
// 暂停流式输出
209213
const pauseStreaming = () => {
210214
isPaused.value = true
@@ -218,7 +222,6 @@ const continueStreaming = () => {
218222
}
219223
}
220224
221-
222225
/**
223226
* 获取一个递归函数,处理流式数据
224227
* @param chat 每一条对话记录
@@ -227,8 +230,8 @@ const continueStreaming = () => {
227230
*/
228231
const getWrite = (reader: any) => {
229232
let tempResult = ''
230-
const middleAnswer = reactive({ content: '', role: 'ai' })
231-
chatMessages.value.push(middleAnswer )
233+
const middleAnswer = reactive({ content: '', role: 'ai' })
234+
chatMessages.value.push(middleAnswer)
232235
233236
// 初始化状态并
234237
fullContent.value = ''
@@ -245,7 +248,7 @@ const getWrite = (reader: any) => {
245248
const write_stream = ({ done, value }: { done: boolean; value: any }) => {
246249
try {
247250
if (done) {
248-
// 流数据接收完成,但定时器继续运行直到显示完所有内容
251+
// 流数据接收完成,但定时器继续运行直到显示完所有内容
249252
loading.value = false
250253
return
251254
}
@@ -302,10 +305,11 @@ const answer = computed(() => {
302305
303306
// 按钮状态计算
304307
const showContinueButton = computed(() => {
305-
return !isStreaming.value && isPaused.value && currentDisplayIndex.value < fullContent.value.length
308+
return (
309+
!isStreaming.value && isPaused.value && currentDisplayIndex.value < fullContent.value.length
310+
)
306311
})
307312
308-
309313
function generatePrompt(inputValue: any) {
310314
loading.value = true
311315
const workspaceId = user.getWorkspaceId() || 'default'
@@ -360,12 +364,10 @@ const handleSubmit = (event?: any) => {
360364
if (!originalUserInput.value) {
361365
originalUserInput.value = inputValue.value
362366
}
363-
if (inputValue.value) {
367+
if (inputValue.value) {
364368
generatePrompt(inputValue.value)
365-
inputValue.value = ''
369+
inputValue.value = ''
366370
}
367-
368-
369371
} else {
370372
// 如果同时按下ctrl/shift/cmd/opt +enter,则会换行
371373
insertNewlineAtCursor(event)
@@ -415,17 +417,12 @@ const handleScroll = () => {
415417
}
416418
417419
const handleDialogClose = (done: () => void) => {
418-
419420
// 弹出 消息
420-
MsgConfirm(
421-
t('common.tip'),
422-
t('views.application.generateDialog.exit'),
423-
{
424-
confirmButtonText: t('common.confirm'),
425-
cancelButtonText: t('common.cancel'),
426-
distinguishCancelAndClose: true,
427-
}
428-
)
421+
MsgConfirm(t('common.tip'), t('views.application.generateDialog.exit'), {
422+
confirmButtonText: t('common.confirm'),
423+
cancelButtonText: t('common.cancel'),
424+
distinguishCancelAndClose: true,
425+
})
429426
.then(() => {
430427
// 点击确认,清除状态
431428
stopStreaming()
@@ -437,8 +434,7 @@ const handleDialogClose = (done: () => void) => {
437434
})
438435
.catch(() => {
439436
// 点击取消
440-
}
441-
)
437+
})
442438
}
443439
444440
// 组件卸载时清理定时器

ui/src/workflow/common/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ export const toolNode = {
362362

363363
export const intentNode = {
364364
type: WorkflowType.IntentNode,
365-
text: t('views.applicationWorkflow.nodes.intentNode.label'),
365+
text: t('views.applicationWorkflow.nodes.intentNode.text'),
366366
label: t('views.applicationWorkflow.nodes.intentNode.label'),
367367
height: 260,
368368
properties: {

0 commit comments

Comments
 (0)