Spaces:
Sleeping
Sleeping
File size: 1,952 Bytes
5880248 9b5b26a c19d193 6aae614 5880248 8fe992b 9b5b26a 63aa8a5 6646e94 63aa8a5 7d22f5b bbcd7df a8b5ab0 63aa8a5 f568512 63aa8a5 f568512 63aa8a5 f568512 63aa8a5 811d183 5880248 811d183 fa237f3 5880248 3fea76e fa237f3 b2b1bc0 63aa8a5 bed7c2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
from smolagents import CodeAgent,HfApiModel,load_tool,tool
import datetime
import requests
import pytz
import yaml
from tools.final_answer import FinalAnswerTool
from tools.visit_webpage import VisitWebpageTool
from tools.web_search import DuckDuckGoSearchTool
from Gradio_UI import GradioUI
# Tool to suggest a menu based on the occasion
@tool
def suggest_menu(occasion: str) -> str:
"""
Suggests a menu based on the occasion. Elaborate your suggestion, if possible giving serving time.
Args:
occasion: The type of occasion for the party. Valid values are casual, formal and superhero
Output:
Your sugestion for the menu, that you will use to give detail about each dish.
"""
if occasion == "casual":
return "Pizza, snacks, and drinks. Please, elaborate this menu."
elif occasion == "formal":
return "3-course dinner with wine and dessert. Please, elaborate this menu, if possible giving serving time."
elif occasion == "superhero":
return "Buffet with high-energy and healthy food. Please, elaborate this menu."
else:
return "Custom menu for the butler."
final_answer = FinalAnswerTool()
visit_webpage = VisitWebpageTool()
web_search = DuckDuckGoSearchTool()
model = HfApiModel(
max_tokens=2096,
temperature=0.5,
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
custom_role_conversions=None,
)
with open("prompts.yaml", 'r') as stream:
prompt_templates = yaml.safe_load(stream)
agent = CodeAgent(
model=model,
tools=[suggest_menu,visit_webpage,web_search,final_answer], ## add your tools here (don't remove final answer)
max_steps=10,
verbosity_level=2,
grammar=None,
planning_interval=None,
name=None,
description=None,
prompt_templates=prompt_templates
)
GradioUI(agent).launch() |