fix: prevent Groq LLM initialization when USE_GEMINI is enabled to avoid missing API key errors during chat stream
Browse files
src/services/llm_service.py
CHANGED
|
@@ -49,14 +49,14 @@ class MathAIEngine:
|
|
| 49 |
"""Orchestrates RAG retrieval, symbolic math, and LLM calls for math tutoring."""
|
| 50 |
|
| 51 |
def __init__(self, vector_store=None, session_id: str = "default"):
|
| 52 |
-
self.llm = self._init_llm()
|
| 53 |
self.vector_store = vector_store
|
| 54 |
self.memory = MongoDBChatMemory(session_id=session_id)
|
| 55 |
self.symbolic = SymbolicMathEngine()
|
| 56 |
self.session_id = session_id
|
| 57 |
|
| 58 |
def _init_llm(self):
|
| 59 |
-
"""Initialize the
|
| 60 |
return _get_llm(settings.groq_model_fallbacks[0])
|
| 61 |
|
| 62 |
def _retrieve_context(self, query: str) -> Tuple[list, str]:
|
|
|
|
| 49 |
"""Orchestrates RAG retrieval, symbolic math, and LLM calls for math tutoring."""
|
| 50 |
|
| 51 |
def __init__(self, vector_store=None, session_id: str = "default"):
|
| 52 |
+
self.llm = self._init_llm() if not settings.use_gemini else None
|
| 53 |
self.vector_store = vector_store
|
| 54 |
self.memory = MongoDBChatMemory(session_id=session_id)
|
| 55 |
self.symbolic = SymbolicMathEngine()
|
| 56 |
self.session_id = session_id
|
| 57 |
|
| 58 |
def _init_llm(self):
|
| 59 |
+
"""Initialize the fallback Groq LLM model."""
|
| 60 |
return _get_llm(settings.groq_model_fallbacks[0])
|
| 61 |
|
| 62 |
def _retrieve_context(self, query: str) -> Tuple[list, str]:
|