naveenvenkatesh commited on
Commit
1979a04
·
verified ·
1 Parent(s): 66f3b9d

Update extract_date.py

Browse files
Files changed (1) hide show
  1. extract_date.py +15 -9
extract_date.py CHANGED
@@ -1,6 +1,5 @@
1
  from PyPDF2 import PdfReader
2
- from openai import OpenAI
3
- # import fitz # PyMuPDF
4
  import logging
5
 
6
  # Configure logging
@@ -33,7 +32,10 @@ class ExtractDateAndDuration:
33
  """
34
  Initialize the ExtractDateAndDuration class.
35
  """
36
- self.client=OpenAI()
 
 
 
37
 
38
 
39
  def get_date_and_duration(self, contract_text: str) -> str:
@@ -58,12 +60,16 @@ class ExtractDateAndDuration:
58
  ]
59
 
60
  # Call OpenAI GPT-3.5-turbo
61
- chat_completion = client.chat.completions.create(
62
- model = "gpt-3.5-turbo",
63
- messages = conversation,
64
- max_tokens=1000,
65
- temperature=0
66
- )
 
 
 
 
67
  response = chat_completion.choices[0].message.content
68
  return response
69
 
 
1
  from PyPDF2 import PdfReader
2
+ import openai
 
3
  import logging
4
 
5
  # Configure logging
 
32
  """
33
  Initialize the ExtractDateAndDuration class.
34
  """
35
+ openai.api_type = os.getenv['api_type']
36
+ openai.api_base = os.getenv['api_base']
37
+ openai.api_version = os.getenv['api_version']
38
+ openai.api_key = os.getenv['api_key']
39
 
40
 
41
  def get_date_and_duration(self, contract_text: str) -> str:
 
60
  ]
61
 
62
  # Call OpenAI GPT-3.5-turbo
63
+ chat_completion = openai.ChatCompletion.create(
64
+ engine="ChatGPT",
65
+ messages = conversation,
66
+ temperature=0.7,
67
+ max_tokens=800,
68
+ top_p=0.95,
69
+ frequency_penalty=0,
70
+ presence_penalty=0,
71
+ stop=None
72
+ )
73
  response = chat_completion.choices[0].message.content
74
  return response
75