Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
5af7d2f
1
Parent(s): b5594ba
backend stabilization
Browse files- core/llm.py +11 -9
- requirements-ai.txt +2 -2
core/llm.py
CHANGED
|
@@ -203,10 +203,10 @@ def _init_google(model: str = None, **kwargs: Any) -> Any:
|
|
| 203 |
raise
|
| 204 |
|
| 205 |
f_kwargs = kwargs.copy()
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
target_model = model or "gemini-2.5-flash"
|
| 211 |
|
| 212 |
if not settings.GOOGLE_API_KEY:
|
|
@@ -215,14 +215,16 @@ def _init_google(model: str = None, **kwargs: Any) -> Any:
|
|
| 215 |
|
| 216 |
logging.info(f"LLM_GOOGLE: Initializing with model='{target_model}' (key length={len(settings.GOOGLE_API_KEY)})")
|
| 217 |
try:
|
| 218 |
-
|
|
|
|
|
|
|
| 219 |
model=target_model,
|
| 220 |
-
google_api_key=settings.GOOGLE_API_KEY
|
| 221 |
-
timeout=kwargs.get("timeout", 60),
|
| 222 |
-
**f_kwargs
|
| 223 |
)
|
|
|
|
|
|
|
| 224 |
except Exception as e:
|
| 225 |
-
logging.error(f"LLM_GOOGLE: ChatGoogleGenerativeAI initialization failed: {e}")
|
| 226 |
raise
|
| 227 |
|
| 228 |
from langchain_core.runnables import Runnable
|
|
|
|
| 203 |
raise
|
| 204 |
|
| 205 |
f_kwargs = kwargs.copy()
|
| 206 |
+
# Remove incompatible parameters
|
| 207 |
+
for key in ["model", "timeout", "format", "is_heavy_task"]:
|
| 208 |
+
f_kwargs.pop(key, None)
|
| 209 |
+
|
| 210 |
target_model = model or "gemini-2.5-flash"
|
| 211 |
|
| 212 |
if not settings.GOOGLE_API_KEY:
|
|
|
|
| 215 |
|
| 216 |
logging.info(f"LLM_GOOGLE: Initializing with model='{target_model}' (key length={len(settings.GOOGLE_API_KEY)})")
|
| 217 |
try:
|
| 218 |
+
# ChatGoogleGenerativeAI doesn't support all the same parameters as other LLMs
|
| 219 |
+
# Only pass the core parameters it actually accepts
|
| 220 |
+
llm = ChatGoogleGenerativeAI(
|
| 221 |
model=target_model,
|
| 222 |
+
google_api_key=settings.GOOGLE_API_KEY
|
|
|
|
|
|
|
| 223 |
)
|
| 224 |
+
logging.info(f"LLM_GOOGLE: Successfully initialized {target_model}")
|
| 225 |
+
return llm
|
| 226 |
except Exception as e:
|
| 227 |
+
logging.error(f"LLM_GOOGLE: ChatGoogleGenerativeAI initialization failed: {type(e).__name__}: {str(e)}")
|
| 228 |
raise
|
| 229 |
|
| 230 |
from langchain_core.runnables import Runnable
|
requirements-ai.txt
CHANGED
|
@@ -8,8 +8,8 @@ requests>=2.31.0
|
|
| 8 |
|
| 9 |
# Cloud Providers (Optional but recommended for Cloud Path)
|
| 10 |
langchain-openai>=0.1.0
|
| 11 |
-
langchain-google-genai>=
|
| 12 |
-
google-
|
| 13 |
langchain-google-vertexai>=1.0.0
|
| 14 |
google-cloud-aiplatform>=1.40.0
|
| 15 |
langchain-groq
|
|
|
|
| 8 |
|
| 9 |
# Cloud Providers (Optional but recommended for Cloud Path)
|
| 10 |
langchain-openai>=0.1.0
|
| 11 |
+
langchain-google-genai>=0.7.0
|
| 12 |
+
google-genai>=0.4.0
|
| 13 |
langchain-google-vertexai>=1.0.0
|
| 14 |
google-cloud-aiplatform>=1.40.0
|
| 15 |
langchain-groq
|