mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 20:35:19 +00:00
simplify citation API
This commit is contained in:
parent
0527755600
commit
55b7c30028
1 changed files with 8 additions and 3 deletions
|
|
@ -139,7 +139,7 @@
|
|||
return;
|
||||
}
|
||||
const status_keys = ["done", "description"];
|
||||
const citation_keys = ["document", "metadata", "source"];
|
||||
const citation_keys = ["document", "url", "title"];
|
||||
if (type === "status" && status_keys.every(key => key in payload)) {
|
||||
if (message.statusHistory) {
|
||||
message.statusHistory.push(payload);
|
||||
|
|
@ -147,10 +147,15 @@
|
|||
message.statusHistory = [payload];
|
||||
}
|
||||
} else if (type === "citation" && citation_keys.every(key => key in payload)) {
|
||||
const citation = {
|
||||
document: [payload.document],
|
||||
metadata: [{source: payload.url}],
|
||||
source: {name: payload.title}
|
||||
};
|
||||
if (message.citations) {
|
||||
message.citations.push(payload);
|
||||
message.citations.push(citation);
|
||||
} else {
|
||||
message.citations = [payload];
|
||||
message.citations = [citation];
|
||||
}
|
||||
} else {
|
||||
console.log("Unknown message type", data);
|
||||
|
|
|
|||
Loading…
Reference in a new issue