-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnon_anthropic_eval.py
51 lines (34 loc) · 1.2 KB
/
non_anthropic_eval.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
import deepinfra
from openai import OpenAI
import time
import llmarithmetic
# Create an OpenAI client with your deepinfra token and endpoint
openai = OpenAI(
api_key="API_KEY"
# Can use deepinfra if you want nonOpenAI models
#base_url="https://api.deepinfra.com/v1/openai",
)
# Should this be used in a system message here?
SYSTEM_PROMPT = [{"role": "system", "content": "You are a helpful assistant."}]
total = 0
matches = 0
errors = 0
for i in range(300):
total += 1
time.sleep(.01)
prompt, expected = llmarithmetic.construct_prompt(7, 9, "*", commas=False)
response = openai.chat.completions.create(
model="gpt-3.5-turbo", # "gpt-4",# "gpt-4o", #"meta-llama/Meta-Llama-3-70B-Instruct",
# Anthropic's API passes the system prompt directly.
messages= SYSTEM_PROMPT + prompt,
#sys
)
response_text = response_content = response.choices[0].message.content
if llmarithmetic.compare_responses(response_text, expected):
matches += 1
print("%s matched :D" % i)
else:
print("%s did not match %s" % (response_text, expected))
#print("Diff of %s" % (actual - resp_num))
print("Proportion corect = %s" % (matches/total))
print("Errors = %s" % errors)