mirror of
https://git.squeakyrat.moe/faggot-chan/
synced 2026-11-04 18:35:45 +01:00
hello
This commit is contained in:
1 parent
b8baac169d
commit
9f82a0a223
7 files changed
+418
-130
No files matched your search
+11
-3
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user