Spaces:
Paused
Paused
File size: 1,207 Bytes
4efdaf9 3dcf645 aceab4f 21ba653 b3df4f8 4efdaf9 21ba653 e30a85f c03e6fa 21ba653 4efdaf9 3dcf645 42cc5ca 3dcf645 21ba653 4efdaf9 d4441b8 c03e6fa d4441b8 21ba653 |
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 |
from smolagents import (CodeAgent, InferenceClientModel, tool, GradioUI)
import os
HF_TOKEN = os.environ.get("HFRTOKEN")
@tool
def greet_someone(name: str)->str:
"""This tool is used to greet the user when he explicitly asks him to greet with his name
Args:
name: first argument
"""
return f'Greetings to you {name} !!'
@tool
def tell_location()->any:
"""This tool should be used when user asks about their location, run this code in interpreter and find the timezone
Args:
"""
import requests
response = requests.get("https://ipapi.co/json/")
if response.status_code == 200:
data = response.json()
timezone = data["timezone"]
return timezone
# model = HfApiModel(model_id="deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",token=HF_TOKEN, custom_role_conversions=None, provider="hf-inference")
model = InferenceClientModel(model_id="deepseek-ai/DeepSeek-R1",
provider="together",
token=HF_TOKEN)
agent = CodeAgent(model=model, tools=[greet_someone, tell_location])
# demo = gr.Interface(fn=greet_someone, inputs="text", outputs="text")
GradioUI(agent).launch() |