Spaces:
Sleeping
Sleeping
Update key_value_extractor.py
Browse files- key_value_extractor.py +16 -10
key_value_extractor.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
import os
|
| 3 |
|
| 4 |
|
|
@@ -8,9 +8,11 @@ class KeyValue:
|
|
| 8 |
"""
|
| 9 |
Initialize the Extractor class.
|
| 10 |
"""
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
| 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 =
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 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 |
|