Spaces:
Running
Running
naveenvenkatesh
commited on
Commit
•
194d1cf
1
Parent(s):
f638900
Update ContractGenerator.py
Browse files- ContractGenerator.py +18 -16
ContractGenerator.py
CHANGED
@@ -12,7 +12,7 @@ class ContractGenerator:
|
|
12 |
Args:
|
13 |
api_key (str): Your OpenAI API key.
|
14 |
"""
|
15 |
-
|
16 |
|
17 |
def generate_contract(self, instructions: str) -> None:
|
18 |
"""
|
@@ -25,19 +25,21 @@ class ContractGenerator:
|
|
25 |
openai.error.OpenAIError: If there is an error with the OpenAI API request.
|
26 |
"""
|
27 |
# Define a prompt
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
43 |
|
|
|
12 |
Args:
|
13 |
api_key (str): Your OpenAI API key.
|
14 |
"""
|
15 |
+
self.client = OpenAI()
|
16 |
|
17 |
def generate_contract(self, instructions: str) -> None:
|
18 |
"""
|
|
|
25 |
openai.error.OpenAIError: If there is an error with the OpenAI API request.
|
26 |
"""
|
27 |
# Define a prompt
|
28 |
+
client = OpenAI()
|
29 |
+
os.environ["OPENAI_API_KEY"]="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"
|
30 |
+
|
31 |
+
conversation = [
|
32 |
+
{"role": "system", "content": "You are a helpful Contract Generator."},
|
33 |
+
{"role": "user", "content": f"""Your task is to generate a contract form based on user instructions. ***Instructions:{instructions}***"""}
|
34 |
+
]
|
35 |
+
|
36 |
+
# Call OpenAI GPT-3.5-turbo
|
37 |
+
chat_completion = client.chat.completions.create(
|
38 |
+
model = "gpt-3.5-turbo",
|
39 |
+
messages = conversation,
|
40 |
+
max_tokens=500,
|
41 |
+
temperature=0
|
42 |
+
)
|
43 |
+
response = chat_completion.choices[0].message.content
|
44 |
+
return response
|
45 |
|