64 lines
1.8 KiB
Python
64 lines
1.8 KiB
Python
"""
|
|
Configuration management for FactsDB service
|
|
"""
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
from typing import Optional
|
|
|
|
@dataclass
|
|
class AIEndpointConfig:
|
|
"""Configuration for AI endpoint"""
|
|
url: str = "http://example.com:4000"
|
|
auth_token: str = "111"
|
|
default_model: str = "gpt-oss"
|
|
|
|
@dataclass
|
|
class DatabaseConfig:
|
|
"""Database configuration"""
|
|
type: str = "sqlite"
|
|
connection_string: str = "facts.db"
|
|
|
|
@dataclass
|
|
class FTPConfig:
|
|
"""FTP server configuration"""
|
|
host: str = "0.0.0.0"
|
|
port: int = 21
|
|
username: str = "factsdb"
|
|
password: str = "factsdb123"
|
|
root_directory: str = "/tmp/factsdb_ftp"
|
|
|
|
@dataclass
|
|
class FileOnboardingConfig:
|
|
"""Configuration for file onboarding"""
|
|
directory_path: str
|
|
table_name: str
|
|
prompt: str
|
|
ai_model: str = "gpt-oss"
|
|
database_type: str = "sqlite"
|
|
cache_file: str = ".factsdb_cache"
|
|
|
|
class Config:
|
|
"""Main configuration class"""
|
|
|
|
def __init__(self):
|
|
self.ai_endpoint = AIEndpointConfig(
|
|
url=os.getenv("AI_ENDPOINT_URL", "http://example.com:4000"),
|
|
auth_token=os.getenv("AI_ENDPOINT_TOKEN", "111"),
|
|
default_model=os.getenv("DEFAULT_AI_MODEL", "gpt-oss")
|
|
)
|
|
|
|
self.database = DatabaseConfig(
|
|
type=os.getenv("DB_TYPE", "sqlite"),
|
|
connection_string=os.getenv("DB_CONNECTION", "facts.db")
|
|
)
|
|
|
|
self.ftp = FTPConfig(
|
|
host=os.getenv("FTP_HOST", "0.0.0.0"),
|
|
port=int(os.getenv("FTP_PORT", "21")),
|
|
username=os.getenv("FTP_USERNAME", "factsdb"),
|
|
password=os.getenv("FTP_PASSWORD", "factsdb123"),
|
|
root_directory=os.getenv("FTP_ROOT_DIR", "/tmp/factsdb_ftp")
|
|
)
|
|
|
|
self.cache_file = os.getenv("CACHE_FILE", ".factsdb_cache") |