refac: start source citation from 1

This commit is contained in:
Timothy Jaeryang Baek 2025-03-26 20:39:39 -07:00
parent dd2d757270
commit 42636347e2
2 changed files with 2 additions and 2 deletions

View File

@ -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"])

View File

@ -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}" />`);
});
}