cps-api-tx / core /txagent_config.py
Ali2206's picture
Initial CPS-API deployment with TxAgent integration
b515e8c
import os
from typing import Optional
import logging
logger = logging.getLogger(__name__)
class TxAgentConfig:
def __init__(self):
# Since TxAgent is now integrated, default to local mode
self.mode = os.getenv("TXAGENT_MODE", "local") # local, cloud, hybrid
self.cloud_url = os.getenv("TXAGENT_CLOUD_URL", "https://rocketfarmstudios-txagent-api.hf.space")
self.local_enabled = os.getenv("TXAGENT_LOCAL_ENABLED", "true").lower() == "true"
self.gpu_available = self._check_gpu_availability()
def _check_gpu_availability(self) -> bool:
"""Vérifie si GPU est disponible localement"""
try:
import torch
return torch.cuda.is_available()
except ImportError:
return False
def get_txagent_mode(self) -> str:
"""Détermine le mode optimal pour TxAgent"""
# Since TxAgent is integrated, always use local mode
return "local"
def get_txagent_url(self) -> str:
"""Retourne l'URL du service TxAgent"""
# Since TxAgent is integrated, return localhost
return "http://localhost:7860" # Same port as the main API
def is_local_available(self) -> bool:
"""Vérifie si le mode local est disponible"""
return True # Always available since it's integrated
# Instance globale
txagent_config = TxAgentConfig()