BredForCompanionship commited on
Commit
51ae812
1 Parent(s): 83f308a

Upload metric.py

Browse files
Files changed (1) hide show
  1. metric.py +22 -0
metric.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ openai.api_key = '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'
3
+
4
+ def compute_metric(params):
5
+ public_score = 0
6
+ private_score = 0
7
+
8
+ response = openai.Completion.create(
9
+ engine="text-davinci-003",
10
+ prompt="Rank the following statement on accuracy, with 10 being the most accurate and 0 the least: 'World War 2 ended in 1954.'\nScore:",
11
+ temperature=0,
12
+ max_tokens=1,
13
+ )
14
+
15
+ public_score = int(response.choices[0].text.strip())
16
+
17
+ metric_dict = {
18
+ "public_score": {"metric1": public_score},
19
+ "private_score": {"metric1": private_score}
20
+ }
21
+
22
+ return metric_dict