santimber commited on
Commit
362f128
·
1 Parent(s): cf93357

improed flow

Browse files
Files changed (1) hide show
  1. tools.py +8 -20
tools.py CHANGED
@@ -602,9 +602,9 @@ python_repl_tool = Tool(
602
  # --- New Tools ---
603
 
604
 
605
- def extract_text_from_image(image_path: str) -> str:
606
  try:
607
- image = Image.open(image_path)
608
  text = pytesseract.image_to_string(image)
609
  return f"Extracted text from image:\n\n{text}"
610
  except Exception as e:
@@ -618,7 +618,8 @@ extract_text_from_image_tool = Tool(
618
  )
619
 
620
 
621
- def analyze_csv_file(file_path: str, query: str) -> str:
 
622
  try:
623
  df = pd.read_csv(file_path)
624
  result = f"CSV file loaded with {len(df)} rows and {len(df.columns)} columns.\n"
@@ -632,12 +633,13 @@ def analyze_csv_file(file_path: str, query: str) -> str:
632
 
633
  analyze_csv_file_tool = Tool(
634
  name="analyze_csv_file_tool",
635
- func=analyze_csv_file,
636
  description="Analyze a CSV file using pandas and answer a question about it."
637
  )
638
 
639
 
640
- def analyze_excel_file(file_path: str, query: str) -> str:
 
641
  try:
642
  df = pd.read_excel(file_path)
643
  result = f"Excel file loaded with {len(df)} rows and {len(df.columns)} columns.\n"
@@ -649,24 +651,10 @@ def analyze_excel_file(file_path: str, query: str) -> str:
649
  return f"Error analyzing Excel file: {str(e)}"
650
 
651
 
652
- def analyze_excel_file_simple(file_path: str) -> str:
653
- """Wrapper for analyze_excel_file that uses a default query."""
654
- return analyze_excel_file(file_path, "Analyze this spreadsheet")
655
-
656
-
657
  analyze_excel_file_tool = Tool(
658
  name="analyze_excel_file_tool",
659
  func=analyze_excel_file_simple,
660
  description="Analyze an Excel file using pandas and answer a question about it."
661
  )
662
 
663
- # =========================
664
- # Smart File Download Tool (Consolidated)
665
- # =========================
666
-
667
- # Note: This tool is no longer needed since files are pre-processed
668
- # when questions are fetched. The agent receives file content directly.
669
-
670
- # =========================
671
- # Image and Data Analysis Tools
672
- # =========================
 
602
  # --- New Tools ---
603
 
604
 
605
+ def extract_text_from_image(file_path: str) -> str:
606
  try:
607
+ image = Image.open(file_path)
608
  text = pytesseract.image_to_string(image)
609
  return f"Extracted text from image:\n\n{text}"
610
  except Exception as e:
 
618
  )
619
 
620
 
621
+ def analyze_csv_file_simple(file_path: str) -> str:
622
+ """Analyze a CSV file using pandas."""
623
  try:
624
  df = pd.read_csv(file_path)
625
  result = f"CSV file loaded with {len(df)} rows and {len(df.columns)} columns.\n"
 
633
 
634
  analyze_csv_file_tool = Tool(
635
  name="analyze_csv_file_tool",
636
+ func=analyze_csv_file_simple,
637
  description="Analyze a CSV file using pandas and answer a question about it."
638
  )
639
 
640
 
641
+ def analyze_excel_file_simple(file_path: str) -> str:
642
+ """Analyze an Excel file using pandas."""
643
  try:
644
  df = pd.read_excel(file_path)
645
  result = f"Excel file loaded with {len(df)} rows and {len(df.columns)} columns.\n"
 
651
  return f"Error analyzing Excel file: {str(e)}"
652
 
653
 
 
 
 
 
 
654
  analyze_excel_file_tool = Tool(
655
  name="analyze_excel_file_tool",
656
  func=analyze_excel_file_simple,
657
  description="Analyze an Excel file using pandas and answer a question about it."
658
  )
659
 
660
+ #