Update app.py
Browse files
app.py
CHANGED
|
@@ -228,17 +228,34 @@ def response(sentence, userID='123', show_details=False):
|
|
| 228 |
# In[31]:
|
| 229 |
|
| 230 |
|
| 231 |
-
import gradio as gr
|
| 232 |
|
| 233 |
-
def chat_response(message):
|
| 234 |
-
return response(message) # Return the response from the chatbot
|
| 235 |
|
| 236 |
-
|
| 237 |
|
| 238 |
|
| 239 |
-
# In[ ]:
|
| 240 |
|
| 241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
|
| 244 |
|
|
|
|
| 228 |
# In[31]:
|
| 229 |
|
| 230 |
|
|
|
|
| 231 |
|
|
|
|
|
|
|
| 232 |
|
| 233 |
+
# In[ ]:
|
| 234 |
|
| 235 |
|
|
|
|
| 236 |
|
| 237 |
|
| 238 |
+
def chatbot_response(message, chat_history=[]):
|
| 239 |
+
# This is a simple echo function, replace it with your chatbot model.
|
| 240 |
+
response_text = f"Chatbot: {response(message)}"
|
| 241 |
+
chat_history.append((input_text, response_text))
|
| 242 |
+
return response_text, chat_history
|
| 243 |
+
|
| 244 |
+
# Define the Gradio interface
|
| 245 |
+
interface = gr.Interface(
|
| 246 |
+
fn=chatbot_response, # Function to handle chatbot responses
|
| 247 |
+
inputs=[
|
| 248 |
+
gr.Textbox(lines=1, label="You"), # Input box for user input
|
| 249 |
+
gr.Chatbot(label="Chat History") # Chat history to display inputs and responses
|
| 250 |
+
],
|
| 251 |
+
outputs=[
|
| 252 |
+
gr.Chatbot(label="Chat History") # Chat history as output to display the conversation
|
| 253 |
+
],
|
| 254 |
+
title="Chatbot with History",
|
| 255 |
+
)
|
| 256 |
+
|
| 257 |
+
# Launch the Gradio interface
|
| 258 |
+
interface.launch()
|
| 259 |
|
| 260 |
|
| 261 |
|