Update util.py
Browse files
util.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
#import base64, cv2
|
| 2 |
import pandas as pd
|
| 3 |
-
|
| 4 |
-
from openai import OpenAI
|
| 5 |
|
| 6 |
def get_questions(file_path):
|
| 7 |
df = pd.read_json(file_path, lines=True)
|
|
@@ -46,6 +46,7 @@ def get_final_answer(model, question, answer):
|
|
| 46 |
If the final answer is a word, start with an uppercase character.
|
| 47 |
If the final answer is a comma-separated list of numbers, use a space character after each comma.
|
| 48 |
If the final answer is a comma-separated list of strings, start with a lowercase character.
|
|
|
|
| 49 |
|
| 50 |
**Question:** """ + question + """
|
| 51 |
|
|
@@ -61,20 +62,20 @@ def get_final_answer(model, question, answer):
|
|
| 61 |
|
| 62 |
"""
|
| 63 |
|
| 64 |
-
client = OpenAI()
|
| 65 |
|
| 66 |
-
completion = client.chat.completions.create(
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
)
|
| 70 |
|
| 71 |
-
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
|
| 78 |
-
return completion.choices[0].message.content
|
| 79 |
|
| 80 |
-
|
|
|
|
| 1 |
#import base64, cv2
|
| 2 |
import pandas as pd
|
| 3 |
+
from google import genai
|
| 4 |
+
#from openai import OpenAI
|
| 5 |
|
| 6 |
def get_questions(file_path):
|
| 7 |
df = pd.read_json(file_path, lines=True)
|
|
|
|
| 46 |
If the final answer is a word, start with an uppercase character.
|
| 47 |
If the final answer is a comma-separated list of numbers, use a space character after each comma.
|
| 48 |
If the final answer is a comma-separated list of strings, start with a lowercase character.
|
| 49 |
+
Do not add any content to the final answer that is not in the initial answer.
|
| 50 |
|
| 51 |
**Question:** """ + question + """
|
| 52 |
|
|
|
|
| 62 |
|
| 63 |
"""
|
| 64 |
|
| 65 |
+
#client = OpenAI()
|
| 66 |
|
| 67 |
+
#completion = client.chat.completions.create(
|
| 68 |
+
# model=model,
|
| 69 |
+
# messages=[{"role": "user", "content": [{"type": "text", "text": prompt_template}]}]
|
| 70 |
+
#)
|
| 71 |
|
| 72 |
+
client = genai.Client(api_key=os.environ["GOOGLE_API_KEY"])
|
| 73 |
|
| 74 |
+
response = client.models.generate_content(
|
| 75 |
+
model=model,
|
| 76 |
+
contents=[prompt_template]
|
| 77 |
+
)
|
| 78 |
|
| 79 |
+
#return completion.choices[0].message.content
|
| 80 |
|
| 81 |
+
return response.text
|