| async function sendMessage() { | |
| const userId = document.getElementById("userId").value; | |
| const message = document.getElementById("message").value; | |
| const output = document.getElementById("output"); | |
| output.textContent = "جارٍ المعالجة... ⏳"; | |
| try { | |
| const response = await fetch("http://localhost:7860/run/predict", { | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify({ | |
| data: [userId, message] | |
| }) | |
| }); | |
| const result = await response.json(); | |
| output.textContent = result.data[0]; | |
| } catch (err) { | |
| output.textContent = "حدث خطأ، حاول مرة أخرى."; | |
| console.error(err); | |
| } | |
| } | |