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