forked from Leaf/amber-ui
改进 工具调用提示
This commit is contained in:
parent
ea5597e6ea
commit
f1fb1625d8
@ -24,13 +24,22 @@
|
|||||||
class="fixed bottom-0 left-0 right-0"
|
class="fixed bottom-0 left-0 right-0"
|
||||||
:class="onBottom ? 'hidden' : 'mb-6'"
|
:class="onBottom ? 'hidden' : 'mb-6'"
|
||||||
>
|
>
|
||||||
<div
|
<!-- <div
|
||||||
class="mx-auto w-2xl max-w-2xl text-center mb-3 animate__animated animate__pulse text-lg"
|
class="mx-auto w-2xl max-w-2xl text-center mb-3 animate__animated animate__pulse text-lg"
|
||||||
v-if="toolCalling"
|
v-if="toolCalling"
|
||||||
>
|
>
|
||||||
<n-gradient-text type="info">
|
<n-gradient-text type="info">
|
||||||
{{ toolName }}
|
{{ toolName }}
|
||||||
</n-gradient-text>
|
</n-gradient-text>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="mx-auto w-2xl max-w-2xl text-center mb-3 animate__animated animate__pulse text-lg"
|
||||||
|
v-if="isMobile && chatStore.toolName != ''"
|
||||||
|
>
|
||||||
|
<n-gradient-text type="info">
|
||||||
|
正在执行 {{ chatStore.toolName }}
|
||||||
|
</n-gradient-text>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
ref="inputContainer"
|
ref="inputContainer"
|
||||||
@ -148,6 +157,7 @@ import MessageList from "./MessageList.vue";
|
|||||||
import { useChatStore } from "@/stores/chat";
|
import { useChatStore } from "@/stores/chat";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import element from "@/config/element";
|
import element from "@/config/element";
|
||||||
|
import { useIsMobile } from "@/utils/composables";
|
||||||
|
|
||||||
// 获取组件传入的 chatId
|
// 获取组件传入的 chatId
|
||||||
const chatId: Ref<string | number | undefined | null> = ref(null);
|
const chatId: Ref<string | number | undefined | null> = ref(null);
|
||||||
@ -165,6 +175,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isMobile = useIsMobile()
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const chatStore = useChatStore();
|
const chatStore = useChatStore();
|
||||||
const compositionStart = ref(false);
|
const compositionStart = ref(false);
|
||||||
@ -178,9 +189,6 @@ const content = ref("");
|
|||||||
const inputExpanded = ref(false);
|
const inputExpanded = ref(false);
|
||||||
const chatMessages: Ref<EntityChatMessage[] | undefined> = ref([]);
|
const chatMessages: Ref<EntityChatMessage[] | undefined> = ref([]);
|
||||||
const processing = ref(false);
|
const processing = ref(false);
|
||||||
const toolName = ref("");
|
|
||||||
const toolError = ref(false);
|
|
||||||
const toolCalling = ref(false);
|
|
||||||
const fileUpload = ref();
|
const fileUpload = ref();
|
||||||
const uploading = ref(false);
|
const uploading = ref(false);
|
||||||
const autoScroll = ref(true);
|
const autoScroll = ref(true);
|
||||||
@ -350,7 +358,7 @@ async function sendMessage(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
toolError.value = false;
|
// toolError.value = false;
|
||||||
getApi()
|
getApi()
|
||||||
.ChatMessage.apiV1ChatsIdMessagesPost(Number(chatId.value), payload)
|
.ChatMessage.apiV1ChatsIdMessagesPost(Number(chatId.value), payload)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
@ -465,28 +473,38 @@ function streamChat(streamId: String, redirect = false) {
|
|||||||
|
|
||||||
switch (data.state) {
|
switch (data.state) {
|
||||||
case "tool_calling":
|
case "tool_calling":
|
||||||
toolCalling.value = true;
|
// toolCalling.value = true;
|
||||||
toolName.value =
|
chatStore.toolName =
|
||||||
data.tool_call_message.tool_name +
|
data.tool_call_message.tool_name +
|
||||||
" 中的 " +
|
" 中的 " +
|
||||||
data.tool_call_message.function_name;
|
data.tool_call_message.function_name;
|
||||||
|
// toolName.value =
|
||||||
|
// data.tool_call_message.tool_name +
|
||||||
|
// " 中的 " +
|
||||||
|
// data.tool_call_message.function_name;
|
||||||
break;
|
break;
|
||||||
case "tool_response":
|
case "tool_response":
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
toolName.value = "";
|
chatStore.toolName = "";
|
||||||
toolCalling.value = false;
|
|
||||||
}, 300);
|
}, 300);
|
||||||
break;
|
break;
|
||||||
case "tool_failed":
|
case "tool_failed":
|
||||||
toolName.value =
|
// toolName.value =
|
||||||
data.tool_response_message.tool_name +
|
// data.tool_response_message.tool_name +
|
||||||
|
// " 中的 " +
|
||||||
|
// data.tool_response_message.function_name;
|
||||||
|
|
||||||
|
chatStore.toolName =
|
||||||
|
data.tool_call_message.tool_name +
|
||||||
" 中的 " +
|
" 中的 " +
|
||||||
data.tool_response_message.function_name;
|
data.tool_call_message.function_name;
|
||||||
toolError.value = true;
|
|
||||||
|
// toolError.value = true;
|
||||||
append = false;
|
append = false;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
toolCalling.value = false;
|
// toolCalling.value = false;
|
||||||
}, 300);
|
chatStore.toolName = "";
|
||||||
|
}, 1000);
|
||||||
break;
|
break;
|
||||||
case "chunk":
|
case "chunk":
|
||||||
if (!messageAdded) {
|
if (!messageAdded) {
|
||||||
|
@ -54,7 +54,10 @@
|
|||||||
<n-grid-item class="flex items-center justify-center select-none">
|
<n-grid-item class="flex items-center justify-center select-none">
|
||||||
<div v-show="!isMobile">
|
<div v-show="!isMobile">
|
||||||
<!-- 中间部分 -->
|
<!-- 中间部分 -->
|
||||||
<n-popover trigger="hover" v-if="!chatStore.currentChat?.id && !chatStore.currentChat?.name">
|
<n-popover
|
||||||
|
trigger="hover"
|
||||||
|
v-if="!chatStore.currentChat?.id && !chatStore.currentChat?.name"
|
||||||
|
>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<img
|
<img
|
||||||
:src="leaflowpng"
|
:src="leaflowpng"
|
||||||
@ -64,6 +67,11 @@
|
|||||||
</template>
|
</template>
|
||||||
<span> Leaflow 利飞 </span>
|
<span> Leaflow 利飞 </span>
|
||||||
</n-popover>
|
</n-popover>
|
||||||
|
<div v-else-if="chatStore.toolName != ''">
|
||||||
|
<n-gradient-text type="info">
|
||||||
|
正在执行 {{ chatStore.toolName }}
|
||||||
|
</n-gradient-text>
|
||||||
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<span>{{ chatStore.currentChat?.name }}</span>
|
<span>{{ chatStore.currentChat?.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,6 +6,7 @@ export const useChatStore = defineStore("chats", {
|
|||||||
state: () => ({
|
state: () => ({
|
||||||
currentChat: <EntityChat | undefined> {},
|
currentChat: <EntityChat | undefined> {},
|
||||||
currentAssistantId: 0,
|
currentAssistantId: 0,
|
||||||
|
toolName: "",
|
||||||
chats: <EntityChat[] | undefined>[],
|
chats: <EntityChat[] | undefined>[],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user