Spaces:
Paused
Paused
| from smolagents import (CodeAgent, InferenceClientModel, tool, GradioUI) | |
| import os | |
| HF_TOKEN = os.environ.get("HFRTOKEN") | |
| 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} !!' | |
| 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() |