Abraham E. Tavarez commited on
Commit
342da0c
·
1 Parent(s): 8d6bd5c

code agent created and added to app

Browse files
Files changed (2) hide show
  1. agent.py +8 -6
  2. app.py +6 -4
agent.py CHANGED
@@ -2,6 +2,7 @@ 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"])
@@ -11,6 +12,8 @@ tools = [
11
  DuckDuckGoSearchTool(),
12
  ]
13
 
 
 
14
  # LLM Model
15
  model = HfApiModel(
16
  "Qwen/Qwen2.5-72B-Instruct",
@@ -31,6 +34,9 @@ codeAgent = CodeAgent(
31
 
32
  codeAgent.logger.console.width=66
33
 
 
 
 
34
 
35
  # Tool Calling Agent
36
  llm = HfApiModel(
@@ -46,9 +52,5 @@ toolCallingAgent = ToolCallingAgent(
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)
 
2
  from smolagents import HfApiModel, CodeAgent, ToolCallingAgent, DuckDuckGoSearchTool
3
  from huggingface_hub import login
4
  from dotenv import load_dotenv
5
+ from sample_questions import QUESTIONS
6
 
7
  load_dotenv()
8
  login(os.environ["HF_API_KEY"])
 
12
  DuckDuckGoSearchTool(),
13
  ]
14
 
15
+ question = QUESTIONS[0];
16
+
17
  # LLM Model
18
  model = HfApiModel(
19
  "Qwen/Qwen2.5-72B-Instruct",
 
34
 
35
  codeAgent.logger.console.width=66
36
 
37
+ res = codeAgent.run(question)
38
+ print(res)
39
+
40
 
41
  # Tool Calling Agent
42
  llm = HfApiModel(
 
52
 
53
  toolCallingAgent.logger.console.width=66
54
 
55
+ # res = toolCallingAgent.run(question)
56
+ # print(res)
 
 
 
 
app.py CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
 
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
@@ -14,10 +15,11 @@ class BasicAgent:
14
  def __init__(self):
15
  print("BasicAgent initialized.")
16
  def __call__(self, question: str) -> str:
17
- print(f"Agent received question (first 50 chars): {question[:50]}...")
18
- fixed_answer = "This is a default answer."
19
- print(f"Agent returning fixed answer: {fixed_answer}")
20
- return fixed_answer
 
21
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from agent import codeAgent
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
 
15
  def __init__(self):
16
  print("BasicAgent initialized.")
17
  def __call__(self, question: str) -> str:
18
+ return codeAgent.run(question)
19
+ # print(f"Agent received question (first 50 chars): {question[:50]}...")
20
+ # fixed_answer = "This is a default answer."
21
+ # print(f"Agent returning fixed answer: {fixed_answer}")
22
+ # return fixed_answer
23
 
24
  def run_and_submit_all( profile: gr.OAuthProfile | None):
25
  """