Spaces:
Sleeping
Sleeping
Update tools.py
Browse files
tools.py
CHANGED
|
@@ -9,12 +9,9 @@ import imageio
|
|
| 9 |
|
| 10 |
from PIL import Image
|
| 11 |
from dotenv import load_dotenv
|
|
|
|
| 12 |
import whisper
|
| 13 |
|
| 14 |
-
def tool(func):
|
| 15 |
-
func.is_tool = True
|
| 16 |
-
return func
|
| 17 |
-
|
| 18 |
load_dotenv()
|
| 19 |
|
| 20 |
@tool
|
|
@@ -37,7 +34,7 @@ def youtube_frames_to_images(url: str, sample_interval_seconds: int = 5) -> List
|
|
| 37 |
'force_ipv4': True,
|
| 38 |
}
|
| 39 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 40 |
-
ydl.extract_info(url, download=True)
|
| 41 |
|
| 42 |
video_path = next((os.path.join(tmpdir, f) for f in os.listdir(tmpdir) if f.endswith('.mp4')), None)
|
| 43 |
reader = imageio.get_reader(video_path)
|
|
@@ -116,4 +113,22 @@ def youtube_transcribe(url: str) -> str:
|
|
| 116 |
|
| 117 |
@tool
|
| 118 |
def transcribe_audio(audio_file_path: str) -> str:
|
| 119 |
-
return whisper.load_model("small").transcribe(audio_file_path)['text']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
from PIL import Image
|
| 11 |
from dotenv import load_dotenv
|
| 12 |
+
from gaia_benchmark.tools import tool
|
| 13 |
import whisper
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
load_dotenv()
|
| 16 |
|
| 17 |
@tool
|
|
|
|
| 34 |
'force_ipv4': True,
|
| 35 |
}
|
| 36 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 37 |
+
info = ydl.extract_info(url, download=True)
|
| 38 |
|
| 39 |
video_path = next((os.path.join(tmpdir, f) for f in os.listdir(tmpdir) if f.endswith('.mp4')), None)
|
| 40 |
reader = imageio.get_reader(video_path)
|
|
|
|
| 113 |
|
| 114 |
@tool
|
| 115 |
def transcribe_audio(audio_file_path: str) -> str:
|
| 116 |
+
return whisper.load_model("small").transcribe(audio_file_path)['text']
|
| 117 |
+
|
| 118 |
+
# 🔧 Stub Tools for Mistral Compatibility
|
| 119 |
+
|
| 120 |
+
@tool
|
| 121 |
+
def web_search(query: str) -> str:
|
| 122 |
+
return f"(Stub) Web search results for: {query}"
|
| 123 |
+
|
| 124 |
+
@tool
|
| 125 |
+
def wikipedia_search(topic: str) -> str:
|
| 126 |
+
return f"(Stub) Wikipedia summary for: {topic}"
|
| 127 |
+
|
| 128 |
+
@tool
|
| 129 |
+
def visit_webpage(url: str) -> str:
|
| 130 |
+
return f"(Stub) Visited webpage at: {url}"
|
| 131 |
+
|
| 132 |
+
@tool
|
| 133 |
+
def final_answer(response: str) -> str:
|
| 134 |
+
return f"(Stub) Final answer: {response}"
|