mirror of
https://github.com/open-webui/open-webui
synced 2025-02-22 21:32:32 +00:00
refac: citations
This commit is contained in:
parent
3d0c06ccee
commit
bbda717b69
@ -772,7 +772,7 @@ async def process_chat_payload(request, form_data, metadata, user, model):
|
||||
|
||||
if "document" in source:
|
||||
for doc_idx, doc_context in enumerate(source["document"]):
|
||||
context_string += f"<source><source_id>{doc_idx}</source_id><source_context>{doc_context}</source_context></source>\n"
|
||||
context_string += f"<source><source_id>{source_idx}</source_id><source_context>{doc_context}</source_context></source>\n"
|
||||
|
||||
context_string = context_string.strip()
|
||||
prompt = get_last_user_message(form_data["messages"])
|
||||
|
@ -17,6 +17,21 @@
|
||||
return attrs;
|
||||
}
|
||||
|
||||
// Helper function to return only the domain from a URL
|
||||
function getDomain(url: string): string {
|
||||
const domain = url.replace('http://', '').replace('https://', '').split(/[/?#]/)[0];
|
||||
return domain;
|
||||
}
|
||||
|
||||
// Helper function to check if text is a URL and return the domain
|
||||
function formattedTitle(title: string): string {
|
||||
if (title.startsWith('http')) {
|
||||
return getDomain(title);
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
$: attributes = extractAttributes(token.text);
|
||||
</script>
|
||||
|
||||
@ -27,6 +42,6 @@
|
||||
}}
|
||||
>
|
||||
<span class="line-clamp-1">
|
||||
{attributes.title}
|
||||
{formattedTitle(attributes.title)}
|
||||
</span>
|
||||
</button>
|
||||
|
Loading…
Reference in New Issue
Block a user