Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,39 @@
|
|
| 1 |
-
from smolagents import CodeAgent,
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
from tools.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Initialize tools
|
| 11 |
final_answer = FinalAnswerTool()
|
| 12 |
|
|
@@ -30,11 +57,13 @@ agent = CodeAgent(
|
|
| 30 |
model=model,
|
| 31 |
tools=[
|
| 32 |
final_answer,
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
| 35 |
generate_shopping_list,
|
| 36 |
-
format_shopping_list
|
| 37 |
-
image_generation_tool
|
| 38 |
],
|
| 39 |
max_steps=6,
|
| 40 |
verbosity_level=1,
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, HfApiModel, load_tool, tool # Removed DuckDuckGoSearchTool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from tools.web_search import DuckDuckGoSearchTool # Added your custom web search
|
| 8 |
+
from tools.visit_webpage import VisitWebPageTool # Added visit webpage tool
|
| 9 |
+
from tools.recipe_tools import (
|
| 10 |
+
search_recipe,
|
| 11 |
+
parse_recipe,
|
| 12 |
+
generate_shopping_list,
|
| 13 |
+
format_shopping_list
|
| 14 |
+
)
|
| 15 |
from Gradio_UI import GradioUI
|
| 16 |
|
| 17 |
+
# Initialize tools with dependencies
|
| 18 |
+
def create_search_recipe_with_deps(web_search, visit_webpage):
|
| 19 |
+
def search_recipe_wrapped(query: str) -> List[Dict[str, str]]:
|
| 20 |
+
return search_recipe(query, web_search, visit_webpage)
|
| 21 |
+
return search_recipe_wrapped
|
| 22 |
+
|
| 23 |
+
def create_parse_recipe_with_deps(visit_webpage):
|
| 24 |
+
def parse_recipe_wrapped(url: str) -> Dict:
|
| 25 |
+
return parse_recipe(url, visit_webpage)
|
| 26 |
+
return parse_recipe_wrapped
|
| 27 |
+
|
| 28 |
+
# Create tool instances
|
| 29 |
+
final_answer = FinalAnswerTool()
|
| 30 |
+
web_search = DuckDuckGoSearchTool()
|
| 31 |
+
visit_webpage = VisitWebPageTool()
|
| 32 |
+
|
| 33 |
+
# Create wrapped recipe tools with dependencies
|
| 34 |
+
search_recipe_tool = create_search_recipe_with_deps(web_search, visit_webpage)
|
| 35 |
+
parse_recipe_tool = create_parse_recipe_with_deps(visit_webpage)
|
| 36 |
+
|
| 37 |
# Initialize tools
|
| 38 |
final_answer = FinalAnswerTool()
|
| 39 |
|
|
|
|
| 57 |
model=model,
|
| 58 |
tools=[
|
| 59 |
final_answer,
|
| 60 |
+
final_answer,
|
| 61 |
+
web_search,
|
| 62 |
+
visit_webpage,
|
| 63 |
+
search_recipe_tool,
|
| 64 |
+
parse_recipe_tool,
|
| 65 |
generate_shopping_list,
|
| 66 |
+
format_shopping_list
|
|
|
|
| 67 |
],
|
| 68 |
max_steps=6,
|
| 69 |
verbosity_level=1,
|