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

Update util.py

Browse files
Files changed (1) hide show
  1. util.py +1 -38
util.py CHANGED
@@ -1,6 +1,5 @@
1
  import os
2
  import pandas as pd
3
- from google import genai
4
 
5
  def get_questions(file_path, level):
6
  df = pd.read_json(file_path, lines=True)
@@ -25,40 +24,4 @@ def read_file(file_path):
25
  elif ext in (".json", ".jsonl"):
26
  df = pd.read_json(file_path)
27
 
28
- return "" if df is None else df.to_json()
29
-
30
- def get_final_answer(model, question, answer):
31
- prompt_template = """
32
- You are an expert question answering assistant. Given a question and an initial answer, your task is to provide the final answer.
33
- 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.
34
- 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.
35
- 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.
36
- 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.
37
- If the final answer is a number, use a number not a word.
38
- If the final answer is a word, start with an uppercase character.
39
- If the final answer is a comma-separated list of numbers, use a space character after each comma.
40
- If the final answer is a comma-separated list of strings, use a space character after each comma and start with a lowercase character.
41
- Do not add any content to the final answer that is not in the initial answer.
42
-
43
- **Question:** """ + question + """
44
-
45
- **Initial answer:** """ + answer + """
46
-
47
- **Example 1:** How many 'r's are in strawberry? 3
48
- **Example 2:** What is the opposite of black? White
49
- **Example 3:** What is the biggest city in California? Los Angeles
50
- **Example 4:** What is the superlative of good? Best
51
- **Example 5:** What are the first 10 numbers in the Fibonacci sequence? 0, 1, 1, 2, 3, 5, 8, 13, 21, 34
52
-
53
- **Final answer:**
54
-
55
- """
56
-
57
- client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
58
-
59
- response = client.models.generate_content(
60
- model=model,
61
- contents=[prompt_template]
62
- )
63
-
64
- return response.text
 
1
  import os
2
  import pandas as pd
 
3
 
4
  def get_questions(file_path, level):
5
  df = pd.read_json(file_path, lines=True)
 
24
  elif ext in (".json", ".jsonl"):
25
  df = pd.read_json(file_path)
26
 
27
+ return "" if df is None else df.to_json()