Update crew.py
Browse files
crew.py
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
# https://docs.crewai.com/introduction
|
4 |
# https://ai.google.dev/gemini-api/docs
|
5 |
|
6 |
-
import
|
7 |
import pandas as pd
|
8 |
from crewai import Agent, Crew, Process, Task
|
9 |
from crewai.tools import tool
|
@@ -87,21 +87,16 @@ def run_crew(question, file_path):
|
|
87 |
Raises:
|
88 |
RuntimeError: If processing fails"""
|
89 |
try:
|
90 |
-
client =
|
91 |
-
|
92 |
-
img_b64 = ""
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
messages = [{"role": "user",
|
100 |
-
"content": [{"type": "text", "text": question},
|
101 |
-
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{img_b64}"}}]}]
|
102 |
)
|
103 |
-
|
104 |
-
|
105 |
except Exception as e:
|
106 |
raise RuntimeError(f"Processing failed: {str(e)}")
|
107 |
|
@@ -265,7 +260,8 @@ def run_crew(question, file_path):
|
|
265 |
goal="Given a question and image file, analyze the image and answer the question: {question}",
|
266 |
backstory="As an expert image analysis assistant, you analyze the image to answer the question.",
|
267 |
allow_delegation=False,
|
268 |
-
llm=AGENT_MODEL,
|
|
|
269 |
max_iter=2,
|
270 |
tools=[image_analysis_tool],
|
271 |
verbose=True
|
|
|
3 |
# https://docs.crewai.com/introduction
|
4 |
# https://ai.google.dev/gemini-api/docs
|
5 |
|
6 |
+
import os
|
7 |
import pandas as pd
|
8 |
from crewai import Agent, Crew, Process, Task
|
9 |
from crewai.tools import tool
|
|
|
87 |
Raises:
|
88 |
RuntimeError: If processing fails"""
|
89 |
try:
|
90 |
+
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
|
|
|
|
91 |
|
92 |
+
file = client.files.upload(file=file_path)
|
93 |
+
|
94 |
+
response = client.models.generate_content(
|
95 |
+
model=IMAGE_ANALYSIS_MODEL,
|
96 |
+
contents=[file, question]
|
|
|
|
|
|
|
97 |
)
|
98 |
+
|
99 |
+
return response.text
|
100 |
except Exception as e:
|
101 |
raise RuntimeError(f"Processing failed: {str(e)}")
|
102 |
|
|
|
260 |
goal="Given a question and image file, analyze the image and answer the question: {question}",
|
261 |
backstory="As an expert image analysis assistant, you analyze the image to answer the question.",
|
262 |
allow_delegation=False,
|
263 |
+
#llm=AGENT_MODEL,
|
264 |
+
llm=IMAGE_ANALYSIS_MODEL,
|
265 |
max_iter=2,
|
266 |
tools=[image_analysis_tool],
|
267 |
verbose=True
|