Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -88,53 +88,142 @@ def predict(message,history):
|
|
88 |
response = handle_query(message)
|
89 |
return response
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
css = '''
|
94 |
/* Style the chat container */
|
95 |
.gradio-container {
|
96 |
display: flex;
|
97 |
flex-direction: column;
|
98 |
-
width:
|
99 |
margin: 0 auto;
|
100 |
padding: 20px;
|
101 |
border: 1px solid #ddd;
|
102 |
-
border-radius:
|
103 |
-
background-color: #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
105 |
|
106 |
-
/* Style the title */
|
107 |
.gradio-title {
|
108 |
-
text-align: center;
|
109 |
font-weight: bold;
|
110 |
-
|
|
|
111 |
}
|
112 |
|
113 |
/* Style the chat history */
|
114 |
.gradio-chat-history {
|
115 |
flex: 1;
|
116 |
-
overflow-y:
|
117 |
-
padding:
|
118 |
-
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
-
/* Style the chat
|
122 |
.gradio-message {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
margin-bottom: 5px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
|
126 |
/* Style the user input field */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
.gradio-chat-input input {
|
128 |
width: 100%;
|
129 |
padding: 10px;
|
130 |
-
border:
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
font-size: 16px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
-
# Launch the chat interface with custom layout
|
138 |
-
interface = gr.ChatInterface(predict, title="RedFerns Tech", layout=custom_layout)
|
139 |
-
interface.launch()
|
140 |
|
|
|
88 |
response = handle_query(message)
|
89 |
return response
|
90 |
|
91 |
+
# Create the chat interface with a custom layout function
|
92 |
+
css = '''
|
|
|
93 |
/* Style the chat container */
|
94 |
.gradio-container {
|
95 |
display: flex;
|
96 |
flex-direction: column;
|
97 |
+
width: 450px;
|
98 |
margin: 0 auto;
|
99 |
padding: 20px;
|
100 |
border: 1px solid #ddd;
|
101 |
+
border-radius: 10px;
|
102 |
+
background-color: #fff;
|
103 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
104 |
+
position: relative;
|
105 |
+
}
|
106 |
+
|
107 |
+
/* Style the logo and title container */
|
108 |
+
.gradio-header {
|
109 |
+
display: flex;
|
110 |
+
align-items: center;
|
111 |
+
margin-bottom: 20px;
|
112 |
+
padding-bottom: 10px;
|
113 |
+
border-bottom: 1px solid #ddd;
|
114 |
+
}
|
115 |
+
|
116 |
+
.gradio-logo img {
|
117 |
+
height: 50px;
|
118 |
+
margin-right: 10px;
|
119 |
}
|
120 |
|
|
|
121 |
.gradio-title {
|
|
|
122 |
font-weight: bold;
|
123 |
+
font-size: 24px;
|
124 |
+
color: #4A90E2;
|
125 |
}
|
126 |
|
127 |
/* Style the chat history */
|
128 |
.gradio-chat-history {
|
129 |
flex: 1;
|
130 |
+
overflow-y: auto;
|
131 |
+
padding: 15px;
|
132 |
+
background-color: #f9f9f9;
|
133 |
+
border-radius: 5px;
|
134 |
+
margin-bottom: 10px;
|
135 |
+
max-height: 500px; /* Increase the height of the chat history */
|
136 |
}
|
137 |
|
138 |
+
/* Style the chat messages */
|
139 |
.gradio-message {
|
140 |
+
margin-bottom: 15px;
|
141 |
+
display: flex;
|
142 |
+
flex-direction: column; /* Stack messages vertically */
|
143 |
+
}
|
144 |
+
|
145 |
+
.gradio-message.user .gradio-message-content {
|
146 |
+
background-color: #E1FFC7;
|
147 |
+
align-self: flex-end;
|
148 |
+
border: 1px solid #c3e6cb;
|
149 |
+
border-radius: 15px 15px 0 15px;
|
150 |
+
padding: 10px;
|
151 |
+
font-size: 16px;
|
152 |
margin-bottom: 5px;
|
153 |
+
max-width: 80%;
|
154 |
+
}
|
155 |
+
|
156 |
+
.gradio-message.bot .gradio-message-content {
|
157 |
+
background-color: #fff;
|
158 |
+
align-self: flex-start;
|
159 |
+
border: 1px solid #ced4da;
|
160 |
+
border-radius: 15px 15px 15px 0;
|
161 |
+
padding: 10px;
|
162 |
+
font-size: 16px;
|
163 |
+
margin-bottom: 5px;
|
164 |
+
max-width: 80%;
|
165 |
+
}
|
166 |
+
|
167 |
+
.gradio-message-content {
|
168 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
169 |
}
|
170 |
|
171 |
/* Style the user input field */
|
172 |
+
.gradio-chat-input {
|
173 |
+
display: flex;
|
174 |
+
border: 1px solid #ddd;
|
175 |
+
border-radius: 20px;
|
176 |
+
padding: 10px;
|
177 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
178 |
+
background-color: #fff;
|
179 |
+
}
|
180 |
+
|
181 |
.gradio-chat-input input {
|
182 |
width: 100%;
|
183 |
padding: 10px;
|
184 |
+
border: none;
|
185 |
+
outline: none;
|
186 |
+
font-size: 16px;
|
187 |
+
border-radius: 20px;
|
188 |
+
}
|
189 |
+
|
190 |
+
.gradio-chat-input button {
|
191 |
+
padding: 10px 15px;
|
192 |
+
background-color: #4A90E2;
|
193 |
+
border: none;
|
194 |
+
border-radius: 20px;
|
195 |
+
color: white;
|
196 |
font-size: 16px;
|
197 |
+
cursor: pointer;
|
198 |
+
margin-left: 10px;
|
199 |
+
}
|
200 |
+
|
201 |
+
.gradio-chat-input button:hover {
|
202 |
+
background-color: #357ABD;
|
203 |
+
}
|
204 |
+
|
205 |
+
/* Remove Gradio footer */
|
206 |
+
footer {
|
207 |
+
display: none !important;
|
208 |
}
|
209 |
+
'''
|
210 |
+
|
211 |
+
# Create a custom HTML block for the logo and title
|
212 |
+
header_html = '''
|
213 |
+
<div class="gradio-header">
|
214 |
+
<div class="gradio-logo">
|
215 |
+
<img src="https://redfernstech.com/wp-content/uploads/2024/05/RedfernsLogo_FinalV1.0-3-2048x575.png" alt="Company Logo">
|
216 |
+
</div>
|
217 |
+
<div class="gradio-title">RedFerns Tech</div>
|
218 |
+
</div>
|
219 |
+
'''
|
220 |
+
|
221 |
+
# Create a Blocks layout with the custom HTML and ChatInterface
|
222 |
+
with gr.Blocks(css=css) as demo:
|
223 |
+
gr.HTML(header_html)
|
224 |
+
gr.ChatInterface(predict)
|
225 |
+
|
226 |
+
# Launch the interface
|
227 |
+
demo.launch()
|
228 |
|
|
|
|
|
|
|
229 |
|