File size: 1,491 Bytes
c31e5ec
58b19e1
a30af76
c31e5ec
6df506c
de7b4bb
5edd3c0
de7b4bb
 
 
a0dc9ac
de7b4bb
a0dc9ac
de7b4bb
 
 
d5b66b5
87ffc1b
ea6ee61
77c78bd
d5b66b5
89cf407
 
82b731c
89cf407
de7b4bb
d3dd41c
58b19e1
de7b4bb
a0dc9ac
 
58b19e1
 
de7b4bb
9e97df9
de7b4bb
 
52fda4a
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
from smolagents import CodeAgent  
from smolagents import HfApiModel
from smolagents import tool
#from smolagents import DuckDuckGoSearchTool
import os
from datasets import load_dataset
dataset = load_dataset("bprateek/amazon_product_description", revision="main", split="train", token=os.getenv('Testing'))


@tool
def get_price_tool(arg1:str)-> float: #it's import to specify the return type
    #Keep this format for the description / args / args description but feel free to modify the tool
    """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
    """
    #filter_dataset = set(dataset['train']['Category'])
    print(type(dataset), type(dataset['Product Name']))
    
    responses = dataset[dataset['Product Name'].str.contains(arg1)]
    print(responses)
    #filter_dataset_min = filter_dataset['Selling Price'].min()
    #filter_dataset_max = filter_dataset['Selling Price'].min()
    return responses
    #return (filter_dataset_min + filter_dataset_max )/2


#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")

# Access HF Hub 
#from huggingface_hub import list_models

#for model in list_models(limit=10, sort="downloads", direction=-1):
#   print(model.id, model.downloads)