Hieucyber2208 commited on
Commit
6706fac
·
verified ·
1 Parent(s): e84a8c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -34
app.py CHANGED
@@ -1,46 +1,31 @@
1
  import gradio as gr
2
  from src.chatbot import RestaurantChatbot
3
 
4
- chatbot = RestaurantChatbot()
 
5
 
6
- def respond(user_message, history):
7
  response, retrieved_docs = chatbot.answer(user_message)
8
 
9
- bot_response = f"{response}\n\n**Nhà hàng gợi ý:**\n"
10
  if retrieved_docs:
11
- doc = retrieved_docs[0]
12
- bot_response += (
13
- f"- **{doc['name']} ({doc['cuisine']})**\n"
14
- f" - Món ăn: {', '.join(doc['dishes'])}\n"
15
- f" - Giá: {doc['price_range']}\n"
16
- f" - Khoảng cách: {doc['distance']} km\n"
17
- f" - Đánh giá: {doc['rating']}\n"
18
- f" - Địa chỉ: {doc['address']}\n"
19
- f" - Mô tả: {doc['description']}\n"
20
- )
21
  else:
22
  bot_response += "- Không tìm thấy nhà hàng phù hợp."
23
 
24
- return bot_response
25
 
26
- with gr.Blocks(css="""
27
- html, body, #root, .gradio-container {
28
- height: 100% !important;
29
- margin: 0 !important;
30
- padding: 0 !important;
31
- }
32
- .chat-wrapper {
33
- height: 100%;
34
- display: flex;
35
- flex-direction: column;
36
- }
37
- .chat-interface {
38
- flex: 1;
39
- display: flex;
40
- flex-direction: column;
41
- }
42
- """) as demo:
43
- with gr.Column(elem_classes=["chat-wrapper"]):
44
- gr.ChatInterface(fn=respond, chatbot=gr.Chatbot(), elem_classes=["chat-interface"])
45
 
46
- demo.launch()
 
1
  import gradio as gr
2
  from src.chatbot import RestaurantChatbot
3
 
4
+ chatbot = RestaurantChatbot()
5
+ chat_history = []
6
 
7
+ def respond(user_message, history):
8
  response, retrieved_docs = chatbot.answer(user_message)
9
 
10
+ bot_response = f"{response}\n\n**Nhà hàng gợi ý:**\n"
11
  if retrieved_docs:
12
+ for doc in retrieved_docs:
13
+ bot_response += (
14
+ f"- **{doc['name']} ({doc['cuisine']})**\n"
15
+ f" - Món ăn: {', '.join(doc['dishes'])}\n"
16
+ f" - Giá: {doc['price_range']}\n"
17
+ f" - Khoảng cách: {doc['distance']} km\n"
18
+ f" - Đánh giá: {doc['rating']}\n"
19
+ f" - Địa chỉ: {doc['address']}\n"
20
+ f" - Mô tả: {doc['description']}\n"
21
+ )
22
  else:
23
  bot_response += "- Không tìm thấy nhà hàng phù hợp."
24
 
25
+ return bot_response
26
 
27
+ with gr.Blocks() as demo:
28
+ gr.Markdown("## Chatbot Gợi ý Quán ăn")
29
+ chatbot_ui = gr.ChatInterface(fn=respond, chatbot=gr.Chatbot())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
+ demo.launch()