Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,10 +2,9 @@ import os
|
|
| 2 |
import gradio as gr
|
| 3 |
from PIL import Image
|
| 4 |
from smolagents import (
|
| 5 |
-
CodeAgent,
|
| 6 |
-
|
| 7 |
-
DuckDuckGoSearchTool,
|
| 8 |
-
# visit_webpage,
|
| 9 |
Tool
|
| 10 |
)
|
| 11 |
import requests
|
|
@@ -66,11 +65,17 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 66 |
image_generation_tool
|
| 67 |
]
|
| 68 |
|
| 69 |
-
# 5. Initialize
|
| 70 |
-
#
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
# 6. Initialize the CodeAgent with the
|
| 74 |
agent = CodeAgent(
|
| 75 |
tools=all_tools,
|
| 76 |
model=model,
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from PIL import Image
|
| 4 |
from smolagents import (
|
| 5 |
+
CodeAgent,
|
| 6 |
+
LiteLLMModel, # <-- NEW: for Gemini
|
| 7 |
+
DuckDuckGoSearchTool,
|
|
|
|
| 8 |
Tool
|
| 9 |
)
|
| 10 |
import requests
|
|
|
|
| 65 |
image_generation_tool
|
| 66 |
]
|
| 67 |
|
| 68 |
+
# 5. Initialize Google Gemini 2.0 Flash model using LiteLLMModel
|
| 69 |
+
# The API key must be stored as a secret named GEMINI_API_KEY in the HF Space.
|
| 70 |
+
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
| 71 |
+
if not gemini_api_key:
|
| 72 |
+
raise ValueError("GEMINI_API_KEY environment variable not set. Please add it to Hugging Face Space secrets.")
|
| 73 |
+
model = LiteLLMModel(
|
| 74 |
+
model_id="gemini/gemini-2.0-flash",
|
| 75 |
+
api_key=gemini_api_key
|
| 76 |
+
)
|
| 77 |
|
| 78 |
+
# 6. Initialize the CodeAgent with the Gemini model
|
| 79 |
agent = CodeAgent(
|
| 80 |
tools=all_tools,
|
| 81 |
model=model,
|