mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-05 02:41:34 +00:00
fix: keep relevance scores on knowledge tool citations (#31307)
With native function calling, citations produced by query_knowledge_files and query_chat_files never showed the relevance percentage badge, while the same knowledge base queried through classic RAG did. The tools already return a distance per chunk, but the step that groups tool results into citation sources dropped it. Each grouped source now carries a distances list aligned with its documents, the same shape the classic RAG path emits, so the existing citation UI shows the badge without frontend changes. Chunks without a score (notes) leave the list empty, which the UI already treats as no score. Fixes #29776
This commit is contained in:
parent
0fe9ed0d3c
commit
1c813902ec
1 changed files with 3 additions and 0 deletions
|
|
@ -510,6 +510,7 @@ def get_citation_source_from_tool_result(
|
|||
},
|
||||
'document': [],
|
||||
'metadata': [],
|
||||
'distances': [],
|
||||
}
|
||||
|
||||
sources_by_file[key]['document'].append(content)
|
||||
|
|
@ -521,6 +522,8 @@ def get_citation_source_from_tool_result(
|
|||
**({'note_id': note_id} if note_id else {}),
|
||||
}
|
||||
)
|
||||
if 'distance' in chunk:
|
||||
sources_by_file[key]['distances'].append(chunk['distance'])
|
||||
|
||||
# Return all grouped sources as a list
|
||||
if sources_by_file:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue