Spaces:
Running
Running
KarthickAdopleAI
commited on
Update key_value_extractor.py
Browse files- key_value_extractor.py +11 -12
key_value_extractor.py
CHANGED
@@ -22,24 +22,23 @@ class KeyValue:
|
|
22 |
Prints the extracted key-value pairs.
|
23 |
"""
|
24 |
try:
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
conversation = [
|
28 |
{"role": "system", "content": "You are a helpful Keywords Extracter."},
|
29 |
{"role": "user", "content": f"""analyze the given contract and Extract Keywords for following contract in triple backticks. tags should be bullet points.contract :```{extracted_summary}```."""}
|
30 |
]
|
31 |
|
32 |
# Call OpenAI GPT-3.5-turbo
|
33 |
-
chat_completion =
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
frequency_penalty=0,
|
40 |
-
presence_penalty=0,
|
41 |
-
stop=None
|
42 |
-
)
|
43 |
response = chat_completion.choices[0].message.content
|
44 |
return response
|
45 |
|
|
|
22 |
Prints the extracted key-value pairs.
|
23 |
"""
|
24 |
try:
|
25 |
+
client = AzureOpenAI(api_key=os.getenv("AZURE_OPENAI_KEY"),
|
26 |
+
api_version="2023-07-01-preview",
|
27 |
+
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
|
28 |
+
)
|
29 |
+
|
30 |
conversation = [
|
31 |
{"role": "system", "content": "You are a helpful Keywords Extracter."},
|
32 |
{"role": "user", "content": f"""analyze the given contract and Extract Keywords for following contract in triple backticks. tags should be bullet points.contract :```{extracted_summary}```."""}
|
33 |
]
|
34 |
|
35 |
# Call OpenAI GPT-3.5-turbo
|
36 |
+
chat_completion = client.chat.completions.create(
|
37 |
+
model = "ChatGPT",
|
38 |
+
messages = conversation,
|
39 |
+
max_tokens=1000,
|
40 |
+
temperature=0
|
41 |
+
)
|
|
|
|
|
|
|
|
|
42 |
response = chat_completion.choices[0].message.content
|
43 |
return response
|
44 |
|