Spaces:
Sleeping
Sleeping
Upload tools.py
Browse files- src/tools.py +20 -1
src/tools.py
CHANGED
|
@@ -2,7 +2,7 @@ import json
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
from langchain_community.document_loaders import \
|
| 5 |
-
AssemblyAIAudioTranscriptLoader, WikipediaLoader
|
| 6 |
from langchain_core.tools import tool
|
| 7 |
|
| 8 |
|
|
@@ -106,3 +106,22 @@ def audio_transcript(
|
|
| 106 |
)
|
| 107 |
docs = loader.load()
|
| 108 |
return docs[0].page_content if docs else "No transcription available."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
from langchain_community.document_loaders import \
|
| 5 |
+
AssemblyAIAudioTranscriptLoader, WikipediaLoader, YoutubeLoader
|
| 6 |
from langchain_core.tools import tool
|
| 7 |
|
| 8 |
|
|
|
|
| 106 |
)
|
| 107 |
docs = loader.load()
|
| 108 |
return docs[0].page_content if docs else "No transcription available."
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
@tool
|
| 112 |
+
def youtube_transcript(
|
| 113 |
+
video_url: str
|
| 114 |
+
) -> str:
|
| 115 |
+
"""
|
| 116 |
+
Get the transcript of a YouTube video.
|
| 117 |
+
|
| 118 |
+
Args:
|
| 119 |
+
video_url: The URL of the YouTube video.
|
| 120 |
+
"""
|
| 121 |
+
loader = YoutubeLoader(
|
| 122 |
+
url=video_url,
|
| 123 |
+
language="en",
|
| 124 |
+
add_video_info=False
|
| 125 |
+
)
|
| 126 |
+
docs = loader.load()
|
| 127 |
+
return docs[0].page_content if docs else "No transcript available."
|