Spaces:
Sleeping
Sleeping
Commit
·
dc7a501
1
Parent(s):
f55317e
Update services/agent_crewai.py
Browse files- services/agent_crewai.py +15 -15
services/agent_crewai.py
CHANGED
|
@@ -276,31 +276,31 @@ Current session file: {session_file_path}
|
|
| 276 |
Execution plan: {plan_json}
|
| 277 |
"""
|
| 278 |
|
| 279 |
-
#
|
| 280 |
-
#
|
|
|
|
| 281 |
try:
|
| 282 |
import google.generativeai as genai
|
| 283 |
|
| 284 |
-
#
|
| 285 |
api_key = os.getenv("GOOGLE_API_KEY") or os.getenv("GEMINI_API_KEY")
|
| 286 |
if api_key:
|
| 287 |
genai.configure(api_key=api_key)
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
|
|
|
| 293 |
|
| 294 |
except ImportError as e:
|
| 295 |
-
print(f"
|
| 296 |
-
print("
|
| 297 |
-
|
| 298 |
-
llm = "gemini/gemini-2.0-flash"
|
| 299 |
|
| 300 |
except Exception as e:
|
| 301 |
-
print(f"
|
| 302 |
-
|
| 303 |
-
llm = os.getenv("CREWAI_LLM", "gemini/gemini-2.0-flash")
|
| 304 |
|
| 305 |
agent = Agent(
|
| 306 |
role="Document Processing Specialist",
|
|
|
|
| 276 |
Execution plan: {plan_json}
|
| 277 |
"""
|
| 278 |
|
| 279 |
+
# Use LiteLLM-compatible string format for Gemini
|
| 280 |
+
# CrewAI internally uses LiteLLM which requires "gemini/" prefix
|
| 281 |
+
# Now that google-generativeai is installed, this should work
|
| 282 |
try:
|
| 283 |
import google.generativeai as genai
|
| 284 |
|
| 285 |
+
# Verify package is installed and configure it
|
| 286 |
api_key = os.getenv("GOOGLE_API_KEY") or os.getenv("GEMINI_API_KEY")
|
| 287 |
if api_key:
|
| 288 |
genai.configure(api_key=api_key)
|
| 289 |
+
# Use LiteLLM string format (not the model object)
|
| 290 |
+
llm = "gemini/gemini-2.0-flash-exp"
|
| 291 |
+
print(f"✅ CrewAI using Gemini via LiteLLM: {llm}")
|
| 292 |
+
else:
|
| 293 |
+
print("⚠️ No Google API key found")
|
| 294 |
+
llm = "gemini/gemini-2.0-flash-exp"
|
| 295 |
|
| 296 |
except ImportError as e:
|
| 297 |
+
print(f"⚠️ google.generativeai not available: {e}")
|
| 298 |
+
print("Using LiteLLM format anyway")
|
| 299 |
+
llm = "gemini/gemini-2.0-flash-exp"
|
|
|
|
| 300 |
|
| 301 |
except Exception as e:
|
| 302 |
+
print(f"⚠️ Error configuring Gemini: {e}")
|
| 303 |
+
llm = "gemini/gemini-2.0-flash-exp"
|
|
|
|
| 304 |
|
| 305 |
agent = Agent(
|
| 306 |
role="Document Processing Specialist",
|