mirror of
https://github.com/open-webui/open-webui
synced 2025-06-10 00:17:52 +00:00
enh: provide source name in context if available
This commit is contained in:
parent
8b5e89eada
commit
80eaa24ca8
@ -919,6 +919,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||||||
for doc_context, doc_meta in zip(
|
for doc_context, doc_meta in zip(
|
||||||
source["document"], source["metadata"]
|
source["document"], source["metadata"]
|
||||||
):
|
):
|
||||||
|
source_name = source.get("source", {}).get("name", None)
|
||||||
citation_id = (
|
citation_id = (
|
||||||
doc_meta.get("source", None)
|
doc_meta.get("source", None)
|
||||||
or source.get("source", {}).get("id", None)
|
or source.get("source", {}).get("id", None)
|
||||||
@ -926,7 +927,11 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||||||
)
|
)
|
||||||
if citation_id not in citation_idx:
|
if citation_id not in citation_idx:
|
||||||
citation_idx[citation_id] = len(citation_idx) + 1
|
citation_idx[citation_id] = len(citation_idx) + 1
|
||||||
context_string += f'<source id="{citation_idx[citation_id]}">{doc_context}</source>\n'
|
context_string += (
|
||||||
|
f'<source id="{citation_idx[citation_id]}"'
|
||||||
|
+ (f' name="{source_name}"' if source_name else "")
|
||||||
|
+ f">{doc_context}</source>\n"
|
||||||
|
)
|
||||||
|
|
||||||
context_string = context_string.strip()
|
context_string = context_string.strip()
|
||||||
prompt = get_last_user_message(form_data["messages"])
|
prompt = get_last_user_message(form_data["messages"])
|
||||||
|
Loading…
Reference in New Issue
Block a user