FabienDanieau commited on
Commit
400b9bc
·
1 Parent(s): d3c0962

enhancement #12: change demo title

Browse files
src/reachy_mini_conversation_demo/main.py CHANGED
@@ -1,4 +1,4 @@
1
- from threading import Thread # noqa: D100
2
 
3
  import gradio as gr
4
  from fastapi import FastAPI
@@ -18,7 +18,7 @@ from reachy_mini_conversation_demo.utils import (
18
 
19
 
20
  def update_chatbot(chatbot: list[dict], response: dict):
21
- print("Updating chatbot with response:", response)
22
  chatbot.append(response)
23
  return chatbot
24
 
@@ -64,15 +64,16 @@ def main():
64
  additional_inputs=[chatbot],
65
  additional_outputs=[chatbot],
66
  additional_outputs_handler=update_chatbot,
 
67
  )
68
 
69
  app = FastAPI()
70
  app = gr.mount_gradio_app(app, stream.ui, path="/")
71
- # UI bloquantethread standard
72
  ui_thread = Thread(target=stream.ui.launch, daemon=True)
73
  ui_thread.start()
74
 
75
- # Chaque service async son propre thread/loop
76
  move_thread = AioTaskThread(movement_manager.enable) # loop A
77
  wobbler_thread = AioTaskThread(head_wobbler.enable) # loop B
78
  cam_thread = AioTaskThread(camera_worker.enable) if camera_worker else None
@@ -82,7 +83,7 @@ def main():
82
  if cam_thread:
83
  cam_thread.start()
84
 
85
- # lier les loops pour la communication thread-safe
86
  head_wobbler.bind_loops(
87
  consumer_loop=wobbler_thread.loop,
88
  movement_loop=move_thread.loop,
 
1
+ from threading import Thread
2
 
3
  import gradio as gr
4
  from fastapi import FastAPI
 
18
 
19
 
20
  def update_chatbot(chatbot: list[dict], response: dict):
21
+ """Update the chatbot with AdditionalOutputs."""
22
  chatbot.append(response)
23
  return chatbot
24
 
 
64
  additional_inputs=[chatbot],
65
  additional_outputs=[chatbot],
66
  additional_outputs_handler=update_chatbot,
67
+ ui_args={"title": "Talk with Reachy Mini"},
68
  )
69
 
70
  app = FastAPI()
71
  app = gr.mount_gradio_app(app, stream.ui, path="/")
72
+ # UI is blocking run in a standard thread
73
  ui_thread = Thread(target=stream.ui.launch, daemon=True)
74
  ui_thread.start()
75
 
76
+ # Each async service → its own thread/loop
77
  move_thread = AioTaskThread(movement_manager.enable) # loop A
78
  wobbler_thread = AioTaskThread(head_wobbler.enable) # loop B
79
  cam_thread = AioTaskThread(camera_worker.enable) if camera_worker else None
 
83
  if cam_thread:
84
  cam_thread.start()
85
 
86
+ # Link the loops for thread-safe communication
87
  head_wobbler.bind_loops(
88
  consumer_loop=wobbler_thread.loop,
89
  movement_loop=move_thread.loop,