Spaces:
Running
Running
naveenvenkatesh
commited on
Commit
•
f8d40ff
1
Parent(s):
f67b4b0
Update aggressive_content_finder.py
Browse files- aggressive_content_finder.py +15 -11
aggressive_content_finder.py
CHANGED
@@ -14,8 +14,7 @@ class AggressiveContentFinder:
|
|
14 |
"""
|
15 |
Initialize the AggressiveContentFinder with your OpenAI API key.
|
16 |
"""
|
17 |
-
|
18 |
-
pass
|
19 |
|
20 |
def _extract_aggressive_content(self, contract_text: str) -> str:
|
21 |
"""
|
@@ -28,17 +27,22 @@ class AggressiveContentFinder:
|
|
28 |
str: Identified aggressive terms.
|
29 |
"""
|
30 |
try:
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
temperature=0
|
39 |
)
|
40 |
-
|
41 |
-
return
|
|
|
42 |
except Exception as e:
|
43 |
print(f"An error occurred during text analysis: {str(e)}")
|
44 |
|
|
|
14 |
"""
|
15 |
Initialize the AggressiveContentFinder with your OpenAI API key.
|
16 |
"""
|
17 |
+
self.client = OpenAI()
|
|
|
18 |
|
19 |
def _extract_aggressive_content(self, contract_text: str) -> str:
|
20 |
"""
|
|
|
27 |
str: Identified aggressive terms.
|
28 |
"""
|
29 |
try:
|
30 |
+
conversation = [
|
31 |
+
{"role": "system", "content": "You are a helpful Aggressive Terms Finder in Given Contract."},
|
32 |
+
{"role": "user", "content": f"""This is a contract document content. Your task is to identify aggressive terms like warning terms, penalties in the given contract:
|
33 |
+
```contract: {contract_text}```"""}
|
34 |
+
]
|
35 |
+
|
36 |
+
# Call OpenAI GPT-3.5-turbo
|
37 |
+
chat_completion = self.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 |
+
|
46 |
except Exception as e:
|
47 |
print(f"An error occurred during text analysis: {str(e)}")
|
48 |
|