bstraehle commited on
Commit
20a8abb
·
verified ·
1 Parent(s): de67e83

Upload ai_tools.py

Browse files
Files changed (1) hide show
  1. agents/tools/ai_tools.py +17 -17
agents/tools/ai_tools.py CHANGED
@@ -9,8 +9,8 @@ from agents.models.llms import (
9
  LLM_WEB_BROWSER,
10
  LLM_IMAGE_ANALYSIS,
11
  LLM_AUDIO_ANALYSIS,
12
- LLM_VIDEO_FILE_ANALYSIS,
13
- LLM_VIDEO_URL_ANALYSIS,
14
  LLM_DOCUMENT_ANALYSIS,
15
  LLM_CODE_GENERATION,
16
  LLM_CODE_EXECUTION,
@@ -20,7 +20,7 @@ from agents.models.llms import (
20
 
21
  THINKING_LEVEL_WEB_SEARCH,
22
  THINKING_LEVEL_MEDIA_ANALYSIS,
23
- THINKING_LEVEL_VIDEO_URL_ANALYSIS,
24
  THINKING_LEVEL_DOCUMENT_ANALYSIS,
25
  THINKING_LEVEL_CODE_GENERATION,
26
  THINKING_LEVEL_CODE_EXECUTION,
@@ -192,8 +192,8 @@ class AITools():
192
  """
193
  return AITools._media_analysis_tool("audio_analysis_tool", LLM_AUDIO_ANALYSIS, question, file_path)
194
 
195
- @tool("Video File Analysis Tool")
196
- def video_file_analysis_tool(question: str, file_path: str) -> str:
197
  """Given a question and video file, analyze the video to answer the question.
198
 
199
  Args:
@@ -206,44 +206,44 @@ class AITools():
206
  Raises:
207
  RuntimeError: If processing fails
208
  """
209
- return AITools._media_analysis_tool("video_file_analysis_tool", LLM_VIDEO_FILE_ANALYSIS, question, file_path)
210
 
211
- @tool("Video URL Analysis Tool")
212
- def video_url_analysis_tool(question: str, url: str) -> str:
213
- """Given a question and video URL, analyze the video to answer the question.
214
 
215
  Args:
216
- question (str): Question about a video URL
217
- url (str): The video URL
218
 
219
  Returns:
220
- str: Answer to the question about the video URL
221
 
222
  Raises:
223
  RuntimeError: If processing fails
224
  """
225
- print(f"🛠️ AITools: video_url_analysis_tool: question={question}, url={url}")
226
 
227
  try:
228
  client = AITools._get_client()
229
 
230
  result = client.models.generate_content(
231
- model=LLM_VIDEO_URL_ANALYSIS,
232
  contents=types.Content(
233
  parts=[types.Part(file_data=types.FileData(file_uri=url)),
234
  types.Part(text=question)]
235
  ),
236
  config=types.GenerateContentConfig(
237
  thinking_config=types.ThinkingConfig(
238
- thinking_level=THINKING_LEVEL_VIDEO_URL_ANALYSIS
239
  )
240
  )
241
  ).strip()
242
 
243
- print(f"🛠️ AITools: video_url_analysis_tool: result={result}")
244
  return result
245
  except Exception as e:
246
- print(f"⚠️ AITools: video_url_analysis_tool: exception={str(e)}")
247
  raise RuntimeError(f"Processing failed: {str(e)}")
248
 
249
  @tool("Document Analysis Tool")
 
9
  LLM_WEB_BROWSER,
10
  LLM_IMAGE_ANALYSIS,
11
  LLM_AUDIO_ANALYSIS,
12
+ LLM_VIDEO_ANALYSIS,
13
+ LLM_YOUTUBE_ANALYSIS,
14
  LLM_DOCUMENT_ANALYSIS,
15
  LLM_CODE_GENERATION,
16
  LLM_CODE_EXECUTION,
 
20
 
21
  THINKING_LEVEL_WEB_SEARCH,
22
  THINKING_LEVEL_MEDIA_ANALYSIS,
23
+ THINKING_LEVEL_YOUTUBE_ANALYSIS,
24
  THINKING_LEVEL_DOCUMENT_ANALYSIS,
25
  THINKING_LEVEL_CODE_GENERATION,
26
  THINKING_LEVEL_CODE_EXECUTION,
 
192
  """
193
  return AITools._media_analysis_tool("audio_analysis_tool", LLM_AUDIO_ANALYSIS, question, file_path)
194
 
195
+ @tool("Video Analysis Tool")
196
+ def video_analysis_tool(question: str, file_path: str) -> str:
197
  """Given a question and video file, analyze the video to answer the question.
198
 
199
  Args:
 
206
  Raises:
207
  RuntimeError: If processing fails
208
  """
209
+ return AITools._media_analysis_tool("video_analysis_tool", LLM_VIDEO_ANALYSIS, question, file_path)
210
 
211
+ @tool("YouTube Analysis Tool")
212
+ def youtube_analysis_tool(question: str, url: str) -> str:
213
+ """Given a question and YouTube URL, analyze the video to answer the question.
214
 
215
  Args:
216
+ question (str): Question about a YouTube video
217
+ url (str): The YouTube URL
218
 
219
  Returns:
220
+ str: Answer to the question about the YouTube video
221
 
222
  Raises:
223
  RuntimeError: If processing fails
224
  """
225
+ print(f"🛠️ AITools: youtube_analysis_tool: question={question}, url={url}")
226
 
227
  try:
228
  client = AITools._get_client()
229
 
230
  result = client.models.generate_content(
231
+ model=LLM_YOUTUBE_ANALYSIS,
232
  contents=types.Content(
233
  parts=[types.Part(file_data=types.FileData(file_uri=url)),
234
  types.Part(text=question)]
235
  ),
236
  config=types.GenerateContentConfig(
237
  thinking_config=types.ThinkingConfig(
238
+ thinking_level=THINKING_LEVEL_YOUTUBE_ANALYSIS
239
  )
240
  )
241
  ).strip()
242
 
243
+ print(f"🛠️ AITools: youtube_analysis_tool: result={result}")
244
  return result
245
  except Exception as e:
246
+ print(f"⚠️ AITools: youtube_analysis_tool: exception={str(e)}")
247
  raise RuntimeError(f"Processing failed: {str(e)}")
248
 
249
  @tool("Document Analysis Tool")