Spaces:
Runtime error
Runtime error
File size: 2,369 Bytes
9902f94 9b5b26a a43d707 9b5b26a c19d193 6aae614 8fe992b 9b5b26a e54d257 9b5b26a d806e9c 10dabf6 9b5b26a 10dabf6 d806e9c 10dabf6 9b5b26a c2c65fa d806e9c 10dabf6 a43d707 10dabf6 a43d707 10dabf6 a43d707 10dabf6 a43d707 10dabf6 a43d707 10dabf6 d806e9c 10dabf6 9b5b26a 8c01ffb 6aae614 9902f94 3d27001 9902f94 13d500a 8c01ffb f7aef56 9b5b26a 8c01ffb 861422e 9b5b26a 8c01ffb 8fe992b cbee0bc 8c01ffb 861422e 8fe992b 9b5b26a 8c01ffb |
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#Just havinfg the original template here, in case we need to duplicate
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
from datetime import datetime
import requests
import pytz
import yaml
from tools.final_answer import FinalAnswerTool
from Gradio_UI import GradioUI
# Belo is an example of a tool that does nothing. Amaze us with your creativity !
@tool
def time_left_for_event(event:str, date:str)-> str: #it's import to specify the return type
"""A tool that calculates the time left for a certain event
Args:
event: the event name (e.g., wedding, birthday, trip)
date: the date of the event in YYYY-MM-DD format
Returns:
A string telling how many days, weeks, and months are left
"""
try:
# Parse the input date
event_date = datetime.strptime(date, '%Y-%m-%d')
today = datetime.now()
# Calculate the difference
time_difference = event_date - today
# Calculate days, weeks, and months
days_left = time_difference.days
weeks_left = days_left // 7
months_left = days_left // 30 # Approximate
return f"For your {event}, you have approximately {months_left} months ({weeks_left} weeks or {days_left} days) left"
except ValueError:
return "Error: Please provide the date in YYYY-MM-DD format (e.g., 2024-12-25)"
except Exception as e:
return f"Error calculating time difference: {str(e)}"
final_answer = FinalAnswerTool()
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,
)
#deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
#'https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud'
# Import tool from Hub
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
with open("prompts.yaml", 'r') as stream:
prompt_templates = yaml.safe_load(stream)
agent = CodeAgent(
model=model,
tools=[final_answer, time_left_for_event], ## add your tools here (don't remove final answer)
max_steps=6,
verbosity_level=1,
grammar=None,
planning_interval=None,
name=None,
description=None,
prompt_templates=prompt_templates
)
GradioUI(agent).launch() |