mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac
This commit is contained in:
parent
cd5e2be27b
commit
6dc0df2473
4 changed files with 33 additions and 8 deletions
|
|
@ -710,9 +710,26 @@ async def chat_completion_files_handler(
|
||||||
|
|
||||||
log.debug(f"rag_contexts:sources: {sources}")
|
log.debug(f"rag_contexts:sources: {sources}")
|
||||||
|
|
||||||
sources_count = 0
|
unique_ids = set()
|
||||||
for source in sources:
|
|
||||||
sources_count += len(source.get("document", []))
|
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__(
|
await __event_emitter__(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -643,10 +643,12 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="chat-{message.role} w-full min-w-full markdown-prose">
|
<div class="chat-{message.role} w-full min-w-full markdown-prose">
|
||||||
<div>
|
<div>
|
||||||
|
{#if model?.info?.meta?.capabilities?.status_updates ?? true}
|
||||||
<StatusHistory
|
<StatusHistory
|
||||||
statusHistory={message?.statusHistory}
|
statusHistory={message?.statusHistory}
|
||||||
expand={message?.content === ''}
|
expand={message?.content === ''}
|
||||||
/>
|
/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if message?.files && message.files?.filter((f) => f.type === 'image').length > 0}
|
{#if message?.files && message.files?.filter((f) => f.type === 'image').length > 0}
|
||||||
<div class="my-1 w-full flex overflow-x-auto gap-2 flex-wrap">
|
<div class="my-1 w-full flex overflow-x-auto gap-2 flex-wrap">
|
||||||
|
|
@ -732,7 +734,7 @@
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="w-full flex flex-col relative" id="response-content-container">
|
<div class="w-full flex flex-col relative" id="response-content-container">
|
||||||
{#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)}
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
{:else if message.content && message.error !== true}
|
{:else if message.content && message.error !== true}
|
||||||
<!-- always show message contents even if there's an error -->
|
<!-- always show message contents even if there's an error -->
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@
|
||||||
citations: {
|
citations: {
|
||||||
label: $i18n.t('Citations'),
|
label: $i18n.t('Citations'),
|
||||||
description: $i18n.t('Displays citations in the response')
|
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;
|
code_interpreter?: boolean;
|
||||||
usage?: boolean;
|
usage?: boolean;
|
||||||
citations?: boolean;
|
citations?: boolean;
|
||||||
|
status_updates?: boolean;
|
||||||
} = {};
|
} = {};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@
|
||||||
image_generation: true,
|
image_generation: true,
|
||||||
code_interpreter: true,
|
code_interpreter: true,
|
||||||
citations: true,
|
citations: true,
|
||||||
|
status_updates: true,
|
||||||
usage: undefined
|
usage: undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue