GattoNero commited on
Commit
a6a4d07
·
verified ·
1 Parent(s): 31887b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -28
app.py CHANGED
@@ -81,6 +81,12 @@ class BasicAgent:
81
  description="Returns the final answer to the user as a string."
82
  )
83
 
 
 
 
 
 
 
84
 
85
  # Registra il tool
86
  #Settings.tools = [ingredient_tool]
@@ -92,7 +98,7 @@ class BasicAgent:
92
  )
93
 
94
  # search_tool,
95
- self.agent = OpenAIAgent.from_tools([ingredient_tool, log_thought_tool, search_tool, sum_list_tool], llm=llm, verbose=True)
96
 
97
  # Client OpenAI per chiamate esterne (immagini/audio)
98
 
@@ -477,39 +483,15 @@ def create_mock_questions():
477
  'Level': '1',
478
  'file_name': ''
479
  },
480
- {'task_id': '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3',
481
- 'question': 'Hi, I\'m making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I\'m not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can\'t quite make out what she\'s saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I\'ve attached the recipe as Strawberry pie.mp3.\n\nIn your response, please only list the ingredients, not any measurements. So if the recipe calls for "a pinch of salt" or "two cups of ripe strawberries" the ingredients on the list would be "salt" and "ripe strawberries".\n\nPlease format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.',
482
- 'Level': '1',
483
- 'file_name': '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3'
484
- }
485
-
486
-
487
  {
488
  "task_id": "5a0c1adf-205e-4841-a666-7c3ef95def9d",
489
  "question": "What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?",
490
  "Level": "1",
491
  "file_name": ""
492
  }
493
- {
494
- "task_id":"f918266a-b3e0-4914-865d-4faa564f1aef",
495
- "question":"What is the final numeric output from the attached Python code?",
496
- "Level":"1",
497
- "file_name":"f918266a-b3e0-4914-865d-4faa564f1aef.py"
498
- }
499
-
500
-
501
- {
502
- "task_id":"7bd855d8-463d-4ed5-93ca-5fe35145f733",
503
- "question":"The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.",
504
- "Level":"1",
505
- "file_name":"7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx"
506
- }
507
-
508
- '''
509
-
510
-
511
- return [
512
- {
513
  'task_id': '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3',
514
  'question': 'Hi, I\'m making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I\'m not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can\'t quite make out what she\'s saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I\'ve attached the recipe as Strawberry pie.mp3.\n\nIn your response, please only list the ingredients, not any measurements. So if the recipe calls for "a pinch of salt" or "two cups of ripe strawberries" the ingredients on the list would be "salt" and "ripe strawberries".\n\nPlease format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.',
515
  'Level': '1',
@@ -545,6 +527,20 @@ def create_mock_questions():
545
  "Level":"1",
546
  "file_name":""
547
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
  ]
549
 
550
 
@@ -610,6 +606,10 @@ def sum_list(numbers: list[float]) -> float:
610
  print_coso(f"[TOOL] sum_list called with: {numbers}")
611
  print_coso(f"[TOOL] Result: {total}")
612
  return total
 
 
 
 
613
 
614
  def final_answer_tool(answer: str) -> str:
615
  print_coso(f"Final answer: {answer}")
 
81
  description="Returns the final answer to the user as a string."
82
  )
83
 
84
+ is_food_tool = FunctionTool.from_defaults(
85
+ name="is_food",
86
+ fn=is_food,
87
+ description="Returns True if the given item is a food item (e.g., burgers, salads, fries, etc.), otherwise False."
88
+ )
89
+
90
 
91
  # Registra il tool
92
  #Settings.tools = [ingredient_tool]
 
98
  )
99
 
100
  # search_tool,
101
+ self.agent = OpenAIAgent.from_tools([ingredient_tool, log_thought_tool, search_tool, sum_list_tool, is_food_tool], llm=llm, verbose=True)
102
 
103
  # Client OpenAI per chiamate esterne (immagini/audio)
104
 
 
483
  'Level': '1',
484
  'file_name': ''
485
  },
486
+
 
 
 
 
 
 
487
  {
488
  "task_id": "5a0c1adf-205e-4841-a666-7c3ef95def9d",
489
  "question": "What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?",
490
  "Level": "1",
491
  "file_name": ""
492
  }
493
+ esatte
494
+ {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
495
  'task_id': '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3',
496
  'question': 'Hi, I\'m making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I\'m not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can\'t quite make out what she\'s saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I\'ve attached the recipe as Strawberry pie.mp3.\n\nIn your response, please only list the ingredients, not any measurements. So if the recipe calls for "a pinch of salt" or "two cups of ripe strawberries" the ingredients on the list would be "salt" and "ripe strawberries".\n\nPlease format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.',
497
  'Level': '1',
 
527
  "Level":"1",
528
  "file_name":""
529
  }
530
+
531
+
532
+
533
+
534
+ '''
535
+
536
+
537
+ return [
538
+ {
539
+ "task_id":"7bd855d8-463d-4ed5-93ca-5fe35145f733",
540
+ "question":"The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.",
541
+ "Level":"1",
542
+ "file_name":"7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx"
543
+ }
544
  ]
545
 
546
 
 
606
  print_coso(f"[TOOL] sum_list called with: {numbers}")
607
  print_coso(f"[TOOL] Result: {total}")
608
  return total
609
+
610
+ def is_food(item_name: str) -> bool:
611
+ food_items = ["burgers", "hot dogs", "salads", "fries", "ice cream"]
612
+ return item_name.lower() in food_items
613
 
614
  def final_answer_tool(answer: str) -> str:
615
  print_coso(f"Final answer: {answer}")