Spaces:
Build error
Build error
Commit
·
13e28fe
1
Parent(s):
6b2acdf
hjjhhjj
Browse files- app_gradio_spaces.py +24 -8
app_gradio_spaces.py
CHANGED
@@ -162,20 +162,36 @@ def create_chat_ui(setup_status="Not started", services_status="Not started"):
|
|
162 |
|
163 |
def on_audio_submit(audio, chat_history):
|
164 |
if not audio:
|
165 |
-
|
|
|
166 |
|
167 |
-
|
168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
-
|
171 |
-
|
|
|
172 |
|
173 |
def on_text_submit(text, chat_history):
|
174 |
if not text:
|
175 |
-
|
|
|
176 |
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
# Connect events
|
181 |
setup_btn.click(on_setup_click, outputs=[setup_output, services_btn])
|
|
|
162 |
|
163 |
def on_audio_submit(audio, chat_history):
|
164 |
if not audio:
|
165 |
+
# Ensure chat_history is returned even if no audio
|
166 |
+
return chat_history if chat_history is not None else [], None
|
167 |
|
168 |
+
# Placeholder for actual transcription logic
|
169 |
+
transcribed_text = "Audio input (transcription pending)"
|
170 |
+
|
171 |
+
# Create new messages in the "messages" format
|
172 |
+
new_messages = [
|
173 |
+
{"role": "user", "content": transcribed_text},
|
174 |
+
{"role": "assistant", "content": "This is a placeholder response. The full model will be running after starting the services."}
|
175 |
+
]
|
176 |
|
177 |
+
# Append new messages to existing history (or initialize if history is None)
|
178 |
+
updated_history = (chat_history if chat_history is not None else []) + new_messages
|
179 |
+
return updated_history, None
|
180 |
|
181 |
def on_text_submit(text, chat_history):
|
182 |
if not text:
|
183 |
+
# Ensure chat_history is returned even if no text
|
184 |
+
return chat_history if chat_history is not None else [], None
|
185 |
|
186 |
+
# Create new messages in the "messages" format
|
187 |
+
new_messages = [
|
188 |
+
{"role": "user", "content": text},
|
189 |
+
{"role": "assistant", "content": "This is a placeholder response. The full model will be running after starting the services."}
|
190 |
+
]
|
191 |
+
|
192 |
+
# Append new messages to existing history (or initialize if history is None)
|
193 |
+
updated_history = (chat_history if chat_history is not None else []) + new_messages
|
194 |
+
return updated_history, None
|
195 |
|
196 |
# Connect events
|
197 |
setup_btn.click(on_setup_click, outputs=[setup_output, services_btn])
|