Update app.py
Browse files
app.py
CHANGED
@@ -133,7 +133,8 @@ class GeminiHandler(StreamHandler):
|
|
133 |
output_sample_rate=self.output_sample_rate,
|
134 |
output_frame_size=self.output_frame_size,
|
135 |
)
|
136 |
-
|
|
|
137 |
return handler
|
138 |
|
139 |
def _initialize_websocket(self):
|
@@ -314,6 +315,9 @@ class PreconsultationApp:
|
|
314 |
<p style='color: #666; font-size: 14px'>
|
315 |
This AI agent will help gather preliminary information before your consultation
|
316 |
</p>
|
|
|
|
|
|
|
317 |
</div>
|
318 |
""")
|
319 |
|
@@ -347,6 +351,12 @@ class PreconsultationApp:
|
|
347 |
<li>Get a summary report for your healthcare provider</li>
|
348 |
</ol>
|
349 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
""")
|
351 |
|
352 |
end_session_btn = gr.Button(
|
@@ -371,7 +381,8 @@ class PreconsultationApp:
|
|
371 |
inputs=[webrtc],
|
372 |
outputs=[webrtc],
|
373 |
time_limit=600, # 10 minutes max
|
374 |
-
concurrency_limit=1
|
|
|
375 |
)
|
376 |
|
377 |
# Handle end session
|
@@ -380,11 +391,13 @@ class PreconsultationApp:
|
|
380 |
self.handler.conversation_tracker.end_session()
|
381 |
report = self.handler.conversation_tracker.generate_report()
|
382 |
return gr.update(value=report, visible=True)
|
383 |
-
|
|
|
384 |
|
385 |
end_session_btn.click(
|
386 |
end_session,
|
387 |
-
outputs=[report_output]
|
|
|
388 |
)
|
389 |
|
390 |
gr.HTML("""
|
@@ -416,12 +429,18 @@ class PreconsultationApp:
|
|
416 |
print("You can get a Gemini API key from: https://ai.google.dev/gemini-api/docs/api-key")
|
417 |
print("The interface will launch, but voice functionality won't work without the API key.")
|
418 |
|
419 |
-
self.demo.
|
|
|
|
|
|
|
420 |
server_name="0.0.0.0",
|
421 |
server_port=int(os.environ.get("PORT", 7860)),
|
422 |
ssl_verify=False,
|
423 |
ssl_keyfile=None,
|
424 |
ssl_certfile=None,
|
|
|
|
|
|
|
425 |
)
|
426 |
|
427 |
|
|
|
133 |
output_sample_rate=self.output_sample_rate,
|
134 |
output_frame_size=self.output_frame_size,
|
135 |
)
|
136 |
+
# Each copy gets its own conversation tracker for independent sessions
|
137 |
+
handler.conversation_tracker = ConversationTracker()
|
138 |
return handler
|
139 |
|
140 |
def _initialize_websocket(self):
|
|
|
315 |
<p style='color: #666; font-size: 14px'>
|
316 |
This AI agent will help gather preliminary information before your consultation
|
317 |
</p>
|
318 |
+
<p style='color: #059669; font-size: 12px; font-weight: bold'>
|
319 |
+
⚡ Real-time voice interaction • 📊 Automated reporting • 🔒 Session-based privacy
|
320 |
+
</p>
|
321 |
</div>
|
322 |
""")
|
323 |
|
|
|
351 |
<li>Get a summary report for your healthcare provider</li>
|
352 |
</ol>
|
353 |
</div>
|
354 |
+
<div style='background-color: #fef3c7; padding: 10px; border-radius: 6px; margin-bottom: 15px'>
|
355 |
+
<p style='margin: 0; font-size: 12px; color: #92400e'>
|
356 |
+
<strong>Note:</strong> If you see "Too many users", please wait a moment and try again.
|
357 |
+
Multiple users can use the system simultaneously.
|
358 |
+
</p>
|
359 |
+
</div>
|
360 |
""")
|
361 |
|
362 |
end_session_btn = gr.Button(
|
|
|
381 |
inputs=[webrtc],
|
382 |
outputs=[webrtc],
|
383 |
time_limit=600, # 10 minutes max
|
384 |
+
concurrency_limit=10, # Increased from 1
|
385 |
+
concurrency_id="webrtc_stream"
|
386 |
)
|
387 |
|
388 |
# Handle end session
|
|
|
391 |
self.handler.conversation_tracker.end_session()
|
392 |
report = self.handler.conversation_tracker.generate_report()
|
393 |
return gr.update(value=report, visible=True)
|
394 |
+
else:
|
395 |
+
return gr.update(value="No active session found. Please start a voice consultation first.", visible=True)
|
396 |
|
397 |
end_session_btn.click(
|
398 |
end_session,
|
399 |
+
outputs=[report_output],
|
400 |
+
concurrency_limit=20
|
401 |
)
|
402 |
|
403 |
gr.HTML("""
|
|
|
429 |
print("You can get a Gemini API key from: https://ai.google.dev/gemini-api/docs/api-key")
|
430 |
print("The interface will launch, but voice functionality won't work without the API key.")
|
431 |
|
432 |
+
self.demo.queue(
|
433 |
+
max_size=50, # Allow more users in queue
|
434 |
+
default_concurrency_limit=20
|
435 |
+
).launch(
|
436 |
server_name="0.0.0.0",
|
437 |
server_port=int(os.environ.get("PORT", 7860)),
|
438 |
ssl_verify=False,
|
439 |
ssl_keyfile=None,
|
440 |
ssl_certfile=None,
|
441 |
+
share=False,
|
442 |
+
show_error=True,
|
443 |
+
max_threads=40
|
444 |
)
|
445 |
|
446 |
|