54 lines
1.2 KiB
Python
54 lines
1.2 KiB
Python
|
from dataclasses import dataclass
|
||
|
from typing import List
|
||
|
from pathlib import Path
|
||
|
|
||
|
|
||
|
@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)
|