Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
983fe4b2
Commit
983fe4b2
authored
Jul 05, 2024
by
Timothy J. Baek
Browse files
refac
parent
55b7c300
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
25 deletions
+15
-25
src/lib/components/chat/Chat.svelte
src/lib/components/chat/Chat.svelte
+15
-25
No files found.
src/lib/components/chat/Chat.svelte
View file @
983fe4b2
...
...
@@ -126,39 +126,29 @@
})();
}
const chatEventHandler = async (
data
) => {
if (
data
.chat_id === $chatId) {
const chatEventHandler = async (
event
) => {
if (
event
.chat_id === $chatId) {
await tick();
console.log(data);
let message = history.messages[data.message_id];
const type = data?.data?.type ?? null;
const payload = data?.data?.data ?? null;
if (!type || !payload) {
console.log("Data and type fields must be provided.", data);
return;
}
const status_keys = ["done", "description"];
const citation_keys = ["document", "url", "title"];
if (type === "status" && status_keys.every(key => key in payload)) {
console.log(event);
let message = history.messages[event.message_id];
const type = event?.data?.type ?? null;
const data = event?.data?.data ?? null;
if (type === 'status') {
if (message.statusHistory) {
message.statusHistory.push(
payload
);
message.statusHistory.push(
data
);
} else {
message.statusHistory = [
payload
];
message.statusHistory = [
data
];
}
} else if (type === "citation" && citation_keys.every(key => key in payload)) {
const citation = {
document: [payload.document],
metadata: [{source: payload.url}],
source: {name: payload.title}
};
} else if (type === 'citation') {
if (message.citations) {
message.citations.push(
citation
);
message.citations.push(
data
);
} else {
message.citations = [
citation
];
message.citations = [
data
];
}
} else {
console.log(
"
Unknown message type
"
, data);
console.log(
'
Unknown message type
'
, data);
}
messages = messages;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment