Atualizar web/chat.js
This commit is contained in:
+46
@@ -78,6 +78,52 @@ async function loadHistory() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async function searchMessages() {
|
||||
const q = prompt("Search:");
|
||||
const r = await fetch(`/api/search?q=${encodeURIComponent(q)}`);
|
||||
const results = await r.json();
|
||||
console.log(results);
|
||||
}
|
||||
|
||||
async function addTags() {
|
||||
const tags = prompt("Tags (comma separated):");
|
||||
await fetch(`/api/tags/${conversationId}`, {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({tags: tags.split(",")})
|
||||
});
|
||||
}
|
||||
|
||||
async function shareConversation() {
|
||||
const email = prompt("Share with email:");
|
||||
await fetch(`/api/share/${conversationId}`, {
|
||||
method: "POST",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({email})
|
||||
});
|
||||
}
|
||||
|
||||
function exportMD() {
|
||||
window.open(`/api/export/md/${conversationId}`, "_blank");
|
||||
}
|
||||
|
||||
function exportPDF() {
|
||||
window.open(`/api/export/pdf/${conversationId}`, "_blank");
|
||||
}
|
||||
|
||||
async function importFile() {
|
||||
const file = document.getElementById("importFile").files[0];
|
||||
const form = new FormData();
|
||||
form.append("file", file);
|
||||
await fetch(`/api/import/${conversationId}`, {
|
||||
method: "POST",
|
||||
body: form
|
||||
});
|
||||
await loadHistory();
|
||||
}
|
||||
|
||||
|
||||
async function sendMessage() {
|
||||
const promptText = document.getElementById("prompt").value;
|
||||
const file = document.getElementById("attachment").files[0];
|
||||
|
||||
Reference in New Issue
Block a user