naveenvenkatesh commited on
Commit
8720566
1 Parent(s): 10bbb62

Update incompletesentencefinder.py

Browse files
Files changed (1) hide show
  1. incompletesentencefinder.py +16 -8
incompletesentencefinder.py CHANGED
@@ -1,5 +1,5 @@
1
  from PyPDF2 import PdfReader
2
- from openai import OpenAI
3
  import gradio as gr
4
 
5
  class IncompleteSentenceFinder:
@@ -17,7 +17,11 @@ class IncompleteSentenceFinder:
17
  Args:
18
  api_key (str): Your OpenAI API key.
19
  """
20
- self.client = OpenAI()
 
 
 
 
21
 
22
  def _check_incomplete_sentence(self, text: str) -> str:
23
 
@@ -36,12 +40,16 @@ class IncompleteSentenceFinder:
36
  ]
37
 
38
  # Call OpenAI GPT-3.5-turbo
39
- chat_completion = self.client.chat.completions.create(
40
- model = "gpt-3.5-turbo",
41
- messages = conversation,
42
- max_tokens=500,
43
- temperature=0
44
- )
 
 
 
 
45
  response = chat_completion.choices[0].message.content
46
  return response
47
 
 
1
  from PyPDF2 import PdfReader
2
+ import openai
3
  import gradio as gr
4
 
5
  class IncompleteSentenceFinder:
 
17
  Args:
18
  api_key (str): Your OpenAI API key.
19
  """
20
+
21
+ openai.api_type = os.getenv['api_type']
22
+ openai.api_base = os.getenv['api_base']
23
+ openai.api_version = os.getenv['api_version']
24
+ openai.api_key = os.getenv['api_key']
25
 
26
  def _check_incomplete_sentence(self, text: str) -> str:
27
 
 
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