Commit 01be378d authored by chenghong_tao's avatar chenghong_tao

Add 显示工作流,fix自动滚动

parent e4ac9f90
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
:historyMsgId="item?.id" :historyMsgId="item?.id"
:messageType="item.type" :messageType="item.type"
:content="item.content" :content="item.content"
@reStartSSE="scrollToBottomStart"
/> />
<userBubble v-else :content="item.content"/> <userBubble v-else :content="item.content"/>
</div> </div>
...@@ -68,15 +69,19 @@ const userQuery = (query, isLoading=false) => { ...@@ -68,15 +69,19 @@ const userQuery = (query, isLoading=false) => {
}) })
if (isLoading) { if (isLoading) {
inputMessageRef.value.changeLoading(true) inputMessageRef.value.changeLoading(true)
// 每隔500ms滚动到底部 scrollToBottomStart()
nextTick(() => {
scrollTimer.value = setInterval(() => {
scrollToBottom()
}, 300)
})
} }
} }
const scrollToBottomStart = () => {
clearInterval(scrollTimer.value)
// 每隔500ms滚动到底部
nextTick(() => {
scrollTimer.value = setInterval(() => {
scrollToBottom()
}, 300)
})
}
const defaultHeight = ref(62); const defaultHeight = ref(62);
const scrollbarStyle = computed(() => { const scrollbarStyle = computed(() => {
...@@ -119,8 +124,6 @@ watch(() => props.historyMsgList, (newValue) => { ...@@ -119,8 +124,6 @@ watch(() => props.historyMsgList, (newValue) => {
content: item?.answer, content: item?.answer,
id: item.id id: item.id
}) })
console.log('zhisx');
}, {immediate: true}) }, {immediate: true})
}) })
......
...@@ -6,14 +6,13 @@ ...@@ -6,14 +6,13 @@
<template #content> <template #content>
<div class="custom-bubble-content" v-adjust-width> <div class="custom-bubble-content" v-adjust-width>
<!-- 工作流 --> <!-- 工作流 -->
<!-- <workflowItem <workflowItem
v-if="workflowContent.length > 0" v-if="taskStore.showWorkflow"
:workflowContent="workflowContent" :workflowContent="workflowContent"
ref="workflowItemRef" ref="workflowItemRef"
@workflow-is-error="workflowIsError" />
/> -->
<!-- 使用 MarkdownRenderer 组件渲染 messageContent --> <!-- 使用 MarkdownRenderer 组件渲染 messageContent -->
<div class="icon" v-if="workflowStatus && workflowStatus != 'success'"> <div class="icon" v-if="workflowStatus && workflowStatus != 'success' && !taskStore.showWorkflow">
<div v-if="workflowStatus == 'loading'"> <div v-if="workflowStatus == 'loading'">
<el-icon style="font-size: 18px" class="is-loaidng"> <el-icon style="font-size: 18px" class="is-loaidng">
<Loading /> <Loading />
...@@ -33,35 +32,60 @@ ...@@ -33,35 +32,60 @@
</template> </template>
<template #footer> <template #footer>
<div class="footer-container"> <div class="footer-container">
<el-button <el-tooltip
type="info" effect="dark"
:icon="Refresh" content="重新回答"
size="small" placement="top"
circle
:disabled="taskStore.isLoading" :disabled="taskStore.isLoading"
@click="reStartSSE" >
/> <el-button
<el-button type="info"
:type="clickLike ? 'success' : 'info'" :icon="Refresh"
class="iconfont icon-zan" size="small"
size="small" circle
circle :disabled="taskStore.isLoading"
@click="feedback('like')" @click="reStartSSE"
/> />
<el-button </el-tooltip>
:type="clickDisLike ? 'success' : 'info'" <el-tooltip
class="iconfont icon-zan icon-rotate" effect="dark"
size="small" :content="clickLike ? '取消点赞' : '点赞'"
circle placement="top"
@click="feedback('dislike')" >
/> <el-button
<el-button :type="clickLike ? 'success' : 'info'"
color="#626aef" class="iconfont icon-zan"
:icon="DocumentCopy" size="small"
size="small" circle
circle @click="feedback('like')"
@click="copyContent()" />
/> </el-tooltip>
<el-tooltip
effect="dark"
:content="clickDisLike ? '取消点踩' : '点踩'"
placement="top"
>
<el-button
:type="clickDisLike ? 'success' : 'info'"
class="iconfont icon-zan icon-rotate"
size="small"
circle
@click="feedback('dislike')"
/>
</el-tooltip>
<el-tooltip
effect="dark"
content="复制"
placement="top"
>
<el-button
color="#626aef"
:icon="DocumentCopy"
size="small"
circle
@click="copyContent()"
/>
</el-tooltip>
</div> </div>
</template> </template>
</Bubble> </Bubble>
...@@ -86,7 +110,7 @@ const clickDisLike = ref(false) ...@@ -86,7 +110,7 @@ const clickDisLike = ref(false)
const isReStartWorkflow = ref(false) const isReStartWorkflow = ref(false)
const workflowStatus = ref(null) const workflowStatus = ref(null)
const emits = defineEmits(["reStartSSE"]);
const props = defineProps({ const props = defineProps({
query: { query: {
type: Array, type: Array,
...@@ -192,12 +216,13 @@ const workflowContent = computed(() => { ...@@ -192,12 +216,13 @@ const workflowContent = computed(() => {
return workflowList; return workflowList;
}); });
// const workflowItemRef = ref(null); const workflowItemRef = ref(null);
const reStartSSE = () => { const reStartSSE = () => {
isReStartWorkflow.value = true; isReStartWorkflow.value = true;
// if(workflowItemRef.value) { if(workflowItemRef.value) {
// workflowItemRef.value.clearWorkflow(); workflowItemRef.value.clearWorkflow();
// } }
emits("reStartSSE")
startSSE(props.query); startSSE(props.query);
console.log('reStartSSE', props.query, props.messageType, props.content) console.log('reStartSSE', props.query, props.messageType, props.content)
}; };
...@@ -301,9 +326,6 @@ function fallbackCopyTextToClipboard(text) { ...@@ -301,9 +326,6 @@ function fallbackCopyTextToClipboard(text) {
document.body.removeChild(textArea); document.body.removeChild(textArea);
} }
// const workflowIsError = (isError) => {
// emits("workflow-is-error", isError);
// };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.message-content { .message-content {
......
...@@ -8,11 +8,18 @@ ...@@ -8,11 +8,18 @@
v-model="senderValue" v-model="senderValue"
:loading="senderLoading" :loading="senderLoading"
clearable clearable
variant="updown"
:auto-size="{ minRows: 2, maxRows: 5 }"
@submit="handleSubmit" @submit="handleSubmit"
> >
<template #prefix>
<div class="action-list-self-wrap">
<el-checkbox v-model="showWorkflow" label="显示工作流" style="margin-right: 10px;" border />
<el-checkbox v-model="deepThink" label="深度思考" style="margin-right: 10px;" border />
</div>
</template>
<template #action-list> <template #action-list>
<div class="action-list-self-wrap"> <div class="action-list-self-wrap">
<el-checkbox v-model="deepThink" label="深度思考" style="margin-right: 20px;" border />
<el-button <el-button
type="danger" type="danger"
link link
...@@ -62,7 +69,8 @@ const senderRef = ref(); ...@@ -62,7 +69,8 @@ const senderRef = ref();
const senderValue = ref(""); const senderValue = ref("");
const senderLoading = ref(false); const senderLoading = ref(false);
const inputRef = ref(null); const inputRef = ref(null);
const deepThink = ref(false); const deepThink = ref(taskStore.deepThink || false);
const showWorkflow = ref(taskStore.showWorkflow || false);
watch(() => deepThink.value, (newValue) => { watch(() => deepThink.value, (newValue) => {
taskStore.setDeepThink(newValue) taskStore.setDeepThink(newValue)
...@@ -72,6 +80,10 @@ watch(() => taskStore.isLoading, (newValue) => { ...@@ -72,6 +80,10 @@ watch(() => taskStore.isLoading, (newValue) => {
senderLoading.value = newValue; senderLoading.value = newValue;
}) })
watch(() => showWorkflow.value, (newValue) => {
taskStore.setShowWorkflow(newValue)
})
const emit = defineEmits(["userQuery", "getInputHeight"]); const emit = defineEmits(["userQuery", "getInputHeight"]);
function handleSubmit() { function handleSubmit() {
senderLoading.value = true; senderLoading.value = true;
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
<WarningFilled /> <WarningFilled />
</el-icon> </el-icon>
</div> </div>
<el-collapse class="workflow-collapse"> <el-collapse class="workflow-collapse" v-model="activeNames">
<el-collapse-item title="工作流"> <el-collapse-item title="工作流" name="workflow">
<ThoughtChain :thinking-items="thinkingItems" row-key="codeId" dot-size="small" <ThoughtChain :thinking-items="thinkingItems" row-key="codeId" dot-size="small"
style="margin-left: 10px" /> style="margin-left: 10px" />
</el-collapse-item> </el-collapse-item>
...@@ -36,6 +36,8 @@ const props = defineProps({ ...@@ -36,6 +36,8 @@ const props = defineProps({
const thinkingItems = ref([]); const thinkingItems = ref([]);
const workflowStatus = ref('loading') const workflowStatus = ref('loading')
const activeNames = ref(['workflow'])
const emit = defineEmits(['workflow-is-error']) const emit = defineEmits(['workflow-is-error'])
watch( watch(
...@@ -47,7 +49,6 @@ watch( ...@@ -47,7 +49,6 @@ watch(
if (item.event === "error") { if (item.event === "error") {
ElMessage.error(item.message) ElMessage.error(item.message)
workflowStatus.value = 'error'; workflowStatus.value = 'error';
emit('workflow-is-error', true)
break; break;
} }
if (item.event === "workflow_finished") { if (item.event === "workflow_finished") {
...@@ -59,30 +60,37 @@ watch( ...@@ -59,30 +60,37 @@ watch(
item.event !== "message_end" && item.event !== "message_end" &&
item.event !== "message" item.event !== "message"
) { ) {
const dataId = item?.data?.id;
const index = thinkingItems.value.findIndex( const index = thinkingItems.value.findIndex(
(ti) => ti.codeId === item.data.id (ti) => ti.codeId === dataId
); );
const dataId = item?.data?.id;
// 判断是否为 code、tool 节点,如果是则排除 // 判断是否为 code、tool 节点,如果是则排除
// const isExcludeNode = item?.data?.node_type === "code" || item?.data?.node_type === "tool"; const excludedNodeTypes = ['code', 'start', 'question-classifier', 'if-else', 'answer'];
// 非代码节点才添加到 thinkingItems 中 const isExcludeNode = excludedNodeTypes.includes(item?.data?.node_type);
// if (!isExcludeNode) { if (!isExcludeNode) {
if (index === -1) { if (index === -1) {
thinkingItems.value.push({ // 如果存在迭代节点,且迭代节点正在执行,则不再添加后续节点
codeId: dataId, const iterationItem = thinkingItems.value.filter(m => m.type === 'iteration')
status: "loading", if (iterationItem.length > 0 && iterationItem[0].status === 'loading') {
isCanExpand: false, console.log('迭代中');
isDefaultExpand: false, } else {
title: item.data.title, thinkingItems.value.push({
thinkTitle: "", codeId: dataId,
thinkContent: "", status: "loading",
}); isCanExpand: false,
isDefaultExpand: false,
title: item.data.title,
thinkTitle: "",
thinkContent: "",
type: item?.data?.node_type
});
}
} else { } else {
if (item.event === "node_finished") { if (item.event === "node_finished" || item.event === "iteration_completed") {
thinkingItems.value[index].status = "success"; thinkingItems.value[index].status = "success";
} }
} }
// } }
} }
} }
console.log("thinkingItems.value", thinkingItems.value); console.log("thinkingItems.value", thinkingItems.value);
......
...@@ -9,6 +9,7 @@ export const useTaskStore = defineStore('task', { ...@@ -9,6 +9,7 @@ export const useTaskStore = defineStore('task', {
workflow_run_id: '', // 当前工作流运行id workflow_run_id: '', // 当前工作流运行id
isLoading: false, isLoading: false,
deepThink: false, deepThink: false,
showWorkflow: false
} }
}, },
actions: { actions: {
...@@ -32,6 +33,9 @@ export const useTaskStore = defineStore('task', { ...@@ -32,6 +33,9 @@ export const useTaskStore = defineStore('task', {
setDeepThink(think) { setDeepThink(think) {
this.deepThink = think this.deepThink = think
}, },
setShowWorkflow(show) {
this.showWorkflow = show
},
clear () { clear () {
this.taskId = '' this.taskId = ''
this.conversation_id = '' this.conversation_id = ''
...@@ -39,6 +43,7 @@ export const useTaskStore = defineStore('task', { ...@@ -39,6 +43,7 @@ export const useTaskStore = defineStore('task', {
this.workflow_run_id = '' this.workflow_run_id = ''
this.isLoading = false this.isLoading = false
this.deepThink = false this.deepThink = false
this.showWorkflow = false
} }
}, },
persist: { persist: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment