57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
import os
|
|
from typing import List
|
|
from pydantic_settings import BaseSettings
|
|
|
|
def get_env_secret(key: str, default: str = "") -> str:
|
|
val = os.getenv(key)
|
|
if val:
|
|
return val
|
|
# Fallback to ~/.hermes/.env
|
|
env_path = os.path.expanduser("~/.hermes/.env")
|
|
if os.path.exists(env_path):
|
|
try:
|
|
with open(env_path, "r", encoding="utf-8") as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if line.startswith(f"{key}="):
|
|
return line.split("=", 1)[1].strip().strip('"').strip("'")
|
|
except Exception:
|
|
pass
|
|
return default
|
|
|
|
class Settings(BaseSettings):
|
|
PROJECT_NAME: str = "NetVibe Telegram Content Automation"
|
|
API_V1_STR: str = "/api/v1"
|
|
|
|
# Database
|
|
DATABASE_URL: str = os.getenv(
|
|
"DATABASE_URL",
|
|
"sqlite+aiosqlite:///./vpn_pipeline.db"
|
|
)
|
|
|
|
# Telegram Bot
|
|
TELEGRAM_BOT_TOKEN: str = get_env_secret("TELEGRAM_BOT_TOKEN", "")
|
|
TARGET_CHANNEL: str = os.getenv("TARGET_CHANNEL", "@NetVibe_VPN")
|
|
|
|
# LLM Settings
|
|
OPENAI_API_BASE: str = get_env_secret("OPENAI_API_BASE", "https://router.zebellkhan.com/v1")
|
|
OPENAI_API_KEY: str = get_env_secret("OPENAI_API_KEY") or get_env_secret("NINEROUTER_API_KEY", "")
|
|
OPENAI_MODEL: str = os.getenv("OPENAI_MODEL", "01")
|
|
|
|
# Scheduling & Automation
|
|
SCRAPE_INTERVAL_HOURS: int = 6
|
|
PUBLISH_CHECK_INTERVAL_SECONDS: int = 60
|
|
|
|
# CORS
|
|
CORS_ORIGINS: List[str] = [
|
|
"http://localhost:3000",
|
|
"http://127.0.0.1:3000",
|
|
"https://netvibe.ehsan.test.zebellkhan.com",
|
|
"*"
|
|
]
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
extra = "ignore"
|
|
|
|
settings = Settings()
|