pulkitme
commited on
Commit
·
9fe98c0
1
Parent(s):
0d6567f
simple smolagent with duck duck go search tool
Browse files- app.py +20 -6
- requirements.txt +2 -1
app.py
CHANGED
@@ -5,8 +5,12 @@ import inspect
|
|
5 |
import pandas as pd
|
6 |
import time
|
7 |
from google import genai
|
|
|
8 |
|
9 |
-
|
|
|
|
|
|
|
10 |
# (Keep Constants as is)
|
11 |
# --- Constants ---
|
12 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
@@ -20,13 +24,23 @@ class BasicAgent:
|
|
20 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
21 |
|
22 |
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
)
|
26 |
-
|
27 |
#fixed_answer = "This is a default answer."
|
28 |
-
print(f"Agent returning fixed answer: {
|
29 |
-
return
|
30 |
|
31 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
32 |
"""
|
|
|
5 |
import pandas as pd
|
6 |
import time
|
7 |
from google import genai
|
8 |
+
from smolagents import CodeAgent, ToolCallingAgent, DuckDuckGoSearchTool, LiteLLMModel, PythonInterpreterTool, tool, TOOL_CALLING_SYSTEM_PROMPT,DuckDuckGoSearchTool
|
9 |
|
10 |
+
|
11 |
+
#client = genai.Client(api_key=os.getenv("API_KEY"))
|
12 |
+
model = LiteLLMModel(model_id="gemini/gemini-2.0-flash-exp",
|
13 |
+
api_key=os.getenv("API_KEY"))
|
14 |
# (Keep Constants as is)
|
15 |
# --- Constants ---
|
16 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
|
24 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
25 |
|
26 |
|
27 |
+
# response = client.models.generate_content(
|
28 |
+
# model="gemini-2.5-flash-preview-04-17", contents=question
|
29 |
+
# )
|
30 |
+
# gemini_flash_answer = response.text
|
31 |
+
|
32 |
+
agent = CodeAgent(
|
33 |
+
tools=[DuckDuckGoSearchTool()],
|
34 |
+
model=model,
|
35 |
+
#additional_authorized_imports=["helium"],
|
36 |
+
#step_callbacks=[save_screenshot],
|
37 |
+
max_steps=20,
|
38 |
+
verbosity_level=2,
|
39 |
)
|
40 |
+
answer = agent.run(question)
|
41 |
#fixed_answer = "This is a default answer."
|
42 |
+
print(f"Agent returning fixed answer: {answer}")
|
43 |
+
return answer
|
44 |
|
45 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
46 |
"""
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
gradio
|
2 |
requests
|
3 |
-
google-genai
|
|
|
|
1 |
gradio
|
2 |
requests
|
3 |
+
google-genai
|
4 |
+
smolagents
|