rahulnamdev commited on
Commit
de7b4bb
·
verified ·
1 Parent(s): 653a2eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -6
app.py CHANGED
@@ -2,15 +2,32 @@ from smolagents import CodeAgent
2
  from smolagents import HfApiModel
3
  #from smolagents import DuckDuckGoSearchTool
4
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  #Agent Example
7
- #model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct", token=os.getenv('Testing'))
8
- #agent = CodeAgent(tools=[], model=model)
9
- #agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
10
 
11
  # Access HF Hub
12
- from huggingface_hub import list_models
13
 
14
- for model in list_models(limit=10, sort="downloads", direction=-1):
15
- print(model.id, model.downloads)
16
 
 
2
  from smolagents import HfApiModel
3
  #from smolagents import DuckDuckGoSearchTool
4
  import os
5
+ from datasets import load_dataset
6
+ dataset = load_dataset("ckandemir/amazon-products1", revision="main" )
7
+
8
+
9
+ @tool
10
+ def predict_price_tool(arg1:str)-> float: #it's import to specify the return type
11
+ #Keep this format for the description / args / args description but feel free to modify the tool
12
+ """This is a tool which look on a dataset as defined by user input and give you a price
13
+ Args:
14
+ arg1: the category of product
15
+ """
16
+ filter_dataset = dataset['Category' == arg1]
17
+ filter_dataset_min = filter_dataset['Selling Price'].min()
18
+ filter_dataset_max = filter_dataset['Selling Price'].min()
19
+
20
+ return (filter_dataset_min + filter_dataset_max )/2
21
+
22
 
23
  #Agent Example
24
+ model = HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct", token=os.getenv('Testing'))
25
+ agent = CodeAgent(tools=[predict_price_tool], model=model)
26
+ agent.run("Get price quoatition for catageory = Toys & Games | Arts & Crafts | Craft Kits | Paper Craft")
27
 
28
  # Access HF Hub
29
+ #from huggingface_hub import list_models
30
 
31
+ #for model in list_models(limit=10, sort="downloads", direction=-1):
32
+ # print(model.id, model.downloads)
33