|
12 | 12 | import inspect |
13 | 13 | import logging # allow-direct-logging :: for direct logging control in _suppress_provider_logs |
14 | 14 | import os |
| 15 | +import secrets |
15 | 16 | import shutil |
16 | 17 | import subprocess |
17 | 18 | import sys |
@@ -210,6 +211,18 @@ def add_letsgo_arguments(parser: argparse.ArgumentParser) -> None: |
210 | 211 | default=False, |
211 | 212 | help="Allow running without TLS certificates. Disables FIPS enforcement. For local development only.", |
212 | 213 | ) |
| 214 | + parser.add_argument( |
| 215 | + "--host", |
| 216 | + type=str, |
| 217 | + default="127.0.0.1", |
| 218 | + help="Host to bind the server to", |
| 219 | + ) |
| 220 | + parser.add_argument( |
| 221 | + "--no-auth", |
| 222 | + action="store_true", |
| 223 | + default=False, |
| 224 | + help="Disable authentication entirely (generates no server.auth block in config).", |
| 225 | + ) |
213 | 226 |
|
214 | 227 |
|
215 | 228 | def _add_file_search_and_responses(run_config: StackConfig) -> None: |
@@ -471,6 +484,23 @@ async def _run_letsgo_cmd_impl(args: argparse.Namespace, parser: argparse.Argume |
471 | 484 | config_dict["server"]["insecure"] = False |
472 | 485 | cprint(f" ✓ Generated self-signed TLS certificate → {cert_path}", color="green") |
473 | 486 |
|
| 487 | + config_dict["server"]["host"] = args.host |
| 488 | + |
| 489 | + if not args.no_auth: |
| 490 | + api_keys = [f"ogk_{secrets.token_urlsafe(24)}" for _ in range(3)] |
| 491 | + if "server" not in config_dict: |
| 492 | + config_dict["server"] = {} |
| 493 | + config_dict["server"]["auth"] = { |
| 494 | + "provider_config": {"type": "local_api_key", "api_keys": api_keys}, |
| 495 | + } |
| 496 | + cprint(" ✓ Simple authentication enabled", color="green") |
| 497 | + cprint(" Here are keys you can use for authentication:", color="green") |
| 498 | + for key in api_keys: |
| 499 | + cprint(f" {key}", color="yellow") |
| 500 | + cprint(f' curl -k -H "Authorization: Bearer {api_keys[0]}" \\', color="cyan") |
| 501 | + cprint(f" https://localhost:{args.port}/v1/chat/completions", color="cyan") |
| 502 | + cprint("", color="green") |
| 503 | + |
474 | 504 | config_file = distro_dir / "config.yaml" |
475 | 505 | logger.info("Writing generated config to", config_file=config_file) |
476 | 506 | with open(config_file, "w") as f: |
@@ -552,6 +582,7 @@ async def _autodetect_providers(debug: bool = False) -> tuple[str, tuple[Qualifi |
552 | 582 | ("remote::anthropic", None, "https://api.anthropic.com/v1", "ANTHROPIC_API_KEY", None), |
553 | 583 | ("remote::gemini", None, "https://generativelanguage.googleapis.com/v1beta/openai", "GEMINI_API_KEY", None), |
554 | 584 | ("remote::azure", "AZURE_API_BASE", "", "AZURE_API_KEY", None), |
| 585 | + ("remote::meta", None, "https://api.meta.ai/v1", "META_API_KEY", None), |
555 | 586 | ] |
556 | 587 |
|
557 | 588 | passed: list[str] = [] |
|
0 commit comments