|
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 |