File size: 769 Bytes
543aa2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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);
    }
}