Jan Štihec commited on
Commit
c578d7a
1 Parent(s): 1e85b1a

GPTHelper update

Browse files
Files changed (1) hide show
  1. GPTHelper.py +8 -8
GPTHelper.py CHANGED
@@ -17,7 +17,7 @@ def gpt35_rephrase(fact):
17
  prompt = open_file('prompts/gpt35_rephrase.txt').replace('<<FACT>>', fact)
18
  try:
19
  response = openai.Completion.create(
20
- model="text-davinci-003",
21
  prompt=prompt,
22
  max_tokens=250,
23
  temperature=0
@@ -36,7 +36,7 @@ def gpt35_rephrase(fact):
36
  return response
37
 
38
  except Exception as e:
39
- logging.error("Error communicating with OpenAI (rephrase): ", exc_info=e)
40
 
41
 
42
  def gpt35_check_fact(evidence, fact):
@@ -47,7 +47,7 @@ def gpt35_check_fact(evidence, fact):
47
  model="text-davinci-003",
48
  prompt=prompt,
49
  max_tokens=3, # Don't need more for Entails/Contradicts/Undetermined
50
- temperature=0 # Higher temperature would not increase prediction accuracy.
51
  )
52
  response = response['choices'][0]['text'].strip()
53
  response = response.replace('.', '')
@@ -56,13 +56,13 @@ def gpt35_check_fact(evidence, fact):
56
  if not os.path.exists('gpt3_factchecking_logs'):
57
  os.makedirs('gpt3_factchecking_logs')
58
 
59
- with open('gpt3_factchecking_logs/%s' % filename, 'w', encoding="utf-8") as outfile:
60
  outfile.write('PROMPT:\n\n' + prompt + '\n\n###############\n\nRESPONSE:\n\n' + response)
61
 
62
  return response
63
 
64
  except Exception as e:
65
- logging.error("Error communicating with OpenAI (check_fact): ", exc_info=e)
66
 
67
 
68
  def gpt35_turbo_rephrase(fact):
@@ -72,8 +72,8 @@ def gpt35_turbo_rephrase(fact):
72
  response = openai.ChatCompletion.create(
73
  model="gpt-3.5-turbo",
74
  messages=[
75
- {"role": "user",
76
- "content": prompt}
77
  ]
78
  )
79
  response = response['choices'][0]['message']['content'].strip()
@@ -88,4 +88,4 @@ def gpt35_turbo_rephrase(fact):
88
  return response
89
 
90
  except Exception as e:
91
- logging.error("Error communicating with OpenAI (gpt35_rephrase): ", exc_info=e)
 
17
  prompt = open_file('prompts/gpt35_rephrase.txt').replace('<<FACT>>', fact)
18
  try:
19
  response = openai.Completion.create(
20
+ model='text-davinci-003',
21
  prompt=prompt,
22
  max_tokens=250,
23
  temperature=0
 
36
  return response
37
 
38
  except Exception as e:
39
+ logging.error('Error communicating with OpenAI (rephrase): ', exc_info=e)
40
 
41
 
42
  def gpt35_check_fact(evidence, fact):
 
47
  model="text-davinci-003",
48
  prompt=prompt,
49
  max_tokens=3, # Don't need more for Entails/Contradicts/Undetermined
50
+ temperature=0
51
  )
52
  response = response['choices'][0]['text'].strip()
53
  response = response.replace('.', '')
 
56
  if not os.path.exists('gpt3_factchecking_logs'):
57
  os.makedirs('gpt3_factchecking_logs')
58
 
59
+ with open('gpt3_factchecking_logs/%s' % filename, 'w', encoding='utf-8') as outfile:
60
  outfile.write('PROMPT:\n\n' + prompt + '\n\n###############\n\nRESPONSE:\n\n' + response)
61
 
62
  return response
63
 
64
  except Exception as e:
65
+ logging.error('Error communicating with OpenAI (check_fact): ', exc_info=e)
66
 
67
 
68
  def gpt35_turbo_rephrase(fact):
 
72
  response = openai.ChatCompletion.create(
73
  model="gpt-3.5-turbo",
74
  messages=[
75
+ {'role': 'user',
76
+ 'content': prompt}
77
  ]
78
  )
79
  response = response['choices'][0]['message']['content'].strip()
 
88
  return response
89
 
90
  except Exception as e:
91
+ logging.error('Error communicating with OpenAI (gpt35_rephrase): ', exc_info=e)