Lumintroll commited on
Commit
2d02cb7
·
1 Parent(s): 1dbed11
__pycache__/agent_tools.cpython-310.pyc ADDED
Binary file (3.44 kB). View file
 
agent_tools.py CHANGED
@@ -7,6 +7,30 @@ from dotenv import load_dotenv
7
  import requests
8
  from io import BytesIO
9
  from typing import IO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  #Excel reader
12
  @tool
@@ -68,6 +92,27 @@ def audio_transcription_tool(media_data: IO) -> dict:
68
 
69
  #chess analysis
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  #string reverse
72
  @tool
73
  def string_reverser(text: str) -> str:
@@ -95,6 +140,6 @@ model = AzureOpenAIServerModel(
95
  max_tokens=4096
96
  )
97
 
98
- planning_steps = 3
99
 
100
  agent = CodeAgent(model=model, tools=tools, additional_authorized_imports=additionals, planning_interval=planning_steps)
 
7
  import requests
8
  from io import BytesIO
9
  from typing import IO
10
+ from elevenlabs import ElevenLabs
11
+ from youtube_transcript_api import YouTubeTranscriptApi
12
+ from langchain.docstore.document import Document
13
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
14
+ from langchain_community.retrievers import BM25Retriever
15
+
16
+ #YouTube Transcriber
17
+ @tool
18
+ def youtube_transcriber(video_url: str) -> list:
19
+
20
+ """Takes web address of YouTube video and generates a transcript. Each utterance is a sting in a chronologically ordered list.
21
+ Args:
22
+ url (str): Web address of YouTube video.
23
+ Returns:
24
+ list: Transcript as chronologically ordered list of strings.
25
+ """
26
+ video_id = video_url[video_url.find('v=')+2:]
27
+ ytt_api = YouTubeTranscriptApi()
28
+ raw = ytt_api.fetch(video_id)
29
+ transcript = [snip.text for snip in raw.snippets]
30
+
31
+ return transcript
32
+
33
+
34
 
35
  #Excel reader
36
  @tool
 
92
 
93
  #chess analysis
94
 
95
+ #pdf reader
96
+ @tool
97
+ def text_from_pdf(pdf_file: str) -> str:
98
+ """Reads a pdf file and outputs the text content as a string. PDFs are long, so it is likely best to read the content into a vector store which can be queried.
99
+
100
+ Args:
101
+ pdf_file (str): Filepath or URL of pdf to parse
102
+
103
+ Returns:
104
+ str: Content of pdf as string
105
+ """
106
+
107
+ pdf_file = '/home/rob/Downloads/Reinforcement Learning 2nd Edition.pdf'
108
+
109
+ with pdfplumber.open(pdf_file) as pdf:
110
+ content = ' '.join([page.extract_text() for page in pdf.pages])
111
+ content = content.replace('\n', ' ')
112
+
113
+
114
+ #vector store
115
+
116
  #string reverse
117
  @tool
118
  def string_reverser(text: str) -> str:
 
140
  max_tokens=4096
141
  )
142
 
143
+ planning_steps = 1
144
 
145
  agent = CodeAgent(model=model, tools=tools, additional_authorized_imports=additionals, planning_interval=planning_steps)
app.py CHANGED
@@ -13,7 +13,7 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
  class BasicAgent:
15
  def __init__(self):
16
- self.agent= agent()
17
  print("BasicAgent initialized.")
18
  def __call__(self, question: str) -> str:
19
  print(f"Agent received question (first 50 chars): {question[:50]}...")
 
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
  class BasicAgent:
15
  def __init__(self):
16
+ self.agent= agent
17
  print("BasicAgent initialized.")
18
  def __call__(self, question: str) -> str:
19
  print(f"Agent received question (first 50 chars): {question[:50]}...")
