-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
93 lines (78 loc) · 2.32 KB
/
main.py
File metadata and controls
93 lines (78 loc) · 2.32 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import gradio as gr
from langchain_core.messages import HumanMessage, AIMessage
from src.graphModel import agent
def run_chat(message, history):
new_message = HumanMessage(content=message)
response = agent.invoke(
{"messages": [new_message]},
config={"configurable": {"thread_id": "1"}}
)
final_message = response["messages"][-1]
if isinstance(final_message, AIMessage) and final_message.content:
return final_message.content
else:
return "An unexpected response format, but the agent ran."
RESTAURANT_CSS = """
/* The main container background */
.gradio-container {
background-color: #f1f8ff !important; /* Light pastel blue */
}
/* Style the title */
.gradio-container h1 {
color: #6fa3ef;
font-family: 'Georgia', serif;
text-shadow: 1px 1px 2px #ffffff;
}
/* Style the Chatbot box itself */
#restaurant_chatbot {
border: 3px solid #ffefb3; /* Pastel yellow border */
border-radius: 10px;
background-color: #ffffff; /* White background */
}
/* Assistant's Chat Bubble */
#restaurant_chatbot .message.bot {
background-color: #ffefb3 !important;
color: #333333 !important;
border-radius: 15px 15px 15px 0px !important;
}
/* Customer's Chat Bubble */
#restaurant_chatbot .message.user {
background-color: #a0c4ff !important;
color: #ffffff !important;
border-radius: 15px 15px 0px 15px !important;
}
/* Style the submit button */
.gradio-container button.submit-button {
background-color: #a0c4ff !important;
color: white !important;
border-radius: 8px !important;
font-weight: bold;
border: none !important;
}
/* Style the input text box */
.gradio-container textarea {
border: 2px solid #ffefb3 !important;
font-family: 'Verdana', sans-serif;
border-radius: 8px !important;
margin:13px;
}
"""
demo = gr.ChatInterface(
fn=run_chat,
title="Chez The Daily Dish 🍽️",
theme=gr.themes.Monochrome(),
css=RESTAURANT_CSS,
chatbot=gr.Chatbot(
height=400,
show_copy_button=True,
elem_id="restaurant_chatbot",
placeholder="How may I help you?"
),
examples=[
"Do you have any Special offers? 🍜",
"What are the Opening Hours? 🚪",
],
submit_btn=" Send 🛎️",
)
if __name__ == "__main__":
demo.launch()