WeByT3 commited on
Commit
4ea8b91
·
verified ·
1 Parent(s): 8dae428

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +17 -0
tools.py CHANGED
@@ -2,6 +2,7 @@ from langchain_core.tools import tool
2
  from langchain_community.tools.tavily_search import TavilySearchResults
3
  from youtube_transcript_api import YouTubeTranscriptApi
4
  from langchain_community.document_loaders import WikipediaLoader
 
5
 
6
  @tool
7
  def add(a: int, b: int) -> int:
@@ -49,6 +50,22 @@ def divide(a: int, b: int) -> int:
49
  raise ValueError("Cannot divide by zero.")
50
  return a / b
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  @tool
53
  def web_search(query: str) -> str:
54
  """Search Tavily for a query and return maximum 3 results.
 
2
  from langchain_community.tools.tavily_search import TavilySearchResults
3
  from youtube_transcript_api import YouTubeTranscriptApi
4
  from langchain_community.document_loaders import WikipediaLoader
5
+ import pandas as pd
6
 
7
  @tool
8
  def add(a: int, b: int) -> int:
 
50
  raise ValueError("Cannot divide by zero.")
51
  return a / b
52
 
53
+ @tool
54
+ def read_excel_summary(file_path: str) -> str:
55
+ """
56
+ Reads an Excel file and returns basic summary statistics, column names, and row count.
57
+ """
58
+ try:
59
+ df = pd.read_excel(file_path, engine="openpyxl")
60
+ info = {
61
+ "columns": df.columns.tolist(),
62
+ "num_rows": len(df),
63
+ "summary": df.describe(include='all').to_dict()
64
+ }
65
+ return str(info)
66
+ except Exception as e:
67
+ return f"Error reading Excel file: {str(e)}"
68
+
69
  @tool
70
  def web_search(query: str) -> str:
71
  """Search Tavily for a query and return maximum 3 results.