Update app.py
Browse files
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 |
-
#
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 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()
|