bstraehle commited on
Commit
1081c8c
·
verified ·
1 Parent(s): 639d21f

Update crew.py

Browse files
Files changed (1) hide show
  1. crew.py +20 -3
crew.py CHANGED
@@ -4,7 +4,7 @@
4
  # https://ai.google.dev/gemini-api/docs
5
 
6
  import os
7
-
8
  from crewai import Agent, Crew, Process, Task
9
  from crewai.tools import tool
10
  from google import genai
@@ -180,18 +180,35 @@ def run_crew(question, file_path):
180
  raise RuntimeError(f"Processing failed: {str(e)}")
181
 
182
  @tool("Code Generation Tool")
183
- def code_generation_tool(question: str) -> str:
184
  """Generate and execute Python code to answer a question.
 
185
 
186
  Args:
187
  question (str): Question to answer
188
 
189
  Returns:
190
  str: Answer to the question
191
-
 
192
  Raises:
193
  RuntimeError: If processing fails"""
194
  try:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
196
 
197
  file = client.files.upload(file=file_path)
 
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
10
  from google import genai
 
180
  raise RuntimeError(f"Processing failed: {str(e)}")
181
 
182
  @tool("Code Generation Tool")
183
+ def code_generation_tool(question: str, file_path: str) -> str:
184
  """Generate and execute Python code to answer a question.
185
+ The question can be about an optional document.
186
 
187
  Args:
188
  question (str): Question to answer
189
 
190
  Returns:
191
  str: Answer to the question
192
+ file_path (str): Optional document file path
193
+
194
  Raises:
195
  RuntimeError: If processing fails"""
196
  try:
197
+ if file_path:
198
+ df = pd.read_excel("data.xlsx")
199
+ data = f"data: {df.head().to_json()}"
200
+ """
201
+ pd.read_csv() for CSV files
202
+
203
+ pd.read_excel() for Excel files (.xls, .xlsx)
204
+
205
+ pd.read_json() for JSON files
206
+
207
+ pd.read_parquet() for Parquet files
208
+
209
+ pd.read_sql() for SQL queries
210
+ """
211
+
212
  client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
213
 
214
  file = client.files.upload(file=file_path)