From 9f82a0a2231ce732cb647ae67d3ac0cd6312c1a4 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 14 Oct 2026 20:45:52 -0300 Subject: hello --- setup_wizard.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'setup_wizard.py') diff --git a/setup_wizard.py b/setup_wizard.py index 743db51..a2329e7 100644 --- a/setup_wizard.py +++ b/setup_wizard.py @@ -63,11 +63,12 @@ def write_tokens_file(config_dir: Path): print(f"wrote {config_dir / 'tokens.txt'}") -def write_connection_file(config_dir: Path, default_uri: str = "ws://127.0.0.1:8765"): +def write_connection_file(config_dir: Path, default_uri: str = "ws://127.0.0.1:8765", ask_fallback: bool = False): config_dir.mkdir(parents=True, exist_ok=True) old = read_lines(config_dir / "connection.txt") old_uri = old[0] if len(old) > 0 else default_uri old_token = old[1] if len(old) > 1 else None + fallback = old[2] if len(old) > 2 else None print("\n-- connection to main.py --") uri = ask_keep("main.py address (ws:// or wss://)", old_uri) if old_token: @@ -78,7 +79,14 @@ def write_connection_file(config_dir: Path, default_uri: str = "ws://127.0.0.1:8 if not token: token = secrets.token_urlsafe(32) print(f"generated token: {token}") - (config_dir / "connection.txt").write_text(f"{uri}\n{token}\n", encoding="utf-8") + if ask_fallback: + print("\n-- fallback (optional) --") + if ask_yn("use a local ollama main.py as the fallback when gemini runs out of quota"): + fallback = ask_keep("fallback main.py address", fallback or "ws://127.0.0.1:8766") + print("start it with: PORT=8766 python3 main.py (it uses the same auth token, from config/auth_token.txt)") + else: + fallback = None + (config_dir / "connection.txt").write_text(f"{uri}\n{token}\n" + (f"{fallback}\n" if fallback else ""), encoding="utf-8") print(f"wrote {config_dir / 'connection.txt'}") return token @@ -124,7 +132,7 @@ def main(): main_config = SCRIPT_DIR / "config" backend = ask_backend() write_tokens_file(bot_config) - token = write_connection_file(bot_config, default_uri="ws://127.0.0.1:8765") + token = write_connection_file(bot_config, default_uri="ws://127.0.0.1:8765", ask_fallback=(backend == "gemini")) write_auth_token_file(main_config, token=token) if backend == "gemini": write_gemini_key_file(main_config) -- cgit v1.3-2-g0d8e