Create Config dataclass for LLM options
This commit is contained in:
parent
3668cc3cbd
commit
f96b6413e2
2 changed files with 28 additions and 3 deletions
22
prophet/config.py
Normal file
22
prophet/config.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import os
|
||||
|
||||
# Load environment variables from .env
|
||||
from dataclasses import dataclass
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
_ = load_dotenv()
|
||||
|
||||
|
||||
@dataclass
|
||||
class AiConfig:
|
||||
API_KEY: str
|
||||
|
||||
@classmethod
|
||||
def from_env(cls) -> "AiConfig":
|
||||
API_KEY = os.getenv("GROQ_API_KEY", "")
|
||||
|
||||
if not API_KEY:
|
||||
raise ValueError(f"{API_KEY} cannot be empty")
|
||||
|
||||
return cls(**{"API_KEY": API_KEY})
|
||||
Loading…
Add table
Add a link
Reference in a new issue