Spaces:
Build error
Build error
Update app.py
Browse files35 unmodified lines36373839404142434445464748495051525335 unmodified linesprint("Bot Response:", bot_response) # Debug: Print the bot's response# Update the history in the correct format for Gradiohistory.append((message, bot_response)) # Use tuples for Gradio's Chatbot componentprint("Updated History:", history) # Debug: Print the updated historyreturn history# Define the Gradio interfacewith gr.Blocks() as demo:chatbot = gr.Chatbot() # No need for type="messages" heremsg = gr.Textbox(placeholder="Ask something...", show_label=False)state = gr.State([]) # Used to store conversation historymsg.submit(chatbot_response, inputs=[msg, state], outputs=[chatbot])# Launch the Gradio appdemo.launch(debug=True)35 unmodified lines3637383940414243444546474849505152535455565735 unmodified linesprint("Bot Response:", bot_response) # Debug: Print the bot's response# Update the history in the correct format for Gradiohistory.append({"role": "user", "content": message}) # Add user messagehistory.append({"role": "assistant", "content": bot_response}) # Add bot responseprint("Updated History:", history) # Debug: Print the updated historyreturn history, "" # Return updated history and clear the input box# Define the Gradio interfacewith gr.Blocks() as demo:chatbot = gr.Chatbot(type="messages") # Use "messages" type for chatbotmsg = gr.Textbox(placeholder="Ask something...", show_label=False)submit_button = gr.Button("Submit") # Add a submit buttonstate = gr.State([]) # Used to store conversation history# Submit on Enter key or button clickmsg.submit(chatbot_response, inputs=[msg, state], outputs=[chatbot, msg])submit_button.click(chatbot_response, inputs=[msg, state], outputs=[chatbot, msg])# Launch the Gradio appdemo.launch(debug=True)
app.py+8-4