-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
33 lines (30 loc) · 1.05 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// script.js
function sendMessage() {
const userInput = document.getElementById('user-input').value;
fetch('http://your-backend-url/predict', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ Symptoms: userInput }),
})
.then(response => response.json())
.then(data => {
// Handle the response from the backend
displayBotMessage(data.Disease, data.Treatment, data.Procedure, data.Precautions);
})
.catch((error) => {
console.error('Error:', error);
});
}
function displayBotMessage(disease, treatment, procedure, precautions) {
const chatBox = document.getElementById('chat-box');
chatBox.innerHTML += `
<div class="bot-message">
<p>Based on your symptoms, you might have: ${disease}</p>
<p>Recommended Ayurvedic Treatment: ${treatment}</p>
<p>Procedure: ${procedure}</p>
<p>Precautions: ${precautions}</p>
</div>
`;
}