bstraehle commited on
Commit
14796a1
·
verified ·
1 Parent(s): fde0c14

Update crew.py

Browse files
Files changed (1) hide show
  1. crew.py +29 -0
crew.py CHANGED
@@ -99,6 +99,35 @@ def run_crew(question, file_path):
99
  except Exception as e:
100
  raise RuntimeError(f"Processing failed: {str(e)}")
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  @tool("Audio Analysis Tool")
103
  def audio_analysis_tool(question: str, file_path: str) -> str:
104
  """Given a question and audio file, analyze the audio to answer the question.
 
99
  except Exception as e:
100
  raise RuntimeError(f"Processing failed: {str(e)}")
101
 
102
+ ###
103
+ @tool("Image Analysis Tool")
104
+ def image_analysis_tool_2(question: str, file_path: str) -> str:
105
+ """Given a question and image file, analyze the image to answer the question.
106
+
107
+ Args:
108
+ question (str): Question about an image file
109
+ file_path (str): The image file path
110
+
111
+ Returns:
112
+ str: Answer to the question about the image file
113
+
114
+ Raises:
115
+ RuntimeError: If processing fails"""
116
+ try:
117
+ client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
118
+
119
+ file = client.files.upload(file=file_path)
120
+
121
+ response = client.models.generate_content(
122
+ model=IMAGE_ANALYSIS_MODEL,
123
+ contents=[file, question]
124
+ )
125
+
126
+ return response.text
127
+ except Exception as e:
128
+ raise RuntimeError(f"Processing failed: {str(e)}")
129
+ ###
130
+
131
  @tool("Audio Analysis Tool")
132
  def audio_analysis_tool(question: str, file_path: str) -> str:
133
  """Given a question and audio file, analyze the audio to answer the question.