bstraehle commited on
Commit
0666451
·
verified ·
1 Parent(s): eae9e2e

Update crew.py

Browse files
Files changed (1) hide show
  1. crew.py +27 -27
crew.py CHANGED
@@ -153,6 +153,32 @@ def run_crew(question, file_path):
153
  return response.text
154
  except Exception as e:
155
  raise RuntimeError(f"Processing failed: {str(e)}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
  @tool("Document Analysis Tool")
158
  def document_analysis_tool(question: str, file_path: str) -> str:
@@ -172,7 +198,7 @@ def run_crew(question, file_path):
172
 
173
  contents = []
174
 
175
- if is_ext(file_path, ".docx")
176
  file_data = read_docx(file_path)
177
  contents = [f"{question}\n{file_data}"]
178
  else:
@@ -187,33 +213,7 @@ def run_crew(question, file_path):
187
  return response.text
188
  except Exception as e:
189
  raise RuntimeError(f"Processing failed: {str(e)}")
190
-
191
- @tool("YouTube Analysis Tool")
192
- def youtube_analysis_tool(question: str, url: str) -> str:
193
- """Given a question and YouTube URL, analyze the video to answer the question.
194
-
195
- Args:
196
- question (str): Question about a YouTube video
197
- url (str): The YouTube video URL
198
-
199
- Returns:
200
- str: Answer to the question about the YouTube video
201
-
202
- Raises:
203
- RuntimeError: If processing fails"""
204
- try:
205
- client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
206
 
207
- return client.models.generate_content(
208
- model=YOUTUBE_ANALYSIS_MODEL,
209
- contents=types.Content(
210
- parts=[types.Part(file_data=types.FileData(file_uri=url)),
211
- types.Part(text=question)]
212
- )
213
- )
214
- except Exception as e:
215
- raise RuntimeError(f"Processing failed: {str(e)}")
216
-
217
  @tool("Code Generation Tool")
218
  def code_generation_tool(question: str, file_path: str) -> str:
219
  """Given a question and data file, generate and execute code to answer the question.
 
153
  return response.text
154
  except Exception as e:
155
  raise RuntimeError(f"Processing failed: {str(e)}")
156
+
157
+ @tool("YouTube Analysis Tool")
158
+ def youtube_analysis_tool(question: str, url: str) -> str:
159
+ """Given a question and YouTube URL, analyze the video to answer the question.
160
+
161
+ Args:
162
+ question (str): Question about a YouTube video
163
+ url (str): The YouTube video URL
164
+
165
+ Returns:
166
+ str: Answer to the question about the YouTube video
167
+
168
+ Raises:
169
+ RuntimeError: If processing fails"""
170
+ try:
171
+ client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
172
+
173
+ return client.models.generate_content(
174
+ model=YOUTUBE_ANALYSIS_MODEL,
175
+ contents=types.Content(
176
+ parts=[types.Part(file_data=types.FileData(file_uri=url)),
177
+ types.Part(text=question)]
178
+ )
179
+ )
180
+ except Exception as e:
181
+ raise RuntimeError(f"Processing failed: {str(e)}")
182
 
183
  @tool("Document Analysis Tool")
184
  def document_analysis_tool(question: str, file_path: str) -> str:
 
198
 
199
  contents = []
200
 
201
+ if is_ext(file_path, ".docx"):
202
  file_data = read_docx(file_path)
203
  contents = [f"{question}\n{file_data}"]
204
  else:
 
213
  return response.text
214
  except Exception as e:
215
  raise RuntimeError(f"Processing failed: {str(e)}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
 
 
 
 
 
 
 
 
 
 
 
217
  @tool("Code Generation Tool")
218
  def code_generation_tool(question: str, file_path: str) -> str:
219
  """Given a question and data file, generate and execute code to answer the question.