Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -73,15 +73,15 @@ def generate_image(prompt, output_filename="generated_image"):
|
|
73 |
# Function to handle chat interaction
|
74 |
def chat_handler(user_input, chat_history):
|
75 |
# Add user message to chat history
|
76 |
-
chat_history.append(
|
77 |
|
78 |
# Generate image based on user input
|
79 |
img, status = generate_image(user_input)
|
80 |
|
81 |
# Add AI response to chat history
|
82 |
if img:
|
83 |
-
chat_history.append(
|
84 |
-
chat_history.append(
|
85 |
|
86 |
return chat_history, ""
|
87 |
|
@@ -94,7 +94,7 @@ with gr.Blocks(title="Image Editing Chatbot") as demo:
|
|
94 |
chatbot = gr.Chatbot(
|
95 |
label="Chat",
|
96 |
height=400,
|
97 |
-
|
98 |
avatar_images=(None, None) # No avatars for simplicity
|
99 |
)
|
100 |
|
@@ -116,8 +116,7 @@ with gr.Blocks(title="Image Editing Chatbot") as demo:
|
|
116 |
run_btn.click(
|
117 |
fn=chat_handler,
|
118 |
inputs=[prompt_input, chat_state],
|
119 |
-
outputs=[chatbot, prompt_input]
|
120 |
-
_js="() => {return [document.querySelector('input').value, null]}"
|
121 |
)
|
122 |
|
123 |
# Also allow Enter key to submit
|
|
|
73 |
# Function to handle chat interaction
|
74 |
def chat_handler(user_input, chat_history):
|
75 |
# Add user message to chat history
|
76 |
+
chat_history.append({"role": "user", "content": user_input})
|
77 |
|
78 |
# Generate image based on user input
|
79 |
img, status = generate_image(user_input)
|
80 |
|
81 |
# Add AI response to chat history
|
82 |
if img:
|
83 |
+
chat_history.append({"role": "assistant", "content": img})
|
84 |
+
chat_history.append({"role": "assistant", "content": status})
|
85 |
|
86 |
return chat_history, ""
|
87 |
|
|
|
94 |
chatbot = gr.Chatbot(
|
95 |
label="Chat",
|
96 |
height=400,
|
97 |
+
type="messages", # Explicitly set to 'messages' format
|
98 |
avatar_images=(None, None) # No avatars for simplicity
|
99 |
)
|
100 |
|
|
|
116 |
run_btn.click(
|
117 |
fn=chat_handler,
|
118 |
inputs=[prompt_input, chat_state],
|
119 |
+
outputs=[chatbot, prompt_input]
|
|
|
120 |
)
|
121 |
|
122 |
# Also allow Enter key to submit
|