pyproject.toml CHANGED
@@ -9,16 +9,20 @@ dependencies = [
9
  "duckduckgo-search>=8.0.2",
10
  "google-genai>=1.16.1",
11
  "gradio-client>=1.10.1",
12
- "gradio>=5.31.0",
13
  "markdownify>=1.1.0",
14
  "mistralai>=1.7.1",
15
  "openpyxl>=3.1.5",
16
  "pandas>=2.2.3",
17
  "requests>=2.32.3",
18
- "smolagents[openai,transformers]>=1.16.1",
19
  "wikipedia-api>=0.8.1",
20
  "huggingface-hub>=0.32.0",
21
  "elevenlabs>=2.1.0",
22
  "jupyter>=1.1.1",
23
  "transformers>=4.52.3",
 
 
 
 
24
  ]
 
9
  "duckduckgo-search>=8.0.2",
10
  "google-genai>=1.16.1",
11
  "gradio-client>=1.10.1",
12
+ "gradio[oauth]>=5.31.0",
13
  "markdownify>=1.1.0",
14
  "mistralai>=1.7.1",
15
  "openpyxl>=3.1.5",
16
  "pandas>=2.2.3",
17
  "requests>=2.32.3",
18
+ "smolagents[audio,openai,transformers]>=1.16.1",
19
  "wikipedia-api>=0.8.1",
20
  "huggingface-hub>=0.32.0",
21
  "elevenlabs>=2.1.0",
22
  "jupyter>=1.1.1",
23
  "transformers>=4.52.3",
24
+ "pdfplumber>=0.11.6",
25
+ "youtube-transcript-api>=1.0.3",
26
+ "langchain>=0.3.25",
27
+ "langchain-community>=0.3.24",
28
  ]
requirements.txt CHANGED
@@ -1,5 +1,8 @@
1
  accelerate==1.7.0
2
  aiofiles==24.1.0
 
 
 
3
  annotated-types==0.7.0
4
  anyio==4.9.0
5
  argon2-cffi==23.1.0
@@ -7,7 +10,9 @@ argon2-cffi-bindings==21.2.0
7
  arrow==1.3.0
8
  asttokens==3.0.0
9
  async-lru==2.0.5
 
10
  attrs==25.3.0
 
11
  babel==2.17.0
12
  beautifulsoup4==4.13.4
13
  bleach==6.2.0
@@ -17,6 +22,8 @@ cffi==1.17.1
17
  charset-normalizer==3.4.2
18
  click==8.2.1
19
  comm==0.2.2
 
 
20
  debugpy==1.8.14
21
  decorator==5.2.1
22
  defusedxml==0.7.1
@@ -33,26 +40,31 @@ fastjsonschema==2.21.1
33
  ffmpy==0.5.0
34
  filelock==3.18.0
35
  fqdn==1.5.1
 
36
  fsspec==2024.12.0
37
  google-auth==2.40.2
38
  google-genai==1.16.1
39
  gradio==5.31.0
40
  gradio-client==1.10.1
 
41
  groovy==0.1.2
42
  h11==0.16.0
43
  hf-xet==1.1.2
44
  httpcore==1.0.9
45
  httpx==0.28.1
 
46
  huggingface-hub==0.32.0
47
  idna==3.10
48
  ipykernel==6.29.5
49
  ipython==8.36.0
50
  ipywidgets==8.1.7
51
  isoduration==20.11.0
 
52
  jedi==0.19.2
53
  jinja2==3.1.6
54
  jiter==0.10.0
55
  json5==0.12.0
 
56
  jsonpointer==3.0.0
57
  jsonschema==4.24.0
58
  jsonschema-specifications==2025.4.1
@@ -68,15 +80,23 @@ jupyterlab==4.4.3
68
  jupyterlab-pygments==0.3.0
69
  jupyterlab-server==2.27.3
70
  jupyterlab-widgets==3.0.15
 
 
 
 
 
71
  lxml==5.4.0
72
  markdown-it-py==3.0.0
73
  markdownify==1.1.0
