bstraehle commited on
Commit
c0e1900
·
verified ·
1 Parent(s): 653ef4e

Update crew.py

Browse files
Files changed (1) hide show
  1. crew.py +37 -1
crew.py CHANGED
@@ -418,4 +418,40 @@ def run_crew(question, file_path):
418
  print(f"Final answer: {final_answer}")
419
  print("###")
420
 
421
- return final_answer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  print(f"Final answer: {final_answer}")
419
  print("###")
420
 
421
+ return final_answer
422
+
423
+ def get_final_answer(model, question, answer):
424
+ prompt_template = """
425
+ You are an expert question answering assistant. Given a question and an initial answer, your task is to provide the final answer.
426
+ Your final answer must be a number and/or string OR as few words as possible OR a comma-separated list of numbers and/or strings.
427
+ If you are asked for a number, don't use comma to write your number neither use units such as USD, $, percent, or % unless specified otherwise.
428
+ If you are asked for a string, don't use articles, neither abbreviations (for example cities), and write the digits in plain text unless specified otherwise.
429
+ If you are asked for a comma-separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
430
+ If the final answer is a number, use a number not a word.
431
+ If the final answer is a string, start with an uppercase character.
432
+ If the final answer is a comma-separated list of numbers, use a space character after each comma.
433
+ If the final answer is a comma-separated list of strings, use a space character after each comma and start with a lowercase character.
434
+ Do not add any content to the final answer that is not in the initial answer.
435
+
436
+ **Question:** """ + question + """
437
+
438
+ **Initial answer:** """ + answer + """
439
+
440
+ **Example 1:** What is the biggest city in California? Los Angeles
441
+ **Example 2:** How many 'r's are in strawberry? 3
442
+ **Example 3:** What is the opposite of black? White
443
+ **Example 4:** What are the first 5 numbers in the Fibonacci sequence? 0, 1, 1, 2, 3
444
+ **Example 5:** What is the opposite of bad, worse, worst? good, better, best
445
+
446
+ **Final answer:**
447
+
448
+ """
449
+
450
+ client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
451
+
452
+ response = client.models.generate_content(
453
+ model=model,
454
+ contents=[prompt_template]
455
+ )
456
+
457
+ return response.text