bstraehle commited on
Commit
9e82ac9
·
verified ·
1 Parent(s): a09b432

Update crew.py

Browse files
Files changed (1) hide show
  1. crew.py +58 -17
crew.py CHANGED
@@ -23,6 +23,7 @@ IMAGE_MODEL = "gemini-2.0-flash"
23
  AUDIO_MODEL = "gemini-2.0-flash"
24
  VIDEO_MODEL = "gemini-2.0-flash"
25
  YOUTUBE_MODEL = "gemini-2.0-flash"
 
26
 
27
  # LLM evaluation
28
 
@@ -147,6 +148,34 @@ def run_crew(question, file_path):
147
  )
148
  except Exception as e:
149
  raise RuntimeError(f"Processing failed: {str(e)}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
  web_search_tool = SerperDevTool()
152
  web_rag_tool = WebsiteSearchTool()
@@ -165,39 +194,39 @@ def run_crew(question, file_path):
165
  verbose=False
166
  )
167
 
168
- audio_analysis_agent = Agent(
169
- role="Audio Analysis Agent",
170
- goal="Analyze audio to help answer question \"{question}\"",
171
- backstory="As an expert audio analysis assistant, you analyze the audio to help answer the question.",
172
  allow_delegation=False,
173
  llm=AGENT_MODEL,
174
  max_iter=2,
175
- tools=[audio_analysis_tool],
176
  verbose=False
177
  )
178
 
179
- image_analysis_agent = Agent(
180
- role="Image Analysis Agent",
181
- goal="Analyze image to help answer question \"{question}\"",
182
- backstory="As an expert image analysis assistant, you analyze the image to help answer the question.",
183
  allow_delegation=False,
184
  llm=AGENT_MODEL,
185
  max_iter=2,
186
- tools=[image_analysis_tool],
187
  verbose=False
188
  )
189
 
190
- youtube_audio_analysis_agent = Agent(
191
- role="YouTube Audio Analysis Agent",
192
- goal="Analyze YouTube video to help answer audio question \"{question}\"",
193
- backstory="As an expert YouTube audio analysis assistant, you analyze the video to help answer the question.",
194
  allow_delegation=False,
195
  llm=AGENT_MODEL,
196
  max_iter=2,
197
- tools=[youtube_audio_analysis_tool],
198
  verbose=False
199
  )
200
-
201
  youtube_analysis_agent = Agent(
202
  role="YouTube Analysis Agent",
203
  goal="Analyze YouTube video to help answer question \"{question}\"",
@@ -205,7 +234,18 @@ def run_crew(question, file_path):
205
  allow_delegation=False,
206
  llm=AGENT_MODEL,
207
  max_iter=2,
208
- tools=[youtube_image_analysis_tool],
 
 
 
 
 
 
 
 
 
 
 
209
  verbose=False
210
  )
211
 
@@ -248,6 +288,7 @@ def run_crew(question, file_path):
248
  audio_analysis_agent,
249
  video_analysis_agent,
250
  youtube_analysis_agent,
 
251
  python_coding_agent],
252
  manager_agent=manager_agent,
253
  tasks=[manager_task],
 
23
  AUDIO_MODEL = "gemini-2.0-flash"
24
  VIDEO_MODEL = "gemini-2.0-flash"
25
  YOUTUBE_MODEL = "gemini-2.0-flash"
26
+ DOCUMENT_MODEL = "gemini-2.0-flash"
27
 
28
  # LLM evaluation
29
 
 
148
  )
149
  except Exception as e:
150
  raise RuntimeError(f"Processing failed: {str(e)}")
151
+
152
+ @tool("Document Analysis Tool")
153
+ def document_analysis_tool(question: str, file_path: str) -> str:
154
+ """Answer a question about a document file. Supported document types include:
155
+ .txt, .csv, .xml, .rtf, .pdf, .md, .html, .css, .js, .py
156
+
157
+ Args:
158
+ question (str): Question about a document file
159
+ file_path (str): The document file path
160
+
161
+ Returns:
162
+ str: Answer to the question about the document file
163
+
164
+ Raises:
165
+ RuntimeError: If processing fails"""
166
+ try:
167
+ client = genai.Client(api_key="GOOGLE_API_KEY")
168
+
169
+ file = client.files.upload(file=file_path)
170
+
171
+ response = client.models.generate_content(
172
+ model=DOCUMENT_MODEL,
173
+ contents=[file, question]
174
+ )
175
+
176
+ return response.text
177
+ except Exception as e:
178
+ raise RuntimeError(f"Processing failed: {str(e)}")
179
 
180
  web_search_tool = SerperDevTool()
181
  web_rag_tool = WebsiteSearchTool()
 
194
  verbose=False
195
  )
196
 
197
+ image_analysis_agent = Agent(
198
+ role="Image Analysis Agent",
199
+ goal="Analyze image file to help answer question \"{question}\"",
200
+ backstory="As an expert image analysis assistant, you analyze the image file to help answer the question.",
201
  allow_delegation=False,
202
  llm=AGENT_MODEL,
203
  max_iter=2,
204
+ tools=[image_analysis_tool],
205
  verbose=False
206
  )
207
 
208
+ audio_analysis_agent = Agent(
209
+ role="Audio Analysis Agent",
210
+ goal="Analyze audio file to help answer question \"{question}\"",
211
+ backstory="As an expert audio analysis assistant, you analyze the audio file to help answer the question.",
212
  allow_delegation=False,
213
  llm=AGENT_MODEL,
214
  max_iter=2,
215
+ tools=[audio_analysis_tool],
216
  verbose=False
217
  )
218
 
219
+ video_analysis_agent = Agent(
220
+ role="Video Analysis Agent",
221
+ goal="Analyze video file to help answer question \"{question}\"",
222
+ backstory="As an expert video analysis assistant, you analyze the video file to help answer the question.",
223
  allow_delegation=False,
224
  llm=AGENT_MODEL,
225
  max_iter=2,
226
+ tools=[video_analysis_tool],
227
  verbose=False
228
  )
229
+
230
  youtube_analysis_agent = Agent(
231
  role="YouTube Analysis Agent",
232
  goal="Analyze YouTube video to help answer question \"{question}\"",
 
234
  allow_delegation=False,
235
  llm=AGENT_MODEL,
236
  max_iter=2,
237
+ tools=[youtube_analysis_tool],
238
+ verbose=False
239
+ )
240
+
241
+ document_analysis_agent = Agent(
242
+ role="Document Analysis Agent",
243
+ goal="Analyze document of type .txt, .csv, .xml, .rtf, .pdf, .md, .html, .css, .js, .py to help answer question \"{question}\"",
244
+ backstory="As an expert document analysis assistant, you analyze the document to help answer the question.",
245
+ allow_delegation=False,
246
+ llm=AGENT_MODEL,
247
+ max_iter=2,
248
+ tools=[document_analysis_tool],
249
  verbose=False
250
  )
251
 
 
288
  audio_analysis_agent,
289
  video_analysis_agent,
290
  youtube_analysis_agent,
291
+ document_analysis_agent,
292
  python_coding_agent],
293
  manager_agent=manager_agent,
294
  tasks=[manager_task],