Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,27 +4,16 @@ import requests
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
import sympy
|
| 7 |
-
import
|
| 8 |
-
from duckduckgo_search import ddg
|
| 9 |
from langgraph.graph import StateGraph, END
|
| 10 |
from typing import TypedDict
|
| 11 |
|
| 12 |
-
# (Keep Constants as is)
|
| 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 |
-
from smolagent import Agent, Tool
|
| 19 |
-
from duckduckgo_search import ddg
|
| 20 |
-
import sympy
|
| 21 |
-
import re
|
| 22 |
# --- Tools ---
|
| 23 |
|
| 24 |
def wikipedia_search_tool(input: str) -> str:
|
| 25 |
-
results =
|
| 26 |
if results:
|
| 27 |
-
return results[0]
|
| 28 |
return "No information found."
|
| 29 |
|
| 30 |
def math_solver_tool(input: str) -> str:
|
|
@@ -96,6 +85,8 @@ builder.add_edge("search", END)
|
|
| 96 |
|
| 97 |
app_graph = builder.compile()
|
| 98 |
|
|
|
|
|
|
|
| 99 |
class BasicAgent:
|
| 100 |
def __init__(self):
|
| 101 |
print("LangGraph Agent initialized.")
|
|
|
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
import sympy
|
| 7 |
+
from duckduckgo_search import search
|
|
|
|
| 8 |
from langgraph.graph import StateGraph, END
|
| 9 |
from typing import TypedDict
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# --- Tools ---
|
| 12 |
|
| 13 |
def wikipedia_search_tool(input: str) -> str:
|
| 14 |
+
results = search(input, max_results=3)
|
| 15 |
if results:
|
| 16 |
+
return results[0].get("body", "No information found.")
|
| 17 |
return "No information found."
|
| 18 |
|
| 19 |
def math_solver_tool(input: str) -> str:
|
|
|
|
| 85 |
|
| 86 |
app_graph = builder.compile()
|
| 87 |
|
| 88 |
+
# --- Agent wrapper ---
|
| 89 |
+
|
| 90 |
class BasicAgent:
|
| 91 |
def __init__(self):
|
| 92 |
print("LangGraph Agent initialized.")
|