apirrone commited on
Commit
11d0943
·
1 Parent(s): 5e2dbee

argparse.parse_known_args() actually returns a tuple

Browse files
src/reachy_mini_conversation_app/main.py CHANGED
@@ -7,6 +7,7 @@ import asyncio
7
  import argparse
8
  import threading
9
  from typing import Any, Dict, List, Optional
 
10
 
11
  import gradio as gr
12
  from fastapi import FastAPI
@@ -20,7 +21,6 @@ from reachy_mini_conversation_app.utils import (
20
  handle_vision_stuff,
21
  )
22
  from reachy_mini_conversation_app.config import config
23
- from pathlib import Path
24
 
25
 
26
  def update_chatbot(chatbot: List[Dict[str, Any]], response: Dict[str, Any]) -> List[Dict[str, Any]]:
@@ -31,7 +31,7 @@ def update_chatbot(chatbot: List[Dict[str, Any]], response: Dict[str, Any]) -> L
31
 
32
  def main() -> None:
33
  """Entrypoint for the Reachy Mini conversation app."""
34
- args = parse_args()
35
  run(args)
36
 
37
 
@@ -183,13 +183,21 @@ def run(
183
  value = f"user_personalities/{name_s}"
184
  if value not in choices:
185
  choices.append(value)
186
- return gr.update(choices=[DEFAULT_OPTION, *sorted(choices)], value=value), gr.update(value=instructions), f"Created personality '{name_s}'."
 
 
 
 
187
  except FileExistsError:
188
  choices = _list_personalities()
189
  value = f"user_personalities/{name_s}"
190
  if value not in choices:
191
  choices.append(value)
192
- return gr.update(choices=[DEFAULT_OPTION, *sorted(choices)], value=value), gr.update(value=instructions), f"Personality '{name_s}' already exists."
 
 
 
 
193
  except Exception as e:
194
  return gr.update(), gr.update(), f"Failed to create personality: {e}"
195
 
@@ -323,6 +331,7 @@ def run(
323
 
324
  # Name textbox
325
  from pathlib import Path as _P
 
326
  name_for_edit = "" if selected == DEFAULT_OPTION else _P(selected).name
327
  # Voice
328
  voice_val = _read_voice_for(selected)
@@ -408,7 +417,11 @@ def run(
408
  value = f"user_personalities/{name_s}"
409
  if value not in choices:
410
  choices.append(value)
411
- return gr.update(choices=[DEFAULT_OPTION, *sorted(choices)], value=value), gr.update(value=instructions), f"Saved personality '{name_s}'."
 
 
 
 
412
  except Exception as e:
413
  return gr.update(), gr.update(), f"Failed to save personality: {e}"
414
 
@@ -499,7 +512,7 @@ class ReachyMiniConversationApp(ReachyMiniApp): # type: ignore[misc]
499
  loop = asyncio.new_event_loop()
500
  asyncio.set_event_loop(loop)
501
 
502
- args = parse_args()
503
  args.gradio = True # Force gradio for Reachy Mini App integration
504
  run(args, robot=reachy_mini, app_stop_event=stop_event, settings_app=self.settings_app)
505
 
 
7
  import argparse
8
  import threading
9
  from typing import Any, Dict, List, Optional
10
+ from pathlib import Path
11
 
12
  import gradio as gr
13
  from fastapi import FastAPI
 
21
  handle_vision_stuff,
22
  )
23
  from reachy_mini_conversation_app.config import config
 
24
 
25
 
26
  def update_chatbot(chatbot: List[Dict[str, Any]], response: Dict[str, Any]) -> List[Dict[str, Any]]:
 
31
 
32
  def main() -> None:
33
  """Entrypoint for the Reachy Mini conversation app."""
34
+ args, _ = parse_args()
35
  run(args)
36
 
37
 
 
183
  value = f"user_personalities/{name_s}"
184
  if value not in choices:
185
  choices.append(value)
186
+ return (
187
+ gr.update(choices=[DEFAULT_OPTION, *sorted(choices)], value=value),
188
+ gr.update(value=instructions),
189
+ f"Created personality '{name_s}'.",
190
+ )
191
  except FileExistsError:
192
  choices = _list_personalities()
193
  value = f"user_personalities/{name_s}"
194
  if value not in choices:
195
  choices.append(value)
196
+ return (
197
+ gr.update(choices=[DEFAULT_OPTION, *sorted(choices)], value=value),
198
+ gr.update(value=instructions),
199
+ f"Personality '{name_s}' already exists.",
200
+ )
201
  except Exception as e:
202
  return gr.update(), gr.update(), f"Failed to create personality: {e}"
203
 
 
331
 
332
  # Name textbox
333
  from pathlib import Path as _P
334
+
335
  name_for_edit = "" if selected == DEFAULT_OPTION else _P(selected).name
336
  # Voice
337
  voice_val = _read_voice_for(selected)
 
417
  value = f"user_personalities/{name_s}"
418
  if value not in choices:
419
  choices.append(value)
420
+ return (
421
+ gr.update(choices=[DEFAULT_OPTION, *sorted(choices)], value=value),
422
+ gr.update(value=instructions),
423
+ f"Saved personality '{name_s}'.",
424
+ )
425
  except Exception as e:
426
  return gr.update(), gr.update(), f"Failed to save personality: {e}"
427
 
 
512
  loop = asyncio.new_event_loop()
513
  asyncio.set_event_loop(loop)
514
 
515
+ args, _ = parse_args()
516
  args.gradio = True # Force gradio for Reachy Mini App integration
517
  run(args, robot=reachy_mini, app_stop_event=stop_event, settings_app=self.settings_app)
518