Update util.py
Browse files
util.py
CHANGED
|
@@ -2,12 +2,10 @@ import pandas as pd
|
|
| 2 |
|
| 3 |
from openai import OpenAI
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
FINAL_ANSWER_MODEL = "gpt-4.5-preview"
|
| 8 |
|
| 9 |
def get_questions():
|
| 10 |
-
df = pd.read_json(
|
| 11 |
result=[]
|
| 12 |
|
| 13 |
for index, row in df.iterrows():
|
|
@@ -15,7 +13,7 @@ def get_questions():
|
|
| 15 |
|
| 16 |
return result
|
| 17 |
|
| 18 |
-
def get_final_answer(question, initial_answer):
|
| 19 |
prompt_template = """
|
| 20 |
You are an expert question answering assistant. Given a question and an initial answer, your task is to provide the final answer.
|
| 21 |
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.
|
|
@@ -41,7 +39,7 @@ def get_final_answer(question, initial_answer):
|
|
| 41 |
client = OpenAI()
|
| 42 |
completion = client.chat.completions.create(
|
| 43 |
messages=[{"role": "user", "content": [{"type": "text", "text": prompt_template}]}],
|
| 44 |
-
model=
|
| 45 |
)
|
| 46 |
|
| 47 |
return completion.choices[0].message.content
|
|
|
|
| 2 |
|
| 3 |
from openai import OpenAI
|
| 4 |
|
| 5 |
+
FILE_PATH = "data/gaia_validation_20.jsonl"
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def get_questions():
|
| 8 |
+
df = pd.read_json(FILE_PATH, lines=True)
|
| 9 |
result=[]
|
| 10 |
|
| 11 |
for index, row in df.iterrows():
|
|
|
|
| 13 |
|
| 14 |
return result
|
| 15 |
|
| 16 |
+
def get_final_answer(model, question, initial_answer):
|
| 17 |
prompt_template = """
|
| 18 |
You are an expert question answering assistant. Given a question and an initial answer, your task is to provide the final answer.
|
| 19 |
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.
|
|
|
|
| 39 |
client = OpenAI()
|
| 40 |
completion = client.chat.completions.create(
|
| 41 |
messages=[{"role": "user", "content": [{"type": "text", "text": prompt_template}]}],
|
| 42 |
+
model=model
|
| 43 |
)
|
| 44 |
|
| 45 |
return completion.choices[0].message.content
|