Update crew.py
Browse files
crew.py
CHANGED
@@ -73,34 +73,6 @@ def run_crew(question, file_path):
|
|
73 |
except Exception as e:
|
74 |
raise RuntimeError(f"Processing failed: {str(e)}")
|
75 |
|
76 |
-
@tool("Image Analysis Tool")
|
77 |
-
def image_analysis_tool(question: str, file_path: str) -> str:
|
78 |
-
"""Given a question and image file, analyze the image to answer the question.
|
79 |
-
|
80 |
-
Args:
|
81 |
-
question (str): Question about an image file
|
82 |
-
file_path (str): The image file path
|
83 |
-
|
84 |
-
Returns:
|
85 |
-
str: Answer to the question about the image file
|
86 |
-
|
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 |
-
|
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.
|
@@ -132,7 +104,33 @@ def run_crew(question, file_path):
|
|
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:
|
|
|
73 |
except Exception as e:
|
74 |
raise RuntimeError(f"Processing failed: {str(e)}")
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
@tool("Image Analysis Tool")
|
77 |
def image_analysis_tool(question: str, file_path: str) -> str:
|
78 |
"""Given a question and image file, analyze the image to answer the question.
|
|
|
104 |
content = completion.choices[0].message.content
|
105 |
except Exception as e:
|
106 |
raise RuntimeError(f"Processing failed: {str(e)}")
|
107 |
+
|
108 |
+
@tool("Audio Analysis Tool")
|
109 |
+
def audio_analysis_tool(question: str, file_path: str) -> str:
|
110 |
+
"""Given a question and audio file, analyze the audio to answer the question.
|
111 |
+
|
112 |
+
Args:
|
113 |
+
question (str): Question about an audio file
|
114 |
+
file_path (str): The audio file path
|
115 |
+
|
116 |
+
Returns:
|
117 |
+
str: Answer to the question about the audio file
|
118 |
+
|
119 |
+
Raises:
|
120 |
+
RuntimeError: If processing fails"""
|
121 |
+
try:
|
122 |
+
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
123 |
+
|
124 |
+
file = client.files.upload(file=file_path)
|
125 |
+
|
126 |
+
response = client.models.generate_content(
|
127 |
+
model=AUDIO_ANALYSIS_MODEL,
|
128 |
+
contents=[file, question]
|
129 |
+
)
|
130 |
+
|
131 |
+
return response.text
|
132 |
+
except Exception as e:
|
133 |
+
raise RuntimeError(f"Processing failed: {str(e)}")
|
134 |
|
135 |
@tool("Video Analysis Tool")
|
136 |
def video_analysis_tool(question: str, file_path: str) -> str:
|