Spaces:
Running
Running
bug fix
Browse files- src/app.py +15 -5
src/app.py
CHANGED
@@ -281,7 +281,8 @@ with gr.Blocks() as demo:
|
|
281 |
label="Medical Consultation",
|
282 |
height=500,
|
283 |
container=True,
|
284 |
-
|
|
|
285 |
)
|
286 |
|
287 |
with gr.Column(scale=1):
|
@@ -315,7 +316,10 @@ with gr.Blocks() as demo:
|
|
315 |
# First get the raw transcript and response
|
316 |
transcript = process_speech(audio_path, []) # Start fresh history
|
317 |
if not transcript or len(transcript) < 2:
|
318 |
-
return history + [
|
|
|
|
|
|
|
319 |
|
320 |
try:
|
321 |
# Get the last assistant response
|
@@ -326,12 +330,18 @@ with gr.Blocks() as demo:
|
|
326 |
response_dict = json.loads(assistant_json)
|
327 |
formatted_response = format_response_for_user(response_dict)
|
328 |
|
329 |
-
# Add the exchange to history in the correct
|
330 |
-
return history + [
|
|
|
|
|
|
|
331 |
|
332 |
except Exception as e:
|
333 |
print(f"Error formatting chat response: {e}")
|
334 |
-
return history + [
|
|
|
|
|
|
|
335 |
|
336 |
microphone.stream(
|
337 |
fn=enhanced_process_speech,
|
|
|
281 |
label="Medical Consultation",
|
282 |
height=500,
|
283 |
container=True,
|
284 |
+
bubble=True,
|
285 |
+
type="messages" # This is now properly supported by our message format
|
286 |
)
|
287 |
|
288 |
with gr.Column(scale=1):
|
|
|
316 |
# First get the raw transcript and response
|
317 |
transcript = process_speech(audio_path, []) # Start fresh history
|
318 |
if not transcript or len(transcript) < 2:
|
319 |
+
return history + [
|
320 |
+
{"role": "user", "content": "Audio recording"},
|
321 |
+
{"role": "assistant", "content": "I couldn't process that audio. Could you try again?"}
|
322 |
+
]
|
323 |
|
324 |
try:
|
325 |
# Get the last assistant response
|
|
|
330 |
response_dict = json.loads(assistant_json)
|
331 |
formatted_response = format_response_for_user(response_dict)
|
332 |
|
333 |
+
# Add the exchange to history in the correct message format
|
334 |
+
return history + [
|
335 |
+
{"role": "user", "content": user_message},
|
336 |
+
{"role": "assistant", "content": formatted_response}
|
337 |
+
]
|
338 |
|
339 |
except Exception as e:
|
340 |
print(f"Error formatting chat response: {e}")
|
341 |
+
return history + [
|
342 |
+
{"role": "user", "content": "Error processing audio"},
|
343 |
+
{"role": "assistant", "content": "Sorry, I encountered an error processing your symptoms. Could you try again?"}
|
344 |
+
]
|
345 |
|
346 |
microphone.stream(
|
347 |
fn=enhanced_process_speech,
|