Update crew.py
Browse files
crew.py
CHANGED
@@ -102,7 +102,7 @@ def run_crew(question, file_path):
|
|
102 |
|
103 |
###
|
104 |
@tool("Image Analysis Tool")
|
105 |
-
def
|
106 |
"""Given a question and image file, analyze the image to answer the question.
|
107 |
|
108 |
Args:
|
@@ -125,43 +125,14 @@ def run_crew(question, file_path):
|
|
125 |
completion = client.chat.completions.create(
|
126 |
model = "gpt-4.5-preview",
|
127 |
messages = [{"role": "user",
|
128 |
-
"content": [{"type": "text",
|
129 |
-
|
130 |
-
{"type": "image_url",
|
131 |
-
"image_url": {"url": f"data:image/jpeg;base64,{img_b64}"}}]}]
|
132 |
)
|
133 |
|
134 |
content = completion.choices[0].message.content
|
135 |
except Exception as e:
|
136 |
raise RuntimeError(f"Processing failed: {str(e)}")
|
137 |
###
|
138 |
-
|
139 |
-
@tool("Audio Analysis Tool")
|
140 |
-
def audio_analysis_tool(question: str, file_path: str) -> str:
|
141 |
-
"""Given a question and audio file, analyze the audio to answer the question.
|
142 |
-
|
143 |
-
Args:
|
144 |
-
question (str): Question about an audio file
|
145 |
-
file_path (str): The audio file path
|
146 |
-
|
147 |
-
Returns:
|
148 |
-
str: Answer to the question about the audio file
|
149 |
-
|
150 |
-
Raises:
|
151 |
-
RuntimeError: If processing fails"""
|
152 |
-
try:
|
153 |
-
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
154 |
-
|
155 |
-
file = client.files.upload(file=file_path)
|
156 |
-
|
157 |
-
response = client.models.generate_content(
|
158 |
-
model=AUDIO_ANALYSIS_MODEL,
|
159 |
-
contents=[file, question]
|
160 |
-
)
|
161 |
-
|
162 |
-
return response.text
|
163 |
-
except Exception as e:
|
164 |
-
raise RuntimeError(f"Processing failed: {str(e)}")
|
165 |
|
166 |
@tool("Video Analysis Tool")
|
167 |
def video_analysis_tool(question: str, file_path: str) -> str:
|
@@ -298,7 +269,7 @@ def run_crew(question, file_path):
|
|
298 |
allow_delegation=False,
|
299 |
llm=AGENT_MODEL,
|
300 |
max_iter=2,
|
301 |
-
tools=[
|
302 |
verbose=True
|
303 |
)
|
304 |
|
@@ -395,7 +366,7 @@ def run_crew(question, file_path):
|
|
395 |
code_execution_agent],
|
396 |
manager_agent=manager_agent,
|
397 |
tasks=[manager_task],
|
398 |
-
verbose=
|
399 |
)
|
400 |
|
401 |
# Process
|
|
|
102 |
|
103 |
###
|
104 |
@tool("Image Analysis Tool")
|
105 |
+
def image_analysis_tool(question: str, file_path: str) -> str:
|
106 |
"""Given a question and image file, analyze the image to answer the question.
|
107 |
|
108 |
Args:
|
|
|
125 |
completion = client.chat.completions.create(
|
126 |
model = "gpt-4.5-preview",
|
127 |
messages = [{"role": "user",
|
128 |
+
"content": [{"type": "text", "text": question},
|
129 |
+
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{img_b64}"}}]}]
|
|
|
|
|
130 |
)
|
131 |
|
132 |
content = completion.choices[0].message.content
|
133 |
except Exception as e:
|
134 |
raise RuntimeError(f"Processing failed: {str(e)}")
|
135 |
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
@tool("Video Analysis Tool")
|
138 |
def video_analysis_tool(question: str, file_path: str) -> str:
|
|
|
269 |
allow_delegation=False,
|
270 |
llm=AGENT_MODEL,
|
271 |
max_iter=2,
|
272 |
+
tools=[image_analysis_tool],
|
273 |
verbose=True
|
274 |
)
|
275 |
|
|
|
366 |
code_execution_agent],
|
367 |
manager_agent=manager_agent,
|
368 |
tasks=[manager_task],
|
369 |
+
verbose=True
|
370 |
)
|
371 |
|
372 |
# Process
|