Merge pull request #3615 from michaelpoluektov/citations-event

feat: Citations event via __event_emitter__
This commit is contained in:
Timothy Jaeryang Baek 2024-07-05 21:20:40 -07:00 committed by GitHub
commit 3928ac1905
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -126,21 +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];
console.log(event);
let message = history.messages[event.message_id];
const status = {
done: data?.data?.done ?? null,
description: data?.data?.status ?? null
};
const type = event?.data?.type ?? null;
const data = event?.data?.data ?? null;
if (message.statusHistory) {
message.statusHistory.push(status);
if (type === 'status') {
if (message.statusHistory) {
message.statusHistory.push(data);
} else {
message.statusHistory = [data];
}
} else if (type === 'citation') {
if (message.citations) {
message.citations.push(data);
} else {
message.citations = [data];
}
} else {
message.statusHistory = [status];
console.log('Unknown message type', data);
}
messages = messages;