-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.html
More file actions
44 lines (38 loc) · 1.58 KB
/
Copy pathchat.html
File metadata and controls
44 lines (38 loc) · 1.58 KB
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
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<html>
<head>
<title>Odoo Doc Chat</title>
<style>
#chat { height: 400px; border: 1px solid #ccc; padding: 10px; overflow-y: scroll; margin-bottom: 10px; }
#question { width: 80%; padding: 8px; }
#send { padding: 8px 16px; }
</style>
</head>
<body>
<div id="chat"></div>
<input type="text" id="question" placeholder="Ask a question about the documentation...">
<button id="send">Send</button>
<script>
document.getElementById('send').addEventListener('click', async () => {
const question = document.getElementById('question').value;
if (!question) return;
// Display user question
document.getElementById('chat').innerHTML += `<div><strong>You:</strong> ${question}</div>`;
try {
// Call your Genkit flow
const response = await fetch('http://localhost:4000/api/flow/ragHTMLDoc', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ input: question })
});
const data = await response.json();
// Display AI answer
document.getElementById('chat').innerHTML += `<div><strong>AI:</strong> ${data.output}</div>`;
} catch (error) {
document.getElementById('chat').innerHTML += `<div><strong>Error:</strong> ${error.message}</div>`;
}
document.getElementById('question').value = '';
});
</script>
</body>
</html>