added web search tool
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
-
from smolagents import CodeAgent, InferenceClientModel
|
| 7 |
from huggingface_hub import login
|
| 8 |
|
| 9 |
# Login to HF
|
|
@@ -13,11 +13,14 @@ login(token=os.getenv("HF_TOKEN"))
|
|
| 13 |
# --- Constants ---
|
| 14 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
# --- Basic Agent Definition ---
|
| 17 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 18 |
class BasicAgent:
|
| 19 |
def __init__(self):
|
| 20 |
-
self.agent = CodeAgent(tools=[],
|
| 21 |
model=InferenceClientModel(),
|
| 22 |
)
|
| 23 |
print("BasicAgent initialized.")
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool
|
| 7 |
from huggingface_hub import login
|
| 8 |
|
| 9 |
# Login to HF
|
|
|
|
| 13 |
# --- Constants ---
|
| 14 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 15 |
|
| 16 |
+
# ---- Tools ----
|
| 17 |
+
web_search_tool = DuckDuckGoSearchTool(max_results=10)
|
| 18 |
+
|
| 19 |
# --- Basic Agent Definition ---
|
| 20 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 21 |
class BasicAgent:
|
| 22 |
def __init__(self):
|
| 23 |
+
self.agent = CodeAgent(tools=[web_search_tool],
|
| 24 |
model=InferenceClientModel(),
|
| 25 |
)
|
| 26 |
print("BasicAgent initialized.")
|