naveenvenkatesh commited on
Commit
df50b14
·
verified ·
1 Parent(s): 5ca540d

Update key_value_extractor.py

Browse files
Files changed (1) hide show
  1. key_value_extractor.py +16 -10
key_value_extractor.py CHANGED
@@ -1,4 +1,4 @@
1
- from openai import OpenAI
2
  import os
3
 
4
 
@@ -8,9 +8,11 @@ class KeyValue:
8
  """
9
  Initialize the Extractor class.
10
  """
11
-
12
- # Set OpenAI API key
13
- # os.environ["OPENAI_API_KEY"] = ""
 
 
14
 
15
  def extract_key_value_pair(extracted_summary):
16
  """
@@ -27,12 +29,16 @@ class KeyValue:
27
  ]
28
 
29
  # Call OpenAI GPT-3.5-turbo
30
- chat_completion = self.client.chat.completions.create(
31
- model = "gpt-3.5-turbo",
32
- messages = conversation,
33
- max_tokens=500,
34
- temperature=0
35
- )
 
 
 
 
36
  response = chat_completion.choices[0].message.content
37
  return response
38
 
 
1
+ import openai
2
  import os
3
 
4
 
 
8
  """
9
  Initialize the Extractor class.
10
  """
11
+
12
+ openai.api_type = os.getenv['api_type']
13
+ openai.api_base = os.getenv['api_base']
14
+ openai.api_version = os.getenv['api_version']
15
+ openai.api_key = os.getenv['api_key']
16
 
17
  def extract_key_value_pair(extracted_summary):
18
  """
 
29
  ]
30
 
31
  # Call OpenAI GPT-3.5-turbo
32
+ chat_completion = openai.ChatCompletion.create(
33
+ engine="ChatGPT",
34
+ messages = conversation,
35
+ temperature=0.7,
36
+ max_tokens=800,
37
+ top_p=0.95,
38
+ frequency_penalty=0,
39
+ presence_penalty=0,
40
+ stop=None
41
+ )
42
  response = chat_completion.choices[0].message.content
43
  return response
44