HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/textanalyse/config.py
# config.py
import os
from pathlib import Path
from dotenv import load_dotenv
from typing import Optional, Tuple, Type
from agno.models.base import Model
from agno.models.google import Gemini
from agno.models.deepseek import DeepSeek # Changed import from DeepSeekChat to DeepSeek

# Load environment variables from.env file
# Ensure the.env file is in the project root directory
dotenv_path = Path(__file__).parent / '.env'
load_dotenv(dotenv_path=dotenv_path)

# --- Model Configuration ---
MODEL_PROVIDER = os.getenv("MODEL_PROVIDER", "google").lower() # Default to google

# API Keys
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY")

# Model IDs (Defaults are provided)
DEFAULT_GOOGLE_MODEL_ID = "gemini-1.5-flash-latest" # Fast and capable
DEFAULT_DEEPSEEK_MODEL_ID = "deepseek-chat" # General purpose DeepSeek model

GOOGLE_MODEL_ID = os.getenv("GOOGLE_MODEL_ID", DEFAULT_GOOGLE_MODEL_ID)
DEEPSEEK_MODEL_ID = os.getenv("DEEPSEEK_MODEL_ID", DEFAULT_DEEPSEEK_MODEL_ID)

# --- File Paths ---
BASE_DIR = Path(__file__).parent
KNOWLEDGE_DIR = BASE_DIR / "knowledge"
# Allow overriding dictionary path via environment variable
DEFAULT_DICT_PATH = KNOWLEDGE_DIR / "official_word_list.txt"
DICTIONARY_FILE_PATH_STR = os.getenv("DICTIONARY_FILE_PATH", str(DEFAULT_DICT_PATH))
DICTIONARY_FILE_PATH = Path(DICTIONARY_FILE_PATH_STR)

# --- Other Settings ---
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")

# --- Dynamic Model Loader ---
def get_selected_model() -> Tuple[Optional[Type[Model]], Optional[str], Optional[str]]:
    """
    Selects the appropriate Agno model class, ID, and API key based on MODEL_PROVIDER.

    Returns:
        Tuple[Optional[Type[Model]], Optional[str], Optional[str]]:
            Model Class, Model ID, API Key. Returns (None, None, None) if provider invalid.
    """
    if MODEL_PROVIDER == "google":
        if not GOOGLE_API_KEY:
            print("Warning: GOOGLE_API_KEY not found in.env file.")
        return Gemini, GOOGLE_MODEL_ID, GOOGLE_API_KEY
    elif MODEL_PROVIDER == "deepseek":
        if not DEEPSEEK_API_KEY:
            print("Warning: DEEPSEEK_API_KEY not found in.env file.")
        # Note: DeepSeek might require base_url depending on Agno implementation
        # Check Agno docs if direct DeepSeek class needs extra args
        return DeepSeek, DEEPSEEK_MODEL_ID, DEEPSEEK_API_KEY
    else:
        print(f"Error: Invalid MODEL_PROVIDER '{MODEL_PROVIDER}' in.env file. Choose 'google' or 'deepseek'.")
        return None, None, None

# Get the selected model details
SelectedModelClass, SELECTED_MODEL_ID, SELECTED_API_KEY = get_selected_model()

# --- Optional API Backend URL ---
API_BASE_URL = os.getenv("API_BASE_URL", "http://127.0.0.1:9239")
CONSOLE_URL = os.getenv("CONSOLE_URL", "http://localhost:3000")

print(f"Using Model Provider: {MODEL_PROVIDER}")
if SelectedModelClass:
    print(f"Using Model ID: {SELECTED_MODEL_ID}")
else:
     print("Model configuration failed. Please check.env file.")