Spaces:
Running
Running
Update agent.py
Browse files
agent.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from smolagents import CodeAgent, LiteLLMModel, tool, load_tool # DuckDuckGoSearchTool, WikipediaSearchTool, HfApiModel, OpenAIServerModel
|
2 |
from langchain_community.tools.tavily_search import TavilySearchResults
|
3 |
from langchain_community.document_loaders import WikipediaLoader
|
|
|
4 |
import asyncio
|
5 |
import os
|
6 |
import yaml
|
@@ -101,6 +102,18 @@ def ImageAnalysisTool(image_path: str) -> str:
|
|
101 |
return f"The image description: '{response}'"
|
102 |
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
#@tool
|
105 |
#class LocalFileAudioTool:
|
106 |
# """Tool for transcribing audio files"""
|
@@ -134,6 +147,7 @@ class MagAgent:
|
|
134 |
tools=[
|
135 |
wiki_search,
|
136 |
web_search,
|
|
|
137 |
# GoogleSearchTool,
|
138 |
# DuckDuckGoSearchTool(),
|
139 |
# WikipediaSearchTool(),
|
|
|
1 |
from smolagents import CodeAgent, LiteLLMModel, tool, load_tool # DuckDuckGoSearchTool, WikipediaSearchTool, HfApiModel, OpenAIServerModel
|
2 |
from langchain_community.tools.tavily_search import TavilySearchResults
|
3 |
from langchain_community.document_loaders import WikipediaLoader
|
4 |
+
from youtube_transcript_api import YouTubeTranscriptApi
|
5 |
import asyncio
|
6 |
import os
|
7 |
import yaml
|
|
|
102 |
return f"The image description: '{response}'"
|
103 |
|
104 |
|
105 |
+
@tool
|
106 |
+
def youtube_transcript(url: str) -> str:
|
107 |
+
"""
|
108 |
+
Get transcript of YouTube video.
|
109 |
+
Args:
|
110 |
+
url: YouTube video url in ""
|
111 |
+
"""
|
112 |
+
video_id = url.partition("https://www.youtube.com/watch?v=")[2]
|
113 |
+
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
114 |
+
transcript_text = " ".join([item["text"] for item in transcript])
|
115 |
+
return {"youtube_transcript": transcript_text}
|
116 |
+
|
117 |
#@tool
|
118 |
#class LocalFileAudioTool:
|
119 |
# """Tool for transcribing audio files"""
|
|
|
147 |
tools=[
|
148 |
wiki_search,
|
149 |
web_search,
|
150 |
+
youtube_transcript,
|
151 |
# GoogleSearchTool,
|
152 |
# DuckDuckGoSearchTool(),
|
153 |
# WikipediaSearchTool(),
|