fix(chat-fixed-assets): 修复固资连续问答与宽泛查询空字段问题
This commit is contained in:
1 parent
599475d4e2
commit
1164ae2e3c
7 files changed
+417
-46
No files matched your search
@@ -8,6 +8,29 @@ import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ChatUploadFileSpec } from '../types/shipping.types';
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
|
||||
const looksLikeCompletedAssistantReply = (content: string) => {
|
||||
if (!content) return false;
|
||||
return (
|
||||
content.includes('<details>')
|
||||
|| content.includes('**查询结果如下:**')
|
||||
|| content.includes('**错误详情**')
|
||||
|| content.includes('[FILE_START]')
|
||||
|| content.includes('【💡 数据概述】')
|
||||
|| content.includes('【📊 数据预览】')
|
||||
|| content.includes('【📈 数据分析汇总报告】')
|
||||
|| content.includes('系统为您从数据库中检索到共计')
|
||||
);
|
||||
};
|
||||
|
||||
const canContinueSendWhileThinking = (messages: ChatMessage[]) => {
|
||||
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
||||
const message = messages[i];
|
||||
if (message?.role !== 'assistant') continue;
|
||||
return looksLikeCompletedAssistantReply(String(message.content || ''));
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
export interface ChatPageSendContext {
|
||||
input: Ref<string>;
|
||||
messages: Ref<ChatMessage[]>;
|
||||
@@ -52,8 +75,9 @@ export interface ChatPageSendContext {
|
||||
|
||||
export function createChatPageSendApi(ctx: ChatPageSendContext) {
|
||||
const canSendMessage = computed(() => {
|
||||
if (ctx.isThinking.value || ctx.isUploadingAttachments.value) return false;
|
||||
if (ctx.input.value.trim()) return true;
|
||||
const allowSendWhileThinking = canContinueSendWhileThinking(ctx.messages.value);
|
||||
if (ctx.isUploadingAttachments.value) return false;
|
||||
if (ctx.input.value.trim()) return !ctx.isThinking.value || allowSendWhileThinking;
|
||||
if (ctx.allowsSendWithAttachmentsOnly.value) return true;
|
||||
return false;
|
||||
});
|
||||
@@ -61,10 +85,11 @@ export function createChatPageSendApi(ctx: ChatPageSendContext) {
|
||||
const handleSend = async (textOrEvent?: string | Event) => {
|
||||
const content = (typeof textOrEvent === 'string' ? textOrEvent : null) || ctx.input.value;
|
||||
const trimmed = content.trim();
|
||||
const allowSendWhileThinking = canContinueSendWhileThinking(ctx.messages.value);
|
||||
if (await ctx.tryHandleShippingAttachmentAutoFlow(textOrEvent, content, trimmed)) {
|
||||
return;
|
||||
}
|
||||
if (!trimmed || ctx.isThinking.value || ctx.isUploadingAttachments.value) {
|
||||
if (!trimmed || ctx.isUploadingAttachments.value || (ctx.isThinking.value && !allowSendWhileThinking)) {
|
||||
return;
|
||||
}
|
||||
if (ctx.tryHandleLeaveSend(content)) {
|
||||
|
||||
Reference in new issue
Block a user