tudeplom commited on
Commit
8317765
·
verified ·
1 Parent(s): 14d5dc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -1
app.py CHANGED
@@ -28,7 +28,34 @@ TTS_MODEL = "facebook/mms-tts-eng"
28
  CHAT_MODEL = "mistralai/Mistral-7B-Instruct"
29
 
30
  # Giao diện HTML
31
- HTML_CONTENT = """<html><body><h1>Chatbot AI</h1><p>Gửi yêu cầu đến API</p></body></html>"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  @app.get("/", response_class=HTMLResponse)
34
  async def root():
 
28
  CHAT_MODEL = "mistralai/Mistral-7B-Instruct"
29
 
30
  # Giao diện HTML
31
+ HTML_CONTENT = """
32
+ <html>
33
+ <head>
34
+ <title>Chatbot AI</title>
35
+ <script>
36
+ async function sendMessage() {
37
+ let prompt = document.getElementById("prompt").value;
38
+ let responseBox = document.getElementById("response");
39
+ responseBox.innerText = "Đang xử lý...";
40
+
41
+ let response = await fetch("/chatbot", {
42
+ method: "POST",
43
+ headers: { "Content-Type": "application/json" },
44
+ body: JSON.stringify({ prompt: prompt })
45
+ });
46
+ let data = await response.json();
47
+ responseBox.innerText = data.text;
48
+ }
49
+ </script>
50
+ </head>
51
+ <body>
52
+ <h1>Chatbot AI</h1>
53
+ <input type="text" id="prompt" placeholder="Nhập nội dung..." />
54
+ <button onclick="sendMessage()">Gửi</button>
55
+ <p id="response"></p>
56
+ </body>
57
+ </html>
58
+ """
59
 
60
  @app.get("/", response_class=HTMLResponse)
61
  async def root():