Fixed tool definition
Browse files
agent.py
CHANGED
@@ -62,26 +62,23 @@ arxiv_tool = Tool.from_function(
|
|
62 |
|
63 |
# Audio Transcription
|
64 |
whisper_model = whisper.load_model("base")
|
65 |
-
|
66 |
def transcribe_audio(file_path: str) -> str:
|
67 |
"""Transcribe audio files using Whisper."""
|
68 |
return whisper_model.transcribe(file_path)["text"]
|
69 |
|
70 |
# YouTube Transcript
|
71 |
-
@Tool
|
72 |
def get_youtube_transcript(video_id: str) -> str:
|
73 |
"""Extract transcript from YouTube video using video ID."""
|
74 |
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
75 |
return " ".join(entry["text"] for entry in transcript)
|
76 |
|
77 |
# OCR Tool
|
78 |
-
@Tool
|
79 |
def extract_text_from_image(image_path: str) -> str:
|
80 |
"""Extract text from an image file."""
|
81 |
return pytesseract.image_to_string(Image.open(image_path))
|
82 |
|
83 |
# Code Execution
|
84 |
-
@Tool
|
85 |
def execute_python_code(code: str) -> str:
|
86 |
"""Execute a Python script and return the output."""
|
87 |
try:
|
@@ -92,7 +89,6 @@ def execute_python_code(code: str) -> str:
|
|
92 |
return f"Error: {e}"
|
93 |
|
94 |
# Excel Parsing
|
95 |
-
@Tool
|
96 |
def total_sales_from_excel(file_path: str) -> str:
|
97 |
"""Compute total food sales from an Excel file."""
|
98 |
df = pd.read_excel(file_path)
|
|
|
62 |
|
63 |
# Audio Transcription
|
64 |
whisper_model = whisper.load_model("base")
|
65 |
+
|
66 |
def transcribe_audio(file_path: str) -> str:
|
67 |
"""Transcribe audio files using Whisper."""
|
68 |
return whisper_model.transcribe(file_path)["text"]
|
69 |
|
70 |
# YouTube Transcript
|
|
|
71 |
def get_youtube_transcript(video_id: str) -> str:
|
72 |
"""Extract transcript from YouTube video using video ID."""
|
73 |
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
74 |
return " ".join(entry["text"] for entry in transcript)
|
75 |
|
76 |
# OCR Tool
|
|
|
77 |
def extract_text_from_image(image_path: str) -> str:
|
78 |
"""Extract text from an image file."""
|
79 |
return pytesseract.image_to_string(Image.open(image_path))
|
80 |
|
81 |
# Code Execution
|
|
|
82 |
def execute_python_code(code: str) -> str:
|
83 |
"""Execute a Python script and return the output."""
|
84 |
try:
|
|
|
89 |
return f"Error: {e}"
|
90 |
|
91 |
# Excel Parsing
|
|
|
92 |
def total_sales_from_excel(file_path: str) -> str:
|
93 |
"""Compute total food sales from an Excel file."""
|
94 |
df = pd.read_excel(file_path)
|