fix: external knowledge citations show the domain instead of the page title (#31982)

The inline citation markers in answers from external knowledge bases (Qdrant, Milvus, pgvector) showed the site's domain, for example docs.example.test, instead of the page title saved with each document. They now show that title, the same way a regular knowledge base shows the file name, and still fall back to the domain when a document has no title. Two different pages can share a title, so each marker now looks up its title by the page it points to; before, a repeated title made every later marker show the next page's title and the last one show nothing.

Fixes https://github.com/open-webui/open-webui/issues/31929
This commit is contained in:
Classic298 2026-10-07 13:05:34 +02:00 • committed by GitHub
parent 30dbf3256a
commit 77febc65d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View file

@ -47,7 +47,7 @@ def _normalize_result(result: dict, mapping: dict, knowledge: KnowledgeModel, di
source_name = source or title or metadata.get('source') or metadata.get('name') or knowledge.name
metadata.update(
{
'name': title or source_name,
'name': title or metadata.get('name') or source_name,
'source': source_name,
'url': url,
'file_id': document_id or f'external-{knowledge.id}',

View file

@ -105,6 +105,7 @@
const getSourceIds = (sources) => {
const result = [];
const seenIds = new Set();
for (const source of sources ?? []) {
for (let index = 0; index < (source.document ?? []).length; index++) {
if (model?.info?.meta?.capabilities?.citations == false) {
@ -112,7 +113,11 @@
continue;
}
const metadata = source.metadata?.[index];
const id = metadata?.source ?? 'N/A';
const id = metadata?.source ?? source?.source?.id ?? 'N/A';
if (seenIds.has(id)) {
continue;
}
seenIds.add(id);
if (metadata?.name) {
result.push(metadata.name);
} else if (id.startsWith('http://') || id.startsWith('https://')) {
@ -122,7 +127,7 @@
}
}
}
sourceIds = [...new Set(result)];
sourceIds = result;
};
/** @param {string} messageContent */