Kaiyeee commited on
Commit
aae8619
Β·
verified Β·
1 Parent(s): b0f8591

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -46,16 +46,18 @@ def chat_with_cardi(user_input, chat_history):
46
  with gr.Blocks() as demo:
47
  gr.Markdown("# 🎀 Cardi B GPT πŸ’…\nAsk Cardi anything and get her spicy takes!")
48
 
49
- # Chat Interface
50
- chat_interface = gr.ChatInterface(
51
- fn=chat_with_cardi,
52
- title="Cardi B GPT",
53
- chatbot=gr.Chatbot(),
54
- input_textbox="Ask me anything, babe! πŸ’…",
55
- retry_btn="Try Again",
56
- undo_btn="Undo",
57
- clear_btn="Clear Chat"
58
- )
 
 
59
 
60
  # Launch the Gradio app
61
  demo.launch()
 
46
  with gr.Blocks() as demo:
47
  gr.Markdown("# 🎀 Cardi B GPT πŸ’…\nAsk Cardi anything and get her spicy takes!")
48
 
49
+ chatbot = gr.Chatbot(label="Cardi B AI πŸ’…", type="messages") # FIXED: Added `type="messages"`
50
+
51
+ textbox = gr.Textbox(label="Ask Cardi B something πŸ’„") # FIXED: Removed `input_textbox`
52
+ submit_btn = gr.Button("Send it, babe! πŸ’…")
53
+
54
+ def process_chat(user_input, history):
55
+ response = chat_with_cardi(user_input, history)
56
+ history.append({"role": "user", "content": user_input}) # OpenAI-style format
57
+ history.append({"role": "assistant", "content": response})
58
+ return history, ""
59
+
60
+ submit_btn.click(process_chat, inputs=[textbox, chatbot], outputs=[chatbot, textbox])
61
 
62
  # Launch the Gradio app
63
  demo.launch()