feat: add initial uipath explainator implementation
Scaffold project with pyproject.toml and environment configuration Implement core modules including CLI, Gemini integration, and scanner
This commit is contained in:
32
src/uipath_explainator/config.py
Normal file
32
src/uipath_explainator/config.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Self
|
||||
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class Settings:
|
||||
api_key: str | None
|
||||
base_url: str | None
|
||||
model: str
|
||||
|
||||
@classmethod
|
||||
def from_env(cls, env_file: Path | None = None, model_override: str | None = None) -> Self:
|
||||
if env_file:
|
||||
load_dotenv(env_file)
|
||||
else:
|
||||
load_dotenv()
|
||||
|
||||
return cls(
|
||||
api_key=os.getenv("GEMINI_API_KEY") or os.getenv("GOOGLE_API_KEY"),
|
||||
base_url=os.getenv("GEMINI_BASE_URL") or None,
|
||||
model=model_override or os.getenv("GEMINI_MODEL") or "gemini-2.5-flash",
|
||||
)
|
||||
|
||||
def require_api_key(self) -> None:
|
||||
if not self.api_key:
|
||||
raise ValueError("Missing GEMINI_API_KEY (or GOOGLE_API_KEY) in the environment.")
|
||||
Reference in New Issue
Block a user