Spaces:
Running
Running
KarthickAdopleAI
commited on
Update extract_date.py
Browse files- extract_date.py +11 -10
extract_date.py
CHANGED
@@ -50,6 +50,11 @@ class ExtractDateAndDuration:
|
|
50 |
str: Extracted dates and durations.
|
51 |
"""
|
52 |
try:
|
|
|
|
|
|
|
|
|
|
|
53 |
conversation = [
|
54 |
{"role": "system", "content": "You are a helpful assistant."},
|
55 |
{"role": "user", "content": f"""Your task is Identify Dates and Durations Mentioned in the contract and extract that date and duration in key-value pair.
|
@@ -61,16 +66,12 @@ class ExtractDateAndDuration:
|
|
61 |
]
|
62 |
|
63 |
# Call OpenAI GPT-3.5-turbo
|
64 |
-
chat_completion =
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
frequency_penalty=0,
|
71 |
-
presence_penalty=0,
|
72 |
-
stop=None
|
73 |
-
)
|
74 |
response = chat_completion.choices[0].message.content
|
75 |
return response
|
76 |
|
|
|
50 |
str: Extracted dates and durations.
|
51 |
"""
|
52 |
try:
|
53 |
+
client = AzureOpenAI(api_key=os.getenv("AZURE_OPENAI_KEY"),
|
54 |
+
api_version="2023-07-01-preview",
|
55 |
+
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
|
56 |
+
)
|
57 |
+
|
58 |
conversation = [
|
59 |
{"role": "system", "content": "You are a helpful assistant."},
|
60 |
{"role": "user", "content": f"""Your task is Identify Dates and Durations Mentioned in the contract and extract that date and duration in key-value pair.
|
|
|
66 |
]
|
67 |
|
68 |
# Call OpenAI GPT-3.5-turbo
|
69 |
+
chat_completion = client.chat.completions.create(
|
70 |
+
model = "ChatGPT",
|
71 |
+
messages = conversation,
|
72 |
+
max_tokens=1000,
|
73 |
+
temperature=0
|
74 |
+
)
|
|
|
|
|
|
|
|
|
75 |
response = chat_completion.choices[0].message.content
|
76 |
return response
|
77 |
|