bstraehle commited on
Commit
9e680bf
·
verified ·
1 Parent(s): be7c8ff

Update crew.py

Browse files
Files changed (1) hide show
  1. crew.py +12 -18
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
- final_question = f"{question}\n{file_data}"
204
- contents = [final_question]
205
  elif is_ext(file_path, ".pptx"):
206
  file_data = read_pptx_text(file_path)
207
- final_question = f"{question}\n{file_data}"
208
- contents = [final_question]
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=[final_question],
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
- initial_answer = crew.kickoff(inputs={"question": question})
433
- final_answer = get_final_answer(FINAL_ANSWER_MODEL, question, str(initial_answer))
434
 
435
- print(f"### Question: {question}")
436
- print(f"### Initial answer: {initial_answer}")
437
- print(f"### Final answer: {final_answer}")
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