Update crew.py
Browse files
crew.py
CHANGED
@@ -193,14 +193,6 @@ def run_crew(question, file_path):
|
|
193 |
Raises:
|
194 |
RuntimeError: If processing fails"""
|
195 |
try:
|
196 |
-
#if file_path:
|
197 |
-
# df = read_file(file_path)
|
198 |
-
# question = f"Content of file {file_path}:\n{df.to_string()}\nQuestion: {question}\nDO NOT READ the file, but use the content provided above."
|
199 |
-
|
200 |
-
print("###")
|
201 |
-
print(question)
|
202 |
-
print("###")
|
203 |
-
|
204 |
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
205 |
|
206 |
response = client.models.generate_content(
|
@@ -366,9 +358,17 @@ def run_crew(question, file_path):
|
|
366 |
# Process
|
367 |
|
368 |
if file_path:
|
369 |
-
|
370 |
-
|
371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
|
373 |
initial_answer = crew.kickoff(inputs={"question": question})
|
374 |
final_answer = get_final_answer(FINAL_ANSWER_MODEL, question, str(initial_answer))
|
|
|
193 |
Raises:
|
194 |
RuntimeError: If processing fails"""
|
195 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
197 |
|
198 |
response = client.models.generate_content(
|
|
|
358 |
# Process
|
359 |
|
360 |
if file_path:
|
361 |
+
ext = os.path.splitext(file_path)[1].lower()
|
362 |
+
|
363 |
+
if ext in (".csv", ".xls", ".xlsx", ".json", ".jsonl"):
|
364 |
+
df = read_file(file_path)
|
365 |
+
question = f"Content of file {file_path}:\n{df.to_string()}\nQuestion: {question}"
|
366 |
+
else:
|
367 |
+
question = f"{question} File path: {file_path}."
|
368 |
+
|
369 |
+
print("###")
|
370 |
+
print(question)
|
371 |
+
print("###")
|
372 |
|
373 |
initial_answer = crew.kickoff(inputs={"question": question})
|
374 |
final_answer = get_final_answer(FINAL_ANSWER_MODEL, question, str(initial_answer))
|