Atualizar web/chat.js
This commit is contained in:
+31
@@ -13,6 +13,37 @@ function toggleTheme() {
|
||||
document.body.classList.toggle("dark");
|
||||
}
|
||||
|
||||
async function sendAsync() {
|
||||
const r = await fetch("/api/queue/generate", {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({
|
||||
conversation_id: conversationId,
|
||||
model: "llama3.2",
|
||||
prompt: document.getElementById("prompt").value
|
||||
})
|
||||
});
|
||||
|
||||
const { task_id } = await r.json();
|
||||
pollTask(task_id);
|
||||
}
|
||||
|
||||
async function pollTask(taskId) {
|
||||
const interval = setInterval(async () => {
|
||||
const r = await fetch(`/api/queue/status/${taskId}`);
|
||||
const data = await r.json();
|
||||
|
||||
if (data.state === "SUCCESS") {
|
||||
clearInterval(interval);
|
||||
await loadHistory();
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async function loadConversations() {
|
||||
const r = await fetch("/api/conversations");
|
||||
conversations = await r.json();
|
||||
|
||||
Reference in New Issue
Block a user