Update crew.py
Browse files
crew.py
CHANGED
@@ -200,18 +200,15 @@ def run_crew(question, file_path):
|
|
200 |
|
201 |
if is_ext(file_path, ".docx"):
|
202 |
file_data = read_docx_text(file_path)
|
203 |
-
|
204 |
-
|
205 |
elif is_ext(file_path, ".pptx"):
|
206 |
file_data = read_pptx_text(file_path)
|
207 |
-
|
208 |
-
|
209 |
else:
|
210 |
file = client.files.upload(file=file_path)
|
211 |
contents = [file, question]
|
212 |
-
|
213 |
-
print(f"### Initial question: {question}")
|
214 |
-
print(f"### Final question: {final_question}")
|
215 |
|
216 |
response = client.models.generate_content(
|
217 |
model=DOCUMENT_ANALYSIS_MODEL,
|
@@ -239,15 +236,12 @@ def run_crew(question, file_path):
|
|
239 |
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
240 |
|
241 |
file_data = read_file_json(file_path)
|
242 |
-
|
243 |
-
final_question = f"{question}\n{file_data}"
|
244 |
-
|
245 |
-
print(f"### Initial question: {question}")
|
246 |
-
print(f"### Final question: {final_question}")
|
247 |
|
|
|
|
|
248 |
response = client.models.generate_content(
|
249 |
model=CODE_GENERATION_MODEL,
|
250 |
-
contents=[
|
251 |
config=types.GenerateContentConfig(
|
252 |
tools=[types.Tool(code_execution=types.ToolCodeExecution)]
|
253 |
),
|
@@ -429,12 +423,12 @@ def run_crew(question, file_path):
|
|
429 |
if file_path:
|
430 |
question = f"{question} File path: {file_path}."
|
431 |
|
432 |
-
|
433 |
-
final_answer = get_final_answer(FINAL_ANSWER_MODEL, question, str(
|
434 |
|
435 |
-
print(f"
|
436 |
-
print(f"
|
437 |
-
print(f"
|
438 |
|
439 |
return final_answer
|
440 |
|
|
|
200 |
|
201 |
if is_ext(file_path, ".docx"):
|
202 |
file_data = read_docx_text(file_path)
|
203 |
+
contents = [f"{question}\n{file_data}"]
|
204 |
+
print(f"=> File data:\n{file_data}")
|
205 |
elif is_ext(file_path, ".pptx"):
|
206 |
file_data = read_pptx_text(file_path)
|
207 |
+
contents = [f"{question}\n{file_data}"]
|
208 |
+
print(f"=> File data:\n{file_data}")
|
209 |
else:
|
210 |
file = client.files.upload(file=file_path)
|
211 |
contents = [file, question]
|
|
|
|
|
|
|
212 |
|
213 |
response = client.models.generate_content(
|
214 |
model=DOCUMENT_ANALYSIS_MODEL,
|
|
|
236 |
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
237 |
|
238 |
file_data = read_file_json(file_path)
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
+
print(f"=> File data:\n{file_data}")
|
241 |
+
|
242 |
response = client.models.generate_content(
|
243 |
model=CODE_GENERATION_MODEL,
|
244 |
+
contents=[f"{question}\n{file_data}"],
|
245 |
config=types.GenerateContentConfig(
|
246 |
tools=[types.Tool(code_execution=types.ToolCodeExecution)]
|
247 |
),
|
|
|
423 |
if file_path:
|
424 |
question = f"{question} File path: {file_path}."
|
425 |
|
426 |
+
answer = crew.kickoff(inputs={"question": question})
|
427 |
+
final_answer = get_final_answer(FINAL_ANSWER_MODEL, question, str(answer))
|
428 |
|
429 |
+
print(f"=> Question: {question}")
|
430 |
+
print(f"=> Answer: {answer}")
|
431 |
+
print(f"=> Final answer: {final_answer}")
|
432 |
|
433 |
return final_answer
|
434 |
|