Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -347,7 +347,7 @@ def build_interface():
|
|
| 347 |
logging.info("Interface build complete.")
|
| 348 |
return demo
|
| 349 |
|
| 350 |
-
def
|
| 351 |
"""
|
| 352 |
Handles chatbot interaction. Can be used both in Gradio and from MAIN.
|
| 353 |
"""
|
|
@@ -375,6 +375,16 @@ def chatbot_interface(message, history=None):
|
|
| 375 |
logging.info(f"Returning updated history with {len(formatted_responses)} response(s).")
|
| 376 |
return history, "", history
|
| 377 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
# MAIN
|
| 379 |
if __name__ == "__main__":
|
| 380 |
logging.info("Loading environment...")
|
|
@@ -409,7 +419,14 @@ if __name__ == "__main__":
|
|
| 409 |
|
| 410 |
logging.info(f"Total agents created: {len(respondent_agents_dict)}")
|
| 411 |
|
| 412 |
-
demo = build_interface()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
|
|
|
|
| 414 |
logging.info("Launching Gradio interface...")
|
| 415 |
demo.launch(debug=True)
|
|
|
|
| 347 |
logging.info("Interface build complete.")
|
| 348 |
return demo
|
| 349 |
|
| 350 |
+
def chatbot_interface_XXX(message, history=None):
|
| 351 |
"""
|
| 352 |
Handles chatbot interaction. Can be used both in Gradio and from MAIN.
|
| 353 |
"""
|
|
|
|
| 375 |
logging.info(f"Returning updated history with {len(formatted_responses)} response(s).")
|
| 376 |
return history, "", history
|
| 377 |
|
| 378 |
+
def chatbot_interface(message, history=None):
|
| 379 |
+
if history is None:
|
| 380 |
+
history = []
|
| 381 |
+
|
| 382 |
+
response = f"Echo: {message}"
|
| 383 |
+
history.append({"role": "user", "content": message})
|
| 384 |
+
history.append({"role": "assistant", "content": response})
|
| 385 |
+
|
| 386 |
+
return history, "", history
|
| 387 |
+
|
| 388 |
# MAIN
|
| 389 |
if __name__ == "__main__":
|
| 390 |
logging.info("Loading environment...")
|
|
|
|
| 419 |
|
| 420 |
logging.info(f"Total agents created: {len(respondent_agents_dict)}")
|
| 421 |
|
| 422 |
+
# demo = build_interface()
|
| 423 |
+
with gr.Blocks() as demo:
|
| 424 |
+
chatbot = gr.Chatbot(label="Demo Chat")
|
| 425 |
+
msg = gr.Textbox()
|
| 426 |
+
history = gr.State([])
|
| 427 |
+
|
| 428 |
+
msg.submit(chatbot_interface, [msg, history], [chatbot, msg, history])
|
| 429 |
|
| 430 |
+
|
| 431 |
logging.info("Launching Gradio interface...")
|
| 432 |
demo.launch(debug=True)
|