generated from coulomb/repo-seed
LLM settings environment-configurable
This commit is contained in:
@@ -129,6 +129,12 @@ heuristic generator remains the fallback.
|
||||
|
||||
The FastAPI settings object also accepts `llm_provider` and `llm_model`. By
|
||||
default `llm_provider` is unset, so analysis is fully offline and deterministic.
|
||||
Environment variables use the `REPO_REGISTRY_` prefix:
|
||||
|
||||
```bash
|
||||
REPO_REGISTRY_LLM_PROVIDER=gemini
|
||||
REPO_REGISTRY_LLM_MODEL=gemini-2.5-flash
|
||||
```
|
||||
|
||||
## Agent-Facing Endpoints
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from pathlib import Path
|
||||
|
||||
from fastapi import Depends, FastAPI, HTTPException
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
from repo_registry.core.service import RegistryService
|
||||
from repo_registry.llm_extraction import LLMCandidateExtractor, create_llm_connect_adapter
|
||||
@@ -12,7 +13,9 @@ from repo_registry.repo_ingestion.git import GitIngestionService
|
||||
from repo_registry.storage.sqlite import NotFoundError, RegistryStore
|
||||
|
||||
|
||||
class Settings(BaseModel):
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_prefix="REPO_REGISTRY_")
|
||||
|
||||
database_path: str = Field(default="var/repo-registry.sqlite3")
|
||||
checkout_root: str = Field(default="var/checkouts")
|
||||
llm_provider: str | None = Field(default=None)
|
||||
|
||||
@@ -193,6 +193,20 @@ def test_api_service_settings_can_enable_llm_extractor(monkeypatch, tmp_path):
|
||||
assert service.llm_extractor is not None
|
||||
|
||||
|
||||
def test_settings_can_load_from_environment(monkeypatch):
|
||||
monkeypatch.setenv("REPO_REGISTRY_DATABASE_PATH", "var/env.sqlite3")
|
||||
monkeypatch.setenv("REPO_REGISTRY_CHECKOUT_ROOT", "var/env-checkouts")
|
||||
monkeypatch.setenv("REPO_REGISTRY_LLM_PROVIDER", "mock")
|
||||
monkeypatch.setenv("REPO_REGISTRY_LLM_MODEL", "demo-model")
|
||||
|
||||
settings = Settings()
|
||||
|
||||
assert settings.database_path == "var/env.sqlite3"
|
||||
assert settings.checkout_root == "var/env-checkouts"
|
||||
assert settings.llm_provider == "mock"
|
||||
assert settings.llm_model == "demo-model"
|
||||
|
||||
|
||||
def test_api_analysis_run_loop(tmp_path):
|
||||
source = tmp_path / "repo"
|
||||
source.mkdir()
|
||||
|
||||
Reference in New Issue
Block a user