-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
37 lines (28 loc) · 1.28 KB
/
config.py
File metadata and controls
37 lines (28 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
from dotenv import load_dotenv
load_dotenv()
class Config:
# LLM Settings
LLM_PROVIDER = os.getenv("LLM_PROVIDER", "openai").lower() # 'openai' or 'ollama'
# OpenAI Settings
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
OPENAI_MODEL = os.getenv("OPENAI_MODEL", "gpt-4o")
# Ollama Settings
OLLAMA_BASE_URL = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434")
OLLAMA_MODEL = os.getenv("OLLAMA_MODEL", "llama3")
# Database Settings
DB_TYPE = os.getenv("DB_TYPE", "sqlite").lower() # 'sqlite', 'postgres', 'mssql'
# SQLite Settings
SQLITE_DB_PATH = os.getenv("SQLITE_DB_PATH", "natural_query.db")
# Postgres / MSSQL Settings
DB_HOST = os.getenv("DB_HOST", "localhost")
DB_PORT = os.getenv("DB_PORT") # Default: 5432 for Postgres, 1433 for MSSQL
DB_USER = os.getenv("DB_USER")
DB_PASSWORD = os.getenv("DB_PASSWORD")
DB_NAME = os.getenv("DB_NAME")
@classmethod
def validate(cls):
if cls.LLM_PROVIDER == "openai" and not cls.OPENAI_API_KEY:
raise ValueError("OPENAI_API_KEY is required for OpenAI provider.")
if cls.DB_TYPE not in ["sqlite", "postgres", "mssql"]:
raise ValueError(f"Unsupported DB_TYPE: {cls.DB_TYPE}. Must be sqlite, postgres, or mssql.")