refac: citations -> sources

This commit is contained in:
Timothy Jaeryang Baek
2024-11-21 19:46:09 -08:00
parent 7062e637e8
commit 81386e9b04
9 changed files with 165 additions and 126 deletions
+11 -11
View File
@@ -236,10 +236,10 @@
message.code_executions = message.code_executions;
} else {
// Regular citation.
if (message?.citations) {
message.citations.push(data);
if (message?.sources) {
message.sources.push(data);
} else {
message.citations = [data];
message.sources = [data];
}
}
} else if (type === 'message') {
@@ -664,7 +664,7 @@
content: m.content,
info: m.info ? m.info : undefined,
timestamp: m.timestamp,
...(m.citations ? { citations: m.citations } : {})
...(m.sources ? { sources: m.sources } : {})
})),
chat_id: chatId,
session_id: $socket?.id,
@@ -718,7 +718,7 @@
content: m.content,
info: m.info ? m.info : undefined,
timestamp: m.timestamp,
...(m.citations ? { citations: m.citations } : {})
...(m.sources ? { sources: m.sources } : {})
})),
...(event ? { event: event } : {}),
chat_id: chatId,
@@ -1278,8 +1278,8 @@
console.log(line);
let data = JSON.parse(line);
if ('citations' in data) {
responseMessage.citations = data.citations;
if ('sources' in data) {
responseMessage.sources = data.sources;
// Only remove status if it was initially set
if (model?.info?.meta?.knowledge ?? false) {
responseMessage.statusHistory = responseMessage.statusHistory.filter(
@@ -1632,7 +1632,7 @@
const textStream = await createOpenAITextStream(res.body, $settings.splitLargeChunks);
for await (const update of textStream) {
const { value, done, citations, selectedModelId, error, usage } = update;
const { value, done, sources, selectedModelId, error, usage } = update;
if (error) {
await handleOpenAIError(error, null, model, responseMessage);
break;
@@ -1658,8 +1658,8 @@
continue;
}
if (citations) {
responseMessage.citations = citations;
if (sources) {
responseMessage.sources = sources;
// Only remove status if it was initially set
if (model?.info?.meta?.knowledge ?? false) {
responseMessage.statusHistory = responseMessage.statusHistory.filter(
@@ -1938,7 +1938,7 @@
if (res && res.ok && res.body) {
const textStream = await createOpenAITextStream(res.body, $settings.splitLargeChunks);
for await (const update of textStream) {
const { value, done, citations, error, usage } = update;
const { value, done, sources, error, usage } = update;
if (error || done) {
break;
}