gdms commited on
Commit
0a66b61
·
1 Parent(s): d0cc14b

Tool para vegetais

Browse files
Files changed (2) hide show
  1. agent.py +2 -2
  2. tools.py +44 -1
agent.py CHANGED
@@ -14,7 +14,7 @@ class Agent:
14
 
15
  print("Initializing Agent....")
16
  print("**************************************************************************************")
17
- print('........ Versão: Sem Temperature no supervisor, tratamento da abertura do excel , .....')
18
  print("**************************************************************************************")
19
 
20
  print("--> Audio Agent")
@@ -39,7 +39,7 @@ class Agent:
39
  agents=[self.web_search_agent, self.audio_agent],
40
  tools=[bird_video_count_tool,chess_image_to_fen_tool,chess_fen_get_best_next_move_tool,
41
  get_excel_columns_tool, calculate_excel_sum_by_columns_tool,execute_python_code_tool,
42
- text_inverter_tool, check_table_commutativity_tool],
43
  prompt= SUPERVISOR_PROMPT,
44
  add_handoff_back_messages=True,
45
  output_mode="last_message",
 
14
 
15
  print("Initializing Agent....")
16
  print("**************************************************************************************")
17
+ print('........ Versão: Tool para verificar se é um vegetal .....')
18
  print("**************************************************************************************")
19
 
20
  print("--> Audio Agent")
 
39
  agents=[self.web_search_agent, self.audio_agent],
40
  tools=[bird_video_count_tool,chess_image_to_fen_tool,chess_fen_get_best_next_move_tool,
41
  get_excel_columns_tool, calculate_excel_sum_by_columns_tool,execute_python_code_tool,
42
+ text_inverter_tool, check_table_commutativity_tool, is_vegetable_tool],
43
  prompt= SUPERVISOR_PROMPT,
44
  add_handoff_back_messages=True,
45
  output_mode="last_message",
tools.py CHANGED
@@ -2,6 +2,7 @@ from contextlib import redirect_stderr, redirect_stdout
2
  import io
3
  import json
4
  import os
 
5
  import subprocess
6
  import traceback
7
  from typing import Dict, List, Literal, Optional
@@ -623,4 +624,46 @@ def calculate_excel_sum_by_columns_tool(
623
 
624
  df = pd.read_excel(final_excel_path)
625
  total = df[include_columns].sum().sum() # soma todas as colunas e depois soma os totais
626
- return total
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import io
3
  import json
4
  import os
5
+ import re
6
  import subprocess
7
  import traceback
8
  from typing import Dict, List, Literal, Optional
 
624
 
625
  df = pd.read_excel(final_excel_path)
626
  total = df[include_columns].sum().sum() # soma todas as colunas e depois soma os totais
627
+ return total
628
+
629
+ # Lista curada de vegetais culinários
630
+ VEGETABLES = {
631
+ "lettuce", "carrot", "broccoli", "spinach", "kale", "celery", "cabbage",
632
+ "sweet potato", "radish", "turnip", "cauliflower", "beet", "onion", "garlic",
633
+ "green bean", "pea", "chard", "arugula", "basil", "parsley", "dill", "leek",
634
+ "asparagus", "eggplant", "okra", "pumpkin", "squash", "yam", "collard green",
635
+ "mustard green", "brussels sprout", "scallion", "fennel", "rhubarb", "artichoke",
636
+ "endive", "escarole", "bok choy", "watercress", "turnip green"
637
+ }
638
+
639
+ COMMON_ADJECTIVES = {"fresh", "raw", "organic", "chopped", "sliced", "whole"}
640
+
641
+ def normalize_item(text: str) -> str:
642
+ # Lowercase and remove common adjectives
643
+ words = [w for w in re.findall(r"\w+", text.lower()) if w not in COMMON_ADJECTIVES]
644
+ # Singularização básica
645
+ singular = []
646
+ for word in words:
647
+ if word.endswith("ies"):
648
+ singular.append(word[:-3] + "y")
649
+ elif word.endswith("oes"):
650
+ singular.append(word[:-2])
651
+ elif word.endswith("s") and not word.endswith("ss"):
652
+ singular.append(word[:-1])
653
+ else:
654
+ singular.append(word)
655
+ return " ".join(singular)
656
+
657
+ def is_vegetable_tool(item_name: str) -> bool:
658
+ """
659
+ Verify if an item is a vegetable
660
+
661
+ Args:
662
+ item_name: Name of the item
663
+
664
+ Returns:
665
+ True if is vegetable, otherwise false
666
+ """
667
+ norm = normalize_item(item_name)
668
+ return norm in VEGETABLES
669
+