Spaces:
Runtime error
Runtime error
Update backend/models.py
Browse files- backend/models.py +2 -38
backend/models.py
CHANGED
|
@@ -69,15 +69,7 @@ class LLMFinanceAnalyzer:
|
|
| 69 |
def __init__(self):
|
| 70 |
self.gemini_api_key = os.getenv("GEMINI_API_KEY")
|
| 71 |
|
| 72 |
-
|
| 73 |
-
logger.error("JTS_API_KEY or JAI_BASE_URL not found for JAI client.")
|
| 74 |
-
raise ValueError("JAI API credentials are not configured.")
|
| 75 |
-
try:
|
| 76 |
-
self.client_jai = AsyncOpenAI(base_url=self.jai_base_url, api_key=self.jai_api_key)
|
| 77 |
-
logger.info("LLMFinanceAnalyzer initialized with JAI client.")
|
| 78 |
-
except Exception as e:
|
| 79 |
-
logger.error(f"Failed to initialize JAI client: {e}")
|
| 80 |
-
raise
|
| 81 |
|
| 82 |
self.client_gemini = None
|
| 83 |
if self.gemini_api_key:
|
|
@@ -89,35 +81,7 @@ class LLMFinanceAnalyzer:
|
|
| 89 |
else:
|
| 90 |
logger.warning("GEMINI_API_KEY not found, Gemini client not initialized.")
|
| 91 |
|
| 92 |
-
|
| 93 |
-
if self.openai_api_key:
|
| 94 |
-
try:
|
| 95 |
-
self.client_openai = AsyncOpenAI(api_key=self.openai_api_key)
|
| 96 |
-
logger.info("LLMFinanceAnalyzer initialized with OpenAI client.")
|
| 97 |
-
except Exception as e:
|
| 98 |
-
logger.error(f"Failed to initialize OpenAI client: {e}")
|
| 99 |
-
else:
|
| 100 |
-
logger.warning("OPENAI_API_KEY not found, OpenAI client not initialized.")
|
| 101 |
-
|
| 102 |
-
self.client_typhoon = None
|
| 103 |
-
if self.typhoon_api_key:
|
| 104 |
-
try:
|
| 105 |
-
self.client_typhoon = AsyncOpenAI(api_key=self.typhoon_api_key, base_url=self.typhoon_base_url)
|
| 106 |
-
logger.info("LLMFinanceAnalyzer initialized with typhoon client.")
|
| 107 |
-
except Exception as e:
|
| 108 |
-
logger.error(f"Failed to initialize typhoon client: {e}")
|
| 109 |
-
else:
|
| 110 |
-
logger.warning("TYPHOON_API_KEY not found, typhoon client not initialized.")
|
| 111 |
-
|
| 112 |
-
self.client_gemma = None
|
| 113 |
-
if self.gemma_api_key:
|
| 114 |
-
try:
|
| 115 |
-
self.client_gemma = AsyncOpenAI(api_key=self.gemma_api_key, base_url=self.gemma_base_url)
|
| 116 |
-
logger.info("LLMFinanceAnalyzer initialized with gemma client.")
|
| 117 |
-
except Exception as e:
|
| 118 |
-
logger.error(f"Failed to initialize gemma client: {e}")
|
| 119 |
-
else:
|
| 120 |
-
logger.warning("GEMMA_API_KEY not found, gemma client not initialized.")
|
| 121 |
|
| 122 |
def _get_client_for_model(self, model_name: str) -> Optional[AsyncOpenAI]:
|
| 123 |
"""Selects the appropriate client based on the model name."""
|
|
|
|
| 69 |
def __init__(self):
|
| 70 |
self.gemini_api_key = os.getenv("GEMINI_API_KEY")
|
| 71 |
|
| 72 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
self.client_gemini = None
|
| 75 |
if self.gemini_api_key:
|
|
|
|
| 81 |
else:
|
| 82 |
logger.warning("GEMINI_API_KEY not found, Gemini client not initialized.")
|
| 83 |
|
| 84 |
+
c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
def _get_client_for_model(self, model_name: str) -> Optional[AsyncOpenAI]:
|
| 87 |
"""Selects the appropriate client based on the model name."""
|