Reorganize python modules slightly
This commit is contained in:
parent
c9a0d9a225
commit
ed38373d1e
2 changed files with 57 additions and 46 deletions
53
src/reviewllama/configs.py
Normal file
53
src/reviewllama/configs.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
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)
|
Loading…
Add table
Add a link
Reference in a new issue