from __future__ import annotations import os from dataclasses import dataclass from pathlib import Path @dataclass(slots=True) class RuntimeConfig: """Runtime settings for the OpenAI-compatible vLLM endpoint.""" base_url: str = "http://localhost:8000/v1" api_key: str = "abc-123" model: str = "iac-secfix" temperature: float = 0.0 top_p: float = 1.0 max_tokens: int = 2048 work_dir: Path = Path("runs") @classmethod def from_env(cls) -> "RuntimeConfig": return cls( base_url=os.getenv("IAC_SECFIX_BASE_URL", cls.base_url), api_key=os.getenv("IAC_SECFIX_API_KEY", cls.api_key), model=os.getenv("IAC_SECFIX_MODEL", cls.model), temperature=float(os.getenv("IAC_SECFIX_TEMPERATURE", str(cls.temperature))), top_p=float(os.getenv("IAC_SECFIX_TOP_P", str(cls.top_p))), max_tokens=int(os.getenv("IAC_SECFIX_MAX_TOKENS", str(cls.max_tokens))), work_dir=Path(os.getenv("IAC_SECFIX_WORK_DIR", str(cls.work_dir))), ) def vllm_extra_body() -> dict[str, object]: """Small vLLM compatibility body. vLLM accepts these fields on OpenAI-compatible chat completions. Keeping this helper tiny avoids depending on notebook globals. """ return { "guided_decoding_backend": "outlines", }