sampsong commited on
Commit
3fd1fbf
·
1 Parent(s): 72908c3

add youtube transcript

Browse files
Files changed (1) hide show
  1. Tools/tools.py +25 -6
Tools/tools.py CHANGED
@@ -5,6 +5,8 @@ from langchain_community.vectorstores import SupabaseVectorStore
5
  from langchain_core.messages import SystemMessage, HumanMessage
6
  from langchain_core.tools import tool
7
  from langchain.tools.retriever import create_retriever_tool
 
 
8
 
9
  @tool
10
  def add(a: int, b:int) -> int:
@@ -49,13 +51,13 @@ def divide(a: int, b: int) -> int:
49
  return a / b
50
 
51
  @tool
52
- def remainder(a: int, b: int) -> int:
53
- """ left over of division
54
- args:
55
- a: first integer
56
- b: second integer
 
57
  """
58
- print ("remainder")
59
  return a % b
60
 
61
  @tool
@@ -109,6 +111,23 @@ def webSearch(searchQuery:str) -> str:
109
  )
110
  return {"web_search": formatted_results}
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
 
114
 
 
5
  from langchain_core.messages import SystemMessage, HumanMessage
6
  from langchain_core.tools import tool
7
  from langchain.tools.retriever import create_retriever_tool
8
+ from langchain_community.document_loaders import YoutubeLoader
9
+ from langchain_community.document_loaders.youtube import TranscriptFormat
10
 
11
  @tool
12
  def add(a: int, b:int) -> int:
 
51
  return a / b
52
 
53
  @tool
54
+ def modulus(a: int, b: int) -> int:
55
+ """
56
+ Get the modulus of two numbers.
57
+ Args:
58
+ a (int): the first number
59
+ b (int): the second number
60
  """
 
61
  return a % b
62
 
63
  @tool
 
111
  )
112
  return {"web_search": formatted_results}
113
 
114
+ @tool
115
+ def youtubeTranscript(youtubeURL:str) -> str:
116
+ """
117
+ obtain youtube transcript by passing in the youtube url
118
+
119
+ args:
120
+ youtubeURL: youtube url to pull out the transcript
121
+ """
122
+ print("youtube_transcript")
123
+ loader = YoutubeLoader.from_youtube_url(
124
+ youtubeURL,
125
+ add_video_info=True,
126
+ transcript_format=TranscriptFormat.CHUNKS,
127
+ chunk_size_seconds=30,
128
+ )
129
+ formatted_results = "\n\n".join(map(repr, loader.load()))
130
+ return {"Youtube transcript":formatted_results}
131
 
132
 
133