Spaces:
Runtime error
Runtime error
Updated tools
Browse files
agent.py
CHANGED
|
@@ -5,7 +5,6 @@ import json
|
|
| 5 |
import pandas as pd
|
| 6 |
from smolagents import (
|
| 7 |
CodeAgent,
|
| 8 |
-
YouTubeSearchTool,
|
| 9 |
LiteLLMModel,
|
| 10 |
DuckDuckGoSearchTool,
|
| 11 |
FinalAnswerTool,
|
|
@@ -75,6 +74,24 @@ def read_python_file(file_name: str) -> str:
|
|
| 75 |
base_path = "data/question_files"
|
| 76 |
with open(os.path.join(base_path, file_name), "r") as f:
|
| 77 |
return f.read()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
@tool
|
| 80 |
def read_excel_file(file_name: str) -> str:
|
|
@@ -106,8 +123,11 @@ agent = CodeAgent(
|
|
| 106 |
WikipediaSearchTool(),
|
| 107 |
arxiv_search,
|
| 108 |
FinalAnswerTool(),
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
| 111 |
],
|
| 112 |
planning_interval=3,
|
| 113 |
max_steps=10,
|
|
|
|
| 5 |
import pandas as pd
|
| 6 |
from smolagents import (
|
| 7 |
CodeAgent,
|
|
|
|
| 8 |
LiteLLMModel,
|
| 9 |
DuckDuckGoSearchTool,
|
| 10 |
FinalAnswerTool,
|
|
|
|
| 74 |
base_path = "data/question_files"
|
| 75 |
with open(os.path.join(base_path, file_name), "r") as f:
|
| 76 |
return f.read()
|
| 77 |
+
@tool
|
| 78 |
+
def get_youtube_transcript(video_id:str)-> str:
|
| 79 |
+
"""
|
| 80 |
+
Retrieves the transcript for a given YouTube video.
|
| 81 |
+
|
| 82 |
+
Args:
|
| 83 |
+
video_id: The ID of the YouTube video.
|
| 84 |
+
|
| 85 |
+
Returns:
|
| 86 |
+
A list of dictionaries, where each dictionary represents a transcript segment
|
| 87 |
+
and contains 'text' and 'start' keys, or None if no transcript is found.
|
| 88 |
+
"""
|
| 89 |
+
try:
|
| 90 |
+
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
| 91 |
+
return transcript
|
| 92 |
+
except Exception as e:
|
| 93 |
+
# print(f"Error getting transcript: {e}")
|
| 94 |
+
return f"Error getting transcript: {e}"
|
| 95 |
|
| 96 |
@tool
|
| 97 |
def read_excel_file(file_name: str) -> str:
|
|
|
|
| 123 |
WikipediaSearchTool(),
|
| 124 |
arxiv_search,
|
| 125 |
FinalAnswerTool(),
|
| 126 |
+
extract_text_from_image.
|
| 127 |
+
read_excel_file,
|
| 128 |
+
read_python_file,
|
| 129 |
+
get_youtube_transcript,
|
| 130 |
+
|
| 131 |
],
|
| 132 |
planning_interval=3,
|
| 133 |
max_steps=10,
|