Spaces:
Sleeping
Sleeping
applied fix
Browse files
app.py
CHANGED
|
@@ -17,10 +17,23 @@ class BasicAgent:
|
|
| 17 |
print("Initializing the BasicAgent")
|
| 18 |
# model = OpenAIServerModel(model_id="gpt-4o")
|
| 19 |
# model = OpenAIServerModel(model_id="gpt-3.5-turbo")
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
# Initialize the search tool
|
| 25 |
search_tool = DuckDuckGoSearchTool()
|
| 26 |
print("DuckDuckSearchTool instantiated")
|
|
|
|
| 17 |
print("Initializing the BasicAgent")
|
| 18 |
# model = OpenAIServerModel(model_id="gpt-4o")
|
| 19 |
# model = OpenAIServerModel(model_id="gpt-3.5-turbo")
|
| 20 |
+
google_api_key = os.getenv('GOOGLE_API_KEY')
|
| 21 |
+
if google_api_key:
|
| 22 |
+
print(f"GOOGLE_API_KEY found. Last 10 characters: ...{google_api_key[-10:]}")
|
| 23 |
+
else:
|
| 24 |
+
print("GOOGLE_API_KEY environment variable not set.")
|
| 25 |
+
|
| 26 |
+
try:
|
| 27 |
+
gemini_model_id = "gemini/gemini-2.0-flash"
|
| 28 |
+
model = LiteLLMModel(model_id=gemini_model_id)
|
| 29 |
+
# print("GPT-4o LLM is instantiated")
|
| 30 |
+
print(f"{gemini_model_id} LLM instantiated using LiteLLM")
|
| 31 |
+
except Exception as e:
|
| 32 |
+
print(f"Error instantiating LLM: {e}")
|
| 33 |
+
print("Please ensure you have installed smolagents[litellm] and google-generativeai,")
|
| 34 |
+
print("and that your GOOGLE_API_KEY environment variable is set.")
|
| 35 |
+
raise e # Re-raise the exception to fail initialization if model fails
|
| 36 |
+
|
| 37 |
# Initialize the search tool
|
| 38 |
search_tool = DuckDuckGoSearchTool()
|
| 39 |
print("DuckDuckSearchTool instantiated")
|