naveenvenkatesh commited on
Commit
5ca540d
1 Parent(s): 8720566

Update incorrect_sentence_finder.py

Browse files
Files changed (1) hide show
  1. incorrect_sentence_finder.py +16 -9
incorrect_sentence_finder.py CHANGED
@@ -1,5 +1,5 @@
1
  from PyPDF2 import PdfReader
2
- from openai import OpenAI
3
  import gradio as gr
4
 
5
  class IncorrectSentenceFinder:
@@ -14,8 +14,11 @@ class IncorrectSentenceFinder:
14
  """
15
  Initialize the IncorrectSentenceFinder with the OpenAI API key.
16
  """
17
- # openai.api_key = openai_api_key
18
- self.client=OpenAI()
 
 
 
19
 
20
  def _find_incorrect_sentence(self, text: str) -> str:
21
  """
@@ -37,12 +40,16 @@ class IncorrectSentenceFinder:
37
  ]
38
 
39
  # Call OpenAI GPT-3.5-turbo
40
- chat_completion =client.chat.completions.create(
41
- model = "gpt-3.5-turbo",
42
- messages = conversation,
43
- max_tokens=500,
44
- temperature=0
45
- )
 
 
 
 
46
  response = chat_completion.choices[0].message.content
47
  return response
48
 
 
1
  from PyPDF2 import PdfReader
2
+ import openai
3
  import gradio as gr
4
 
5
  class IncorrectSentenceFinder:
 
14
  """
15
  Initialize the IncorrectSentenceFinder with the OpenAI API key.
16
  """
17
+
18
+ openai.api_type = os.getenv['api_type']
19
+ openai.api_base = os.getenv['api_base']
20
+ openai.api_version = os.getenv['api_version']
21
+ openai.api_key = os.getenv['api_key']
22
 
23
  def _find_incorrect_sentence(self, text: str) -> str:
24
  """
 
40
  ]
41
 
42
  # Call OpenAI GPT-3.5-turbo
43
+ chat_completion =openai.ChatCompletion.create(
44
+ engine="ChatGPT",
45
+ messages = conversation,
46
+ temperature=0.7,
47
+ max_tokens=800,
48
+ top_p=0.95,
49
+ frequency_penalty=0,
50
+ presence_penalty=0,
51
+ stop=None
52
+ )
53
  response = chat_completion.choices[0].message.content
54
  return response
55