Spaces:
Runtime error
Runtime error
| from smolagents import CodeAgent | |
| from smolagents import HfApiModel | |
| from smolagents import tool | |
| #from smolagents import DuckDuckGoSearchTool | |
| import os | |
| import gradio as gr | |
| from datasets import load_dataset | |
| dataset = load_dataset("bprateek/amazon_product_description", revision="main", split="train", token=os.getenv('Testing')) | |
| def get_price_tool(arg1:str)-> float: | |
| """This is a tool which look on a dataset and filter for products and their various atteibutes like prices description | |
| Args: | |
| arg1: the category of product | |
| """ | |
| arg1 = arg1.lower() | |
| responses = dataset.filter(lambda example: arg1 in example['Product Name'].lower()) | |
| #filter_dataset_min = filter_dataset['Selling Price'].min() | |
| #filter_dataset_max = filter_dataset['Selling Price'].min() | |
| return responses | |
| #Agent Example | |
| model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct", token=os.getenv('Testing')) | |
| agent = CodeAgent(tools=[get_price_tool], model=model) | |
| agent.run("Can you dispay prices of all Electronics products in a table") |