BredForCompanionship commited on
Commit
9628ad8
1 Parent(s): 0691591

Update metric.py

Browse files
Files changed (1) hide show
  1. metric.py +7 -6
metric.py CHANGED
@@ -1,5 +1,6 @@
1
- from openai import Completion
2
- openai.api_key = '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'
 
3
 
4
  import pandas as pd
5
  from huggingface_hub import hf_hub_download
@@ -32,17 +33,17 @@ def compute(params):
32
  prompt=f"Give me a score from 1 to 10 (higher is better) judging how similar these two captions are. Caption one: {submitted_answer}. Caption two: {gt}\nScore:"
33
 
34
  try:
35
- response = Completion.create(
36
- engine="text-davinci-003",
37
  prompt=prompt,
38
  temperature=0,
39
  max_tokens=1,
40
  )
41
 
42
- public_score = int(response['choices'][0]['text'].strip())
43
 
44
  except:
45
- print("Error:", e)
46
 
47
  private_score = public_score
48
 
 
1
+ from openai import OpenAI
2
+ client = OpenAI()
3
+ OpenAI.api_key = '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'
4
 
5
  import pandas as pd
6
  from huggingface_hub import hf_hub_download
 
33
  prompt=f"Give me a score from 1 to 10 (higher is better) judging how similar these two captions are. Caption one: {submitted_answer}. Caption two: {gt}\nScore:"
34
 
35
  try:
36
+ response = client.completions.create(
37
+ engine="gpt-3.5-turbo-instruct",
38
  prompt=prompt,
39
  temperature=0,
40
  max_tokens=1,
41
  )
42
 
43
+ public_score = int(response.choices[0].text.strip())
44
 
45
  except:
46
+ print("Error w/ api")
47
 
48
  private_score = public_score
49