Spaces:
Sleeping
Sleeping
Fix to new gradio
Browse files
app.py
CHANGED
|
@@ -157,10 +157,11 @@ with gr.Blocks() as demo:
|
|
| 157 |
|
| 158 |
with gr.Row():
|
| 159 |
with gr.Column(scale=2):
|
| 160 |
-
chatbox = gr.Chatbot()
|
| 161 |
user_input = gr.Textbox(placeholder="Type or speak...", show_label=False)
|
|
|
|
| 162 |
with gr.Row():
|
| 163 |
-
mic = gr.Audio(
|
| 164 |
send_btn = gr.Button("Send")
|
| 165 |
|
| 166 |
with gr.Accordion("Tools"):
|
|
@@ -179,9 +180,10 @@ with gr.Blocks() as demo:
|
|
| 179 |
log += "\nTranscribing..."
|
| 180 |
tr = transcribe_audio_tool(mic_file)
|
| 181 |
text = tr.content
|
|
|
|
| 182 |
history = history or []
|
| 183 |
-
history.append(
|
| 184 |
-
history
|
| 185 |
return history, log
|
| 186 |
|
| 187 |
send_btn.click(on_send_text, [user_input, chatbox, mic], [chatbox, tools_log])
|
|
@@ -198,7 +200,7 @@ with gr.Blocks() as demo:
|
|
| 198 |
if not file_obj:
|
| 199 |
return "No file uploaded"
|
| 200 |
desc = describe_image_tool(file_obj.name)
|
| 201 |
-
return desc.content
|
| 202 |
|
| 203 |
img_btn.click(on_describe, [img_upload], [chatbox])
|
| 204 |
|
|
|
|
| 157 |
|
| 158 |
with gr.Row():
|
| 159 |
with gr.Column(scale=2):
|
| 160 |
+
chatbox = gr.Chatbot(type="messages")
|
| 161 |
user_input = gr.Textbox(placeholder="Type or speak...", show_label=False)
|
| 162 |
+
|
| 163 |
with gr.Row():
|
| 164 |
+
mic = gr.Audio(sources=["microphone"], type="filepath")
|
| 165 |
send_btn = gr.Button("Send")
|
| 166 |
|
| 167 |
with gr.Accordion("Tools"):
|
|
|
|
| 180 |
log += "\nTranscribing..."
|
| 181 |
tr = transcribe_audio_tool(mic_file)
|
| 182 |
text = tr.content
|
| 183 |
+
|
| 184 |
history = history or []
|
| 185 |
+
history.append({"role": "user", "content": text})
|
| 186 |
+
history.append({"role": "assistant", "content": "You said: " + text})
|
| 187 |
return history, log
|
| 188 |
|
| 189 |
send_btn.click(on_send_text, [user_input, chatbox, mic], [chatbox, tools_log])
|
|
|
|
| 200 |
if not file_obj:
|
| 201 |
return "No file uploaded"
|
| 202 |
desc = describe_image_tool(file_obj.name)
|
| 203 |
+
return {"role": "assistant", "content": desc.content}
|
| 204 |
|
| 205 |
img_btn.click(on_describe, [img_upload], [chatbox])
|
| 206 |
|