Spaces:
Sleeping
Sleeping
File size: 1,399 Bytes
682caaf b515e8c 682caaf b515e8c 682caaf b515e8c 682caaf b515e8c 682caaf b515e8c 682caaf | 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 38 39 | 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()
|