-
-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Bug title
Only 4 or 5 sources are shown in the response but many more are added
Describe the bug
In this example I had 3 sources added (the ones mentioned in the response) but after 1 second, more got added.
The first 3 also have a high score (80%) and the rest is 50% or lower.
I tried turing off followup generation but this did not have an effect.
I tried analyzing this with Copilot but could not apply a fix:
What you’re seeing
During streaming, your function emits only the citations that are actually referenced in the content (e.g., [doc1], [doc2]). That’s by design in __emit_openwebui_citation_events which filters by the indices it finds in the text.
Shortly after the stream finishes, additional citations appear that are not referenced in the generated content.Why this happens
In the streaming path, you do not remove or filter the raw context.citations included in the final message JSON that comes from Azure. Your code only emits filtered citation events, but it leaves the provider’s full context.citations list intact in the SSE JSON that the UI also receives. The UI then renders those extra citations when it processes the final message, which looks like “more citations arriving a bit later.”
Concretely:_emit_openwebui_citation_events(...) filters to only the referenced [docX] indices. If none are found, it falls back to all citations (for backward compatibility).
stream_processor_with_citations(...) updates content (turning [docX] into clickable links) but does not prune choices[].message.context.citations (or choices[].delta.context...) from the SSE JSON lines it forwards.
In the non‑stream path, enhance_azure_search_response(...) converts [docX] to links but likewise does not filter the citations array in the returned response.As a result, you get two sources of citations in the UI:
Your filtered OpenWebUI citation events (correct, only referenced), and
The provider’s unfiltered context.citations included in the final message (causing extra, unreferenced cards to appear afterwards).
Steps to reproduce
- Create new funtion
- Connect with azure ai and azure ai data source
- Chat
Environment
OWUI latest version
Latest azure_ai_foundry.py
Additional context
No response
Metadata
Metadata
Assignees
Labels
Projects
Status