ReviewLlama/src/reviewllama/configs.py

54 lines
1.2 KiB
Python
Raw Normal View History

2025-06-08 06:31:34 -04:00
from dataclasses import dataclass
from pathlib import Path
from typing import List
2025-06-08 06:31:34 -04:00
@dataclass(frozen=True)
class OllamaConfig:
"""Configuration for Ollama client."""
model: str
server_url: str
timeout: int
max_retries: int
@dataclass(frozen=True)
class ReviewConfig:
"""Complete configuration for ReviewLlama."""
paths: List[Path]
ollama: OllamaConfig
def create_ollama_config(
model: str, server_url: str, timeout: int, max_retries: int
) -> OllamaConfig:
"""Create OllamaConfig with validated parameters."""
return OllamaConfig(
model=model,
server_url=normalize_server_url(server_url),
timeout=timeout,
max_retries=max_retries,
)
def create_review_config(
paths: List[Path], ollama_config: OllamaConfig
) -> ReviewConfig:
"""Create complete ReviewConfig from validated components."""
return ReviewConfig(paths=paths, ollama=ollama_config)
def create_config_from_vars(
paths: List[Path], model: str, server_url: str, timeout: int, max_retries: int
):
ollama_config = OllamaConfig(
model=model,
server_url=server_url,
timeout=timeout,
max_retries=max_retries,
)
return create_review_config(paths, ollama_config)