Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(embed): preserve draft when attachment read fails (#4118)
hahahahahayesyeseys44f16dd2f216
diff --git a/frontend/src/components/EmbedInputField.vue b/frontend/src/components/EmbedInputField.vueindex 844802e47..699a62dc7 100644--- a/frontend/src/components/EmbedInputField.vue+++ b/frontend/src/components/EmbedInputField.vue@@ -128,7 +128,7 @@ const props = defineProps<{}>()const emit = defineEmits<{- (e: 'send-msg', query: string, imageFiles: File[], attachmentFiles: File[]): void+ (e: 'send-msg', query: string, imageFiles: File[], attachmentFiles: File[], onPrepared: () => void): void(e: 'stop-generation'): void(e: 'update:webSearchEnabled', value: boolean): void}>()@@ -253,16 +253,22 @@ const removeImage = (index: number) => {const submit = () => {if (props.isReplying || !canSend.value) return+ const submittedQuery = query.value+ const submittedImages = [...uploadedImages.value]+ const submittedAttachments = [...uploadedAttachments.value]const val = query.value.trim()- const imageFiles = uploadedImages.value.map((img) => img.file)- const attachmentFiles = uploadedAttachments.value.map((att) => att.file)+ const imageFiles = submittedImages.map((img) => img.file)+ const attachmentFiles = submittedAttachments.map((att) => att.file)const textarea = getTextareaEl()if (textarea) textarea.blur()- emit('send-msg', val, imageFiles, attachmentFiles)- if (getTextareaEl()) query.value = ''- uploadedImages.value.forEach((img) => URL.revokeObjectURL(img.preview))- uploadedImages.value = []- uploadedAttachments.value = []+ emit('send-msg', val, imageFiles, attachmentFiles, () => {+ if (query.value === submittedQuery && getTextareaEl()) query.value = ''+ for (const image of submittedImages) URL.revokeObjectURL(image.preview)+ uploadedImages.value = uploadedImages.value.filter((image) => !submittedImages.includes(image))+ uploadedAttachments.value = uploadedAttachments.value.filter(+ (attachment) => !submittedAttachments.includes(attachment),+ )+ })}const onKeydown = (_val: string, ctx: { e: KeyboardEvent }) => {diff --git a/frontend/src/composables/useEmbedChatSession.ts b/frontend/src/composables/useEmbedChatSession.tsindex 5876cbffc..213ec93ca 100644--- a/frontend/src/composables/useEmbedChatSession.ts+++ b/frontend/src/composables/useEmbedChatSession.ts@@ -248,7 +248,12 @@ export function useEmbedChatSession(options: {const sendMsg = async (value: string,- opts: { webSearchEnabled?: boolean; imageFiles?: File[]; attachmentFiles?: File[] } = {},+ opts: {+ webSearchEnabled?: boolean+ imageFiles?: File[]+ attachmentFiles?: File[]+ onPrepared?: () => void+ } = {},) => {stopStream()prepareForNewOutgoingMessage()@@ -291,6 +296,7 @@ export function useEmbedChatSession(options: {channel: 'embed',created_at: new Date().toISOString(),})+ opts.onPrepared?.()postEmbedMessageSent(options.channelId, options.sessionId.value, value)relayEmbedWebhookEvent(options.channelId,diff --git a/frontend/src/views/embed/EmbedChatCore.vue b/frontend/src/views/embed/EmbedChatCore.vueindex 854e52015..e625e2c77 100644--- a/frontend/src/views/embed/EmbedChatCore.vue+++ b/frontend/src/views/embed/EmbedChatCore.vue@@ -344,11 +344,17 @@ const fetchSuggestedQuestions = async () => {}}-const onSendMsg = (query: string, imageFiles: File[] = [], attachmentFiles: File[] = []) => {+const onSendMsg = (+ query: string,+ imageFiles: File[] = [],+ attachmentFiles: File[] = [],+ onPrepared?: () => void,+) => {void sendMsg(query, {webSearchEnabled: webSearchEnabled.value,imageFiles,attachmentFiles,+ onPrepared,})}