mirror of
https://github.com/open-webui/open-webui
synced 2025-04-04 04:51:27 +00:00
refac: start source citation from 1
This commit is contained in:
parent
dd2d757270
commit
42636347e2
@ -847,7 +847,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
for source_idx, source in enumerate(sources):
|
||||
if "document" in source:
|
||||
for doc_idx, doc_context in enumerate(source["document"]):
|
||||
context_string += f"<source><source_id>{source_idx}</source_id><source_context>{doc_context}</source_context></source>\n"
|
||||
context_string += f"<source><source_id>{source_idx + 1}</source_id><source_context>{doc_context}</source_context></source>\n"
|
||||
|
||||
context_string = context_string.strip()
|
||||
prompt = get_last_user_message(form_data["messages"])
|
||||
|
@ -64,7 +64,7 @@ export const replaceTokens = (content, sourceIds, char, user) => {
|
||||
if (Array.isArray(sourceIds)) {
|
||||
sourceIds.forEach((sourceId, idx) => {
|
||||
const regex = new RegExp(`\\[${idx}\\]`, 'g');
|
||||
segment = segment.replace(regex, `<source_id data="${idx}" title="${sourceId}" />`);
|
||||
segment = segment.replace(regex, `<source_id data="${idx + 1}" title="${sourceId}" />`);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user