Spaces:
Running
Running
bigwolfe
commited on
Commit
·
f820354
1
Parent(s):
b7676a2
bugs
Browse files
backend/src/services/rag_index.py
CHANGED
|
@@ -13,8 +13,15 @@ from llama_index.core import (
|
|
| 13 |
Document,
|
| 14 |
Settings
|
| 15 |
)
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
from llama_index.core.base.response.schema import Response as LlamaResponse
|
| 19 |
from llama_index.core.llms import ChatMessage as LlamaChatMessage, MessageRole
|
| 20 |
|
|
@@ -34,6 +41,10 @@ class RAGIndexService:
|
|
| 34 |
|
| 35 |
def _setup_gemini(self):
|
| 36 |
"""Configure global LlamaIndex settings for Gemini."""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
if not self.config.google_api_key:
|
| 38 |
logger.warning("GOOGLE_API_KEY not set. RAG features will fail.")
|
| 39 |
return
|
|
|
|
| 13 |
Document,
|
| 14 |
Settings
|
| 15 |
)
|
| 16 |
+
|
| 17 |
+
try:
|
| 18 |
+
from llama_index.llms.google_genai import Gemini
|
| 19 |
+
from llama_index.embeddings.google_genai import GeminiEmbedding
|
| 20 |
+
except ImportError:
|
| 21 |
+
Gemini = None
|
| 22 |
+
GeminiEmbedding = None
|
| 23 |
+
logger.warning("Could not import google_genai modules. RAG features will be disabled.")
|
| 24 |
+
|
| 25 |
from llama_index.core.base.response.schema import Response as LlamaResponse
|
| 26 |
from llama_index.core.llms import ChatMessage as LlamaChatMessage, MessageRole
|
| 27 |
|
|
|
|
| 41 |
|
| 42 |
def _setup_gemini(self):
|
| 43 |
"""Configure global LlamaIndex settings for Gemini."""
|
| 44 |
+
if not Gemini or not GeminiEmbedding:
|
| 45 |
+
logger.error("Google GenAI modules not loaded. RAG setup skipped.")
|
| 46 |
+
return
|
| 47 |
+
|
| 48 |
if not self.config.google_api_key:
|
| 49 |
logger.warning("GOOGLE_API_KEY not set. RAG features will fail.")
|
| 50 |
return
|