mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
add canSend flag
This commit is contained in:
@@ -23,6 +23,7 @@ const { data: chatsRemaining, refresh: reloadChatsRemaining } = useFetch(`/api/a
|
|||||||
|
|
||||||
const currentText = ref<string>("");
|
const currentText = ref<string>("");
|
||||||
const loading = ref<boolean>(false);
|
const loading = ref<boolean>(false);
|
||||||
|
const canSend = ref<boolean>(false);
|
||||||
|
|
||||||
const currentChatId = ref<string>("");
|
const currentChatId = ref<string>("");
|
||||||
const currentChatMessages = ref<{ role: string, content: string, charts?: any[], tool_calls?: any }[]>([]);
|
const currentChatMessages = ref<{ role: string, content: string, charts?: any[], tool_calls?: any }[]>([]);
|
||||||
@@ -108,6 +109,8 @@ async function sendMessage() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
canSend.value = false;
|
||||||
|
|
||||||
const res = await $fetch<{ chat_id: string }>(`/api/ai/send_message`, { method: 'POST', body: JSON.stringify(body), headers: useComputedHeaders({ useSnapshotDates: false, custom: { 'Content-Type': 'application/json' } }).value });
|
const res = await $fetch<{ chat_id: string }>(`/api/ai/send_message`, { method: 'POST', body: JSON.stringify(body), headers: useComputedHeaders({ useSnapshotDates: false, custom: { 'Content-Type': 'application/json' } }).value });
|
||||||
currentChatId.value = res.chat_id;
|
currentChatId.value = res.chat_id;
|
||||||
|
|
||||||
@@ -125,6 +128,8 @@ async function sendMessage() {
|
|||||||
currentChatMessageDelta.value = status;
|
currentChatMessageDelta.value = status;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
canSend.value = true;
|
||||||
|
|
||||||
} catch (ex: any) {
|
} catch (ex: any) {
|
||||||
|
|
||||||
if (ex.message.includes('CHAT_LIMIT_REACHED')) {
|
if (ex.message.includes('CHAT_LIMIT_REACHED')) {
|
||||||
@@ -141,6 +146,10 @@ async function sendMessage() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentChatMessages.value.push({ role: 'assistant', content: ex.message, });
|
||||||
|
|
||||||
|
canSend.value = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -154,6 +163,7 @@ async function openChat(chat_id?: string) {
|
|||||||
|
|
||||||
typer.stop();
|
typer.stop();
|
||||||
|
|
||||||
|
canSend.value = true;
|
||||||
currentChatMessages.value = [];
|
currentChatMessages.value = [];
|
||||||
currentChatMessageDelta.value = '';
|
currentChatMessageDelta.value = '';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user