diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 7320d77816..463f52d0af 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -710,9 +710,26 @@ async def chat_completion_files_handler( log.debug(f"rag_contexts:sources: {sources}") - sources_count = 0 - for source in sources: - sources_count += len(source.get("document", [])) + unique_ids = set() + + for source in sources or []: + if not source or len(source.keys()) == 0: + continue + + documents = source.get("document") or [] + metadatas = source.get("metadata") or [] + src_info = source.get("source") or {} + + for index, _ in enumerate(documents): + metadata = metadatas[index] if index < len(metadatas) else None + _id = ( + (metadata or {}).get("source") + or (src_info or {}).get("id") + or "N/A" + ) + unique_ids.add(_id) + + sources_count = len(unique_ids) await __event_emitter__( { diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 0dfe4381c7..9db76bfa85 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -643,10 +643,12 @@
- + {#if model?.info?.meta?.capabilities?.status_updates ?? true} + + {/if} {#if message?.files && message.files?.filter((f) => f.type === 'image').length > 0}
@@ -732,7 +734,7 @@
{:else}
- {#if message.content === '' && !message.error && ((message?.statusHistory ?? [...(message?.status ? [message?.status] : [])]).length === 0 || (message?.statusHistory?.at(-1)?.hidden ?? false))} + {#if message.content === '' && !message.error && ((model?.info?.meta?.capabilities?.status_updates ?? true) ? (message?.statusHistory ?? [...(message?.status ? [message?.status] : [])]).length === 0 || (message?.statusHistory?.at(-1)?.hidden ?? false) : true)} {:else if message.content && message.error !== true} diff --git a/src/lib/components/workspace/Models/Capabilities.svelte b/src/lib/components/workspace/Models/Capabilities.svelte index d0b45384a6..2d10802df8 100644 --- a/src/lib/components/workspace/Models/Capabilities.svelte +++ b/src/lib/components/workspace/Models/Capabilities.svelte @@ -36,6 +36,10 @@ citations: { label: $i18n.t('Citations'), description: $i18n.t('Displays citations in the response') + }, + status_updates: { + label: $i18n.t('Status Updates'), + description: $i18n.t('Displays status updates (e.g., web search progress) in the response') } }; @@ -47,6 +51,7 @@ code_interpreter?: boolean; usage?: boolean; citations?: boolean; + status_updates?: boolean; } = {}; diff --git a/src/lib/components/workspace/Models/ModelEditor.svelte b/src/lib/components/workspace/Models/ModelEditor.svelte index 0791b80bbb..fc9c167e9b 100644 --- a/src/lib/components/workspace/Models/ModelEditor.svelte +++ b/src/lib/components/workspace/Models/ModelEditor.svelte @@ -86,6 +86,7 @@ image_generation: true, code_interpreter: true, citations: true, + status_updates: true, usage: undefined };