Abraham E. Tavarez commited on
Commit
8d6bd5c
·
1 Parent(s): fb4e72c
Files changed (1) hide show
  1. agent.py +54 -0
agent.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from smolagents import HfApiModel, CodeAgent, ToolCallingAgent, DuckDuckGoSearchTool
3
+ from huggingface_hub import login
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv()
7
+ login(os.environ["HF_API_KEY"])
8
+
9
+ # Tools
10
+ tools = [
11
+ DuckDuckGoSearchTool(),
12
+ ]
13
+
14
+ # LLM Model
15
+ model = HfApiModel(
16
+ "Qwen/Qwen2.5-72B-Instruct",
17
+ provider="together",
18
+ max_tokens=4096,
19
+ temperature=0.1
20
+ # token=get_huggingface_token(),
21
+ )
22
+
23
+ # Code Agent
24
+ codeAgent = CodeAgent(
25
+ model=model,
26
+ tools=tools,
27
+ max_steps=10,
28
+ additional_authorized_imports=['pandas', 'numpy'],
29
+ verbosity_level=2
30
+ )
31
+
32
+ codeAgent.logger.console.width=66
33
+
34
+
35
+ # Tool Calling Agent
36
+ llm = HfApiModel(
37
+ "Qwen/Qwen2.5-72B-Instruct",
38
+ temperature=0.6
39
+ )
40
+
41
+ toolCallingAgent = ToolCallingAgent(
42
+ model=model,
43
+ tools=tools,
44
+ max_steps=20,
45
+ )
46
+
47
+ toolCallingAgent.logger.console.width=66
48
+
49
+ question = """
50
+ I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:\n\nmilk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts\n\nI need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list.
51
+ """
52
+
53
+ res = toolCallingAgent.run(question)
54
+ print(res)