-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquickstart.py
75 lines (57 loc) · 1.71 KB
/
quickstart.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import json
import os
from dotenv import load_dotenv
from openai import OpenAI
from betamark import arc_agi
load_dotenv()
EVAL_CHALELNGES_FILEPATH = "data/arc-agi_evaluation_challenges.json"
eval_challenges_json = json.load(open(EVAL_CHALELNGES_FILEPATH, "r"))
def zero_shot_gpt_predict(input_dict):
PROMPT = """
What is the output to this sequence?
Only answer as a double list
"""
for i in range(len(input_dict["train"])):
input = input_dict["train"][i]["input"]
PROMPT += f'\n"input": {input}'
output = input_dict["train"][i]["output"]
PROMPT += f'\n"output": {output}'
PROMPT += f'\n"input": {input_dict["test"][0]["input"]}'
print(PROMPT)
client = OpenAI(
# This is the default and can be omitted
api_key=os.environ.get("OPENAI_API_KEY_ARC"),
)
try:
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": PROMPT,
}
],
model="gpt-4o-mini",
)
except:
return [[0]]
print("######")
print(chat_completion.choices[0].message.content)
list_repr_string = chat_completion.choices[0].message.content
list_repr_string = (
list_repr_string.replace("```json", "")
.replace("```python", "")
.replace("```", "")
)
try:
list_repr = eval(list_repr_string)
print(list_repr)
print(type(list_repr))
return list_repr
except:
pass
print("error!")
return [[0]]
return [[0]]
if __name__ == "__main__":
results = arc_agi.run_eval(user_func=zero_shot_gpt_predict)
print(results)