74
  markupsafe==3.0.2
 
75
  matplotlib-inline==0.1.7
76
  mdurl==0.1.2
77
  mistralai==1.7.1
78
  mistune==3.1.3
79
  mpmath==1.3.0
 
 
80
  nbclient==0.10.2
81
  nbconvert==7.16.6
82
  nbformat==5.10.4
@@ -107,12 +127,15 @@ packaging==24.2
107
  pandas==2.2.3
108
  pandocfilters==1.5.1
109
  parso==0.8.4
 
 
110
  pexpect==4.9.0
111
  pillow==11.2.1
112
  platformdirs==4.3.8
113
  primp==0.15.0
114
  prometheus-client==0.22.0
115
  prompt-toolkit==3.0.51
 
116
  psutil==7.0.0
117
  ptyprocess==0.7.0
118
  pure-eval==0.2.3
@@ -121,8 +144,10 @@ pyasn1-modules==0.4.2
121
  pycparser==2.22
122
  pydantic==2.11.5
123
  pydantic-core==2.33.2
 
124
  pydub==0.25.1
125
  pygments==2.19.1
 
126
  python-dateutil==2.9.0.post0
127
  python-dotenv==1.1.0
128
  python-json-logger==3.3.0
@@ -133,6 +158,7 @@ pyzmq==26.4.0
133
  referencing==0.36.2
134
  regex==2024.11.6
135
  requests==2.32.3
 
136
  rfc3339-validator==0.1.4
137
  rfc3986-validator==0.1.1
138
  rich==14.0.0
@@ -148,10 +174,13 @@ shellingham==1.5.4
148
  six==1.17.0
149
  smolagents==1.16.1
150
  sniffio==1.3.1
 
151
  soupsieve==2.7
 
152
  stack-data==0.6.3
153
  starlette==0.46.2
154
  sympy==1.14.0
 
155
  terminado==0.18.1
156
  tinycss2==1.4.0
157
  tokenizers==0.21.1
@@ -167,6 +196,7 @@ triton==3.3.0
167
  typer==0.15.3
168
  types-python-dateutil==2.9.0.20250516
169
  typing-extensions==4.13.2
 
170
  typing-inspection==0.4.1
171
  tzdata==2025.2
172
  uri-template==1.3.0
@@ -179,3 +209,6 @@ websocket-client==1.8.0
179
  websockets==15.0.1
180
  widgetsnbextension==4.0.14
181
  wikipedia-api==0.8.1
 
 
 
 
1
  accelerate==1.7.0
2
  aiofiles==24.1.0
3
+ aiohappyeyeballs==2.6.1
4
+ aiohttp==3.12.4
5
+ aiosignal==1.3.2
6
  annotated-types==0.7.0
7
  anyio==4.9.0
8
  argon2-cffi==23.1.0
 
10
  arrow==1.3.0
11
  asttokens==3.0.0
12
  async-lru==2.0.5
13
+ async-timeout==4.0.3
14
  attrs==25.3.0
15
+ authlib==1.6.0
16
  babel==2.17.0
17
  beautifulsoup4==4.13.4
18
  bleach==6.2.0
 
22
  charset-normalizer==3.4.2
23
  click==8.2.1
24
  comm==0.2.2
25
+ cryptography==45.0.3
26
+ dataclasses-json==0.6.7
27
  debugpy==1.8.14
28
  decorator==5.2.1
29
  defusedxml==0.7.1
 
40
  ffmpy==0.5.0
41
  filelock==3.18.0
42
  fqdn==1.5.1
43
+ frozenlist==1.6.0
44
  fsspec==2024.12.0
45
  google-auth==2.40.2
46
  google-genai==1.16.1
47
  gradio==5.31.0
48
  gradio-client==1.10.1
49
+ greenlet==3.2.2
50
  groovy==0.1.2
51
  h11==0.16.0
52
  hf-xet==1.1.2
53
  httpcore==1.0.9
54
  httpx==0.28.1
55
+ httpx-sse==0.4.0
56
  huggingface-hub==0.32.0
57
  idna==3.10
58
  ipykernel==6.29.5
59
  ipython==8.36.0
60
  ipywidgets==8.1.7
61
  isoduration==20.11.0
62
+ itsdangerous==2.2.0
63
  jedi==0.19.2
64
  jinja2==3.1.6
65
  jiter==0.10.0
66
  json5==0.12.0
67
+ jsonpatch==1.33
68
  jsonpointer==3.0.0
69
  jsonschema==4.24.0
70
  jsonschema-specifications==2025.4.1
 
80
  jupyterlab-pygments==0.3.0
81
  jupyterlab-server==2.27.3
82
  jupyterlab-widgets==3.0.15
83
+ langchain==0.3.25
84
+ langchain-community==0.3.24
85
+ langchain-core==0.3.63
86
+ langchain-text-splitters==0.3.8
87
+ langsmith==0.3.43
88
  lxml==5.4.0
89
  markdown-it-py==3.0.0
90
  markdownify==1.1.0
91
  markupsafe==3.0.2
92
+ marshmallow==3.26.1
93
  matplotlib-inline==0.1.7
94
  mdurl==0.1.2
95
  mistralai==1.7.1
96
  mistune==3.1.3
97
  mpmath==1.3.0
98
+ multidict==6.4.4
99
+ mypy-extensions==1.1.0
100
  nbclient==0.10.2
101
  nbconvert==7.16.6
102
  nbformat==5.10.4
 
127
  pandas==2.2.3
128
  pandocfilters==1.5.1
129
  parso==0.8.4
130
+ pdfminer-six==20250327
131
+ pdfplumber==0.11.6
132
  pexpect==4.9.0
133
  pillow==11.2.1
134
  platformdirs==4.3.8
135
  primp==0.15.0
136
  prometheus-client==0.22.0
137
  prompt-toolkit==3.0.51
138
+ propcache==0.3.1
139
  psutil==7.0.0
140
  ptyprocess==0.7.0
141
  pure-eval==0.2.3
 
144
  pycparser==2.22
145
  pydantic==2.11.5
146
  pydantic-core==2.33.2
147
+ pydantic-settings==2.9.1
148
  pydub==0.25.1
149
  pygments==2.19.1
150
+ pypdfium2==4.30.1
151
  python-dateutil==2.9.0.post0
152
  python-dotenv==1.1.0
153
  python-json-logger==3.3.0
 
158
  referencing==0.36.2
159
  regex==2024.11.6
160
  requests==2.32.3
161
+ requests-toolbelt==1.0.0
162
  rfc3339-validator==0.1.4
163
  rfc3986-validator==0.1.1
164
  rich==14.0.0
 
174
  six==1.17.0
175
  smolagents==1.16.1
176
  sniffio==1.3.1
177
+ soundfile==0.13.1
178
  soupsieve==2.7
179
+ sqlalchemy==2.0.41
180
  stack-data==0.6.3
181
  starlette==0.46.2
182
  sympy==1.14.0
183
+ tenacity==9.1.2
184
  terminado==0.18.1
185
  tinycss2==1.4.0
186
  tokenizers==0.21.1
 
196
  typer==0.15.3
197
  types-python-dateutil==2.9.0.20250516
198
  typing-extensions==4.13.2
199
+ typing-inspect==0.9.0
200
  typing-inspection==0.4.1
201
  tzdata==2025.2
202
  uri-template==1.3.0
 
209
  websockets==15.0.1
210
  widgetsnbextension==4.0.14
211
  wikipedia-api==0.8.1
212
+ yarl==1.20.0
213
+ youtube-transcript-api==1.0.3
214
+ zstandard==0.23.0
uv.lock CHANGED
The diff for this file is too large to render. See raw diff