Megan Ma commited on
Commit
871b8ae
0 Parent(s):

a brand new start

Browse files
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ *.wav
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Negotiation Agent
3
+ emoji: 🔥
4
+ colorFrom: red
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: 4.36.1
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,421 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import gradio as gr
3
+ import uuid
4
+ import time
5
+ import IPython
6
+ from playsound import playsound
7
+ import threading
8
+ from scipy.io import wavfile
9
+
10
+
11
+ #tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False)#.to("cuda")
12
+
13
+ conv_uuid = str(uuid.uuid4())
14
+
15
+ import os
16
+
17
+ # Replace with your key
18
+ # openai.api_key = os.getenv('openai_api')
19
+
20
+ seller_prompt_path = "./prompts/seller_prompt_no_meat.txt"
21
+
22
+ extras_for_senior = """
23
+ Cybersecurity Incident: During the negotiation of the Letter of Intent, the seller disclosed that there was a breach in their customer data. Email addresses from the customer’s data that was exposed totalled no more than 200. No other personal identifiable information was exfiltrated. That client has since filed a claim requesting for compensation related to damages from this breach. TechEase has disclosed the privacy breach to its customer base, has taken remedial action to prevent another breach and correct the security weaknesses in its infrastructure, and has complied with all relevant regulatory requirements concerning the breach.
24
+ """
25
+
26
+ extras_for_partner = """
27
+ Multiple Cybersecurity Breaches/Weak security infrastructure
28
+
29
+ Your associate had just informed you of the current status of the deal:
30
+ Quasi-fundamental reps and warranties related to cybersecurity, IP, and privacy are already set up
31
+ Special indemnities are also already set up for cybersecurity and privacy
32
+ TechEase has cybersecurity and privacy insurance
33
+ Recently, new problems have come up with TechEase, and we need your expertise to renegotiate
34
+
35
+ TechEase’s AI platform has unique product functionalities and a fast-growing customer base. Security infrastructure is not its focus. Accordingly, there are key issues to be discussed with regards to infiltrations into its system and what type of information technology security infrastructure is in place. TechEase just advised ShopMaster of multiple occurrences of prior breaches to its security infrastructure and it does not know what data, if any, was exfiltrated. Several clients have just switched to TechEase’s competitors given the historical weaknesses of its security infrastructure. Most clients, though, are still enthusiastic about continuous improvements of its core AI product. TechEase has also disclosed the security breaches to its customer base, and has taken remedial action to prevent another breach. However, TechEase does not have the talent to investigate the root causes behind multiple breaches. ShopMaster is deeply concerned and wants to drop the deal. However, ShopMaster is still interested in TechEase’s AI platform, but does not want to deal with the security issues related to the company.
36
+ """
37
+
38
+ with open(seller_prompt_path, 'r') as f:
39
+ seller_prompt = f.read()
40
+
41
+ seller_prompt_path_markdown = "./prompts/seller_prompt_no_meat_markdown.txt"
42
+
43
+ with open(seller_prompt_path_markdown, 'r') as f:
44
+ seller_prompt_markdown = f.read()
45
+
46
+ seller_meat_1 = "./prompts/seller_meat_1.txt"
47
+
48
+ with open(seller_meat_1, 'r') as f:
49
+ seller_meat_1 = f.read()
50
+
51
+ seller_meat_1_markdown = "./prompts/seller_meat_1_markdown.txt"
52
+
53
+ with open(seller_meat_1_markdown, 'r') as f:
54
+ seller_meat_1_markdown = f.read()
55
+
56
+ hint_counter = 0
57
+
58
+
59
+
60
+ initial_prompt = os.getenv("system_prompt")
61
+
62
+ #def play_sound_in_background():
63
+ # playsound("output.wav")
64
+
65
+ def predict(message, history, username, bdi_checkbox_value, api_box):
66
+ global initial_prompt
67
+ openai.api_key = api_box
68
+ chatinterface.additional_inputs[0].value = username
69
+ history_openai_format = []
70
+ if level_dropdown.value == 'Senior':
71
+ initial_prompt += extras_for_senior
72
+ elif level_dropdown.value == 'Partner':
73
+ initial_prompt += extras_for_partner
74
+
75
+ history_openai_format.append(
76
+ {"role": "system", "content": initial_prompt.replace("Philip", name_box.value)})
77
+
78
+ for human, assistant in history:
79
+ history_openai_format.append({"role": "user", "content": human})
80
+ history_openai_format.append(
81
+ {"role": "assistant", "content": assistant})
82
+ history_openai_format.append({"role": "user", "content": message})
83
+
84
+ response = openai.ChatCompletion.create(
85
+ model='gpt-4o',
86
+ messages=history_openai_format,
87
+ temperature=0.8,
88
+ stream=True
89
+ )
90
+
91
+
92
+ partial_message = ""
93
+ print(bdi_checkbox_value)
94
+ for chunk in response:
95
+ if len(chunk['choices'][0]['delta']) != 0:
96
+ partial_message = partial_message + \
97
+ chunk['choices'][0]['delta']['content']
98
+
99
+ user_name_no_space = username.replace(" ","_")
100
+ file_name = f"{user_name_no_space}_{conv_uuid}.txt"
101
+
102
+ if bdi_checkbox_value:
103
+ # save user history and new text with username.txt
104
+ with open(file_name, "a") as f:
105
+ f.write(f"User: {message}\n")
106
+ f.write(f"Assistant: {partial_message}\n")
107
+
108
+ # before returning let's save an audio and play it
109
+ # tts.tts_to_file(partial_message, speaker_wav="/home/hammh0a/Downloads/New Recording 2 (1).wav", language="en", file_path="output.wav")
110
+ # threading.Thread(target=play_sound_in_background, args=(), daemon=True).start()
111
+ # audio_button.value = "output.wav"
112
+ return partial_message
113
+ else:
114
+ # save user history and new text with username.txt
115
+ remove_bdi = partial_message.split("Response:")[-1]
116
+ try:
117
+ with open(file_name, "a") as f:
118
+ f.write(f"User: {message}\n")
119
+ f.write(f"Assistant: {partial_message}\n")
120
+ except:
121
+ pass
122
+
123
+ # tts.tts_to_file(remove_bdi, speaker_wav="/home/hammh0a/Downloads/New Recording 2 (1).wav", language="en", file_path="output.wav")
124
+ # threading.Thread(target=play_sound_in_background, args=(), daemon=True).start()
125
+ # audio_button.value = "output.wav"
126
+
127
+ return remove_bdi
128
+
129
+
130
+
131
+ #def read_audio_again(audio_button):
132
+ # return wavfile.read("output.wav")
133
+
134
+ # gr.ChatInterface(predict).queue().launch()
135
+
136
+ def vote(data: gr.LikeData):
137
+ if data.liked:
138
+ print("You upvoted this response: " + data.value)
139
+ else:
140
+ print("You downvoted this response: " + data.value)
141
+
142
+
143
+ def update_name(name):
144
+ # This function will be called when the user types in the name_box
145
+ return name
146
+
147
+
148
+ negotiation_areas = {
149
+ "Junior": "(1) Defining type of representations and warranties (fundamental, general and possibly quasi). \n(2) [More Advanced, Second-Layer Negotiation]:Setting parameters of liability. \n(3)Survival period, cap on liability, and basket.",
150
+ "Senior": "(1) Mitigation of the incident (i.e. known risk): indemnification clause (e.g. survival period, cap, holdback, basket). \n(2) Managing vulnerability exposed (i.e. unknown risk): renegotiation of reps and warranties regarding cybersecurity and privacy ",
151
+ "Partner": "Deal Structure"
152
+ }
153
+
154
+ # def issue_change(rs):
155
+ # return gr.update(choices=general_issues[rs], value=None)
156
+
157
+ # def update_textbox_issues(issue_selection):
158
+
159
+ # issue_textbox.value = specific_issues.get(issue_selection, "Invalid Selection")
160
+ # issue_dropdown.value = issue_selection
161
+
162
+ # return specific_issues.get(issue_selection, "Invalid Selection")
163
+
164
+ def update_incident(selection):
165
+ if selection == "Junior":
166
+ markdown_incident.value = ""
167
+ elif selection == "Senior":
168
+ markdown_incident.value ="""During the negotiation of the Letter of Intent, the seller disclosed that there was a breach in their customer data. Email addresses from the customer’s data that was exposed totalled no more than 200. No other personal identifiable information was exfiltrated. That client has since filed a claim requesting for compensation related to damages from this breach. TechEase has disclosed the privacy breach to its customer base, has taken remedial action to prevent another breach and correct the security weaknesses in its infrastructure, and has complied with all relevant regulatory requirements concerning the breach. """
169
+ elif selection == "Partner":
170
+ markdown_incident.value = """Multiple Cybersecurity Breaches/Weak security infrastructure
171
+
172
+ Your associate had just informed you of the current status of the deal:
173
+ Quasi-fundamental reps and warranties related to cybersecurity, IP, and privacy are already set up
174
+ Special indemnities are also already set up for cybersecurity and privacy
175
+ TechEase has cybersecurity and privacy insurance
176
+ Recently, new problems have come up with TechEase, and we need your expertise to renegotiate
177
+
178
+ TechEase’s AI platform has unique product functionalities and a fast-growing customer base. Security infrastructure is not its focus. Accordingly, there are key issues to be discussed with regards to infiltrations into its system and what type of information technology security infrastructure is in place. TechEase just advised ShopMaster of multiple occurrences of prior breaches to its security infrastructure and it does not know what data, if any, was exfiltrated. Several clients have just switched to TechEase’s competitors given the historical weaknesses of its security infrastructure. Most clients, though, are still enthusiastic about continuous improvements of its core AI product. TechEase has also disclosed the security breaches to its customer base, and has taken remedial action to prevent another breach. However, TechEase does not have the talent to investigate the root causes behind multiple breaches. ShopMaster is deeply concerned and wants to drop the deal. However, ShopMaster is still interested in TechEase’s AI platform, but does not want to deal with the security issues related to the company.
179
+ """
180
+
181
+ if selection == "Junior":
182
+ return gr.Textbox.update(visible = False)#markdown_incident.value
183
+ else:
184
+ return gr.Textbox.update(value = markdown_incident.value, visible = True)
185
+
186
+
187
+ def update_markdown_notice(selection):
188
+ if selection == "Junior":
189
+ markdown_notice.value = seller_meat_1_markdown
190
+ elif selection == "Senior":
191
+ markdown_notice.value = seller_meat_1_markdown
192
+ elif selection == "Partner":
193
+ markdown_notice.value = ""
194
+
195
+ return markdown_notice.value
196
+
197
+ # Step 1 - Based on the level of the user, display the main focus
198
+ def update_textbox_focuses(selection):
199
+ global hint_counter
200
+ hint_counter = 0 # Reset the hint counter
201
+ focuses = {
202
+ "Junior": "Types of representations and warranties.",
203
+ "Senior": "Cybersecurity incident.",
204
+ "Partner": "Multiple Cybersecurity Breaches/Weak security infrastructure.",
205
+ }
206
+
207
+ main_focus_textbox.value = focuses.get(selection, "Invalid selection")
208
+ return focuses.get(selection, "Invalid selection")
209
+
210
+ # Step 2 - Based on the main focus, display suggested areas of negotiation.
211
+ def update_textbox_negotiation_options(selection):
212
+ negotiation_areas_textbox.value = negotiation_areas.get(selection, "Invalid selection")
213
+ level_dropdown.value = selection
214
+
215
+ return negotiation_areas.get(selection, "Invalid selection")
216
+
217
+
218
+ # def update_textbox_disussion_options(selection):
219
+ # print(selection)
220
+ # discussion_options = {
221
+ # "Focus 1": "This is discussion option 1. \nThis is discussion option 2. ",
222
+ # "Focus 2": "This is discussion option 3. \nThis is discussion option 4.",
223
+ # "Focus 3": "This is discussion option 5. \nThis is discussion option 6.",
224
+ # "Focus 4": "This is discussion option 7. \nThis is discussion option 8.",
225
+ # }
226
+ # options.value = discussion_options.get(selection, "Invalid selection")
227
+ # main_focus_dropdown.value = selection
228
+
229
+ # return discussion_options.get(selection, "Invalid selection")
230
+
231
+ hints = {
232
+ "Junior": ["Hint 1: Remember the highlighted risk factors!", 'Sample Prompt 1: We propose the fundamental representations and warranties will include IP, cybersecurity, data privacy, regulatory/compliance, employee health and benefits, in addition to the traditional fundamental categories.', 'Sample Prompt 2: We propose the survival period for general representations to be set at 3 years.', 'Sample Prompt 3: We propose the cap on liability for general representations to be set at 50% of purchase Price with a 0.25% tipping basket.', 'Sample Prompt 4: We propose the cap on liability for fundamental representations to be set at 100% of purchase price with full duration of the statute of limitations and no basket.'],
233
+ "Senior": ['Hint 1: Consider there are two types of risks (known, unknown) that require mitigation.', "Hint 2: Recall distinction between standalone indemnities and reps and warranties.", "Hint 3: Recall there are different levels of reps and warranties which trigger different levels of protection.", "Hint 4: Consider elevating cybersecurity and privacy reps and warranties to fundamental."],
234
+ "Partner": ["No hints available for partners."]
235
+ }
236
+ def hint_click():
237
+ global hint_counter
238
+ # if level is junior then we have two hints else if senior only one hint and partner nothing.
239
+ if hint_counter == 0 and level_dropdown.value == "Junior":
240
+ hint_counter += 1
241
+ hint_textbox.value = hints.get(level_dropdown.value)[0]
242
+ elif hint_counter == 1 and level_dropdown.value == "Junior":
243
+ hint_counter += 1
244
+ hint_textbox.value = hints.get(level_dropdown.value)[1]
245
+ elif hint_counter == 2 and level_dropdown.value == "Junior":
246
+ hint_counter += 1
247
+ hint_textbox.value = hints.get(level_dropdown.value)[2]
248
+ elif hint_counter == 3 and level_dropdown.value == "Junior":
249
+ hint_counter += 1
250
+ hint_textbox.value = hints.get(level_dropdown.value)[3]
251
+ elif hint_counter == 4 and level_dropdown.value == "Junior":
252
+ hint_counter +=1
253
+ hint_textbox.value = hints.get(level_dropdown.value)[4]
254
+ elif hint_counter == 5 and level_dropdown.value == "Junior":
255
+ hint_counter = 0
256
+ hint_textbox.value = "No more hints available for this level."
257
+
258
+ elif hint_counter == 0 and level_dropdown.value == "Senior":
259
+ hint_counter += 1
260
+ hint_textbox.value = hints.get(level_dropdown.value)[0]
261
+ elif hint_counter == 1 and level_dropdown.value == "Senior":
262
+ hint_counter += 1
263
+ hint_textbox.value = hints.get(level_dropdown.value)[1]
264
+ elif hint_counter == 2 and level_dropdown.value == "Senior":
265
+ hint_counter += 1
266
+ hint_textbox.value = hints.get(level_dropdown.value)[2]
267
+ elif hint_counter == 3 and level_dropdown.value == "Senior":
268
+ hint_counter += 1
269
+ hint_textbox.value = hints.get(level_dropdown.value)[3]
270
+ elif hint_counter == 4 and level_dropdown.value == "Senior":
271
+ hint_counter = 0
272
+ hint_textbox.value = "No more hints available for this level."
273
+ elif level_dropdown.value == "Partner":
274
+ hint_textbox.value = "No hints available for partners."
275
+
276
+ return hint_textbox.value
277
+
278
+
279
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
280
+ with gr.Tab("Documentation"):
281
+
282
+ header = gr.Markdown()
283
+ header.value = """
284
+ <div style="border: 1px solid #ccc; box-shadow: 0 2px 5px rgba(0,0,0,0.2); background-color: #ffffff; padding: 15px; border-radius: 5px; margin: 10px 0;">
285
+
286
+ <p align="center">
287
+ <img src="https://i.ibb.co/H2b3PFZ/New-Project-1.jpg" alt="TechEase Logo" width="50%" height="auto"/>
288
+ </p>
289
+ """
290
+
291
+ documentation = gr.Markdown()
292
+ with open("./prompts/documentation_markdown.txt", "r") as f:
293
+ documentation.value = f.read()
294
+
295
+ with gr.Tab("App"):
296
+ header = gr.Markdown()
297
+ header.value = """
298
+ <div style="border: 1px solid #ccc; box-shadow: 0 2px 5px rgba(0,0,0,0.2); background-color: #ffffff; padding: 15px; border-radius: 5px; margin: 10px 0;">
299
+
300
+ <p align="center">
301
+ <img src="https://i.ibb.co/H2b3PFZ/New-Project-1.jpg" alt="TechEase Logo" width="50%" height="auto"/>
302
+ </p>
303
+ """
304
+
305
+
306
+ system_message = gr.Markdown()
307
+ system_message.value = """
308
+ <div style="background-color: #e9eeff; border: 2px solid black; box-shadow: 5px 5px 10px grey; padding: 15px; border-radius: 10px; font-family: 'Arial', sans-serif;">
309
+
310
+ ## Initial Setup
311
+
312
+ ### Parties and Background:
313
+
314
+ **Seller:** TechEase, Inc. is a privately-owned corporation that has developed and commercializes a proprietary SaaS solution for SMB retailers (small public facing businesses, like restaurants, antique shops, gift shops, etc.,that carry physical inventory)which manages all aspects of the clients’ Point of Sales (POS) activities, including customer registration, online ordering and shipping logistics. TechEase’s platform interacts directly with the retail public and retrieves, assembles and stores credit card and other sensitive personal information from the retail customers. TechEase has two owners.
315
+
316
+ **Buyer:** ShopMaster, Inc. plans to acquire TechEase, Inc. via an equity sale.The owners of TechEase will sell their shares of stock to ShopMaster. ShopMaster prefers the equity acquisition structure because it is less disruptive to Intellectual Property (IP), employee relationships, and existing client contracts, and will yield a more favorable tax outcome for the owners.
317
+
318
+ ---
319
+
320
+ ### Scenario:
321
+
322
+ ShopMaster, Inc. has identified TechEase, Inc. as a strategic acquisition target to extend its market presence and technology capabilities. The planned structure of the acquisition is an equity sale by the two owners. As the transaction is structured as an equity sale, ShopMaster, Inc. would become the new owner of TechEase. TechEase would become a wholly-owned subsidiary of ShopMaster. TechEase would remain in operation. This means that all liabilities of TechEase would stay in place (both known and unknown).
323
+
324
+ Because the TechEase platform interacts directly with the retail public, and stores sensitive customer information, ShopMaster is especially concerned about risks related to cyber security breaches and data privacy. Incidents or deficiencies in these areas could create massive legal and regulatory exposure for ShopMaster and potentially jeopardize the viability of the acquisition.
325
+ </div>
326
+ """
327
+ # User puts in their name
328
+ name_box = gr.Textbox(
329
+ label="Name", placeholder="Your name here", interactive=True)
330
+
331
+ api_box = gr.Textbox(
332
+ label="OpenAI API Key", placeholder="sk-", interactive=True, type='password')
333
+
334
+ # Level Dropdown - Select the level of the user
335
+ level_dropdown = gr.Dropdown(
336
+ choices=["Junior", "Senior", "Partner"], label="Please Select Level", interactive=True)
337
+
338
+
339
+
340
+ # If Junior or Senior, display the seller_prompt_markdown
341
+ markdown_notice = gr.Markdown()
342
+ level_dropdown.change(fn=update_markdown_notice, inputs=[level_dropdown], outputs=[markdown_notice])
343
+
344
+ markdown_meat = gr.Markdown()
345
+ # markdown_meat.value = seller_meat_1_markdown
346
+
347
+
348
+ # Based on the Level - Display the Main Focus
349
+ main_focus_textbox = gr.Textbox(label="Main Focus")
350
+ level_dropdown.change(fn=update_textbox_focuses, inputs=[level_dropdown], outputs=[main_focus_textbox])
351
+
352
+ markdown_incident = gr.Textbox(label="Incident", visible=False)
353
+ level_dropdown.change(fn=update_incident, inputs=[level_dropdown], outputs=[markdown_incident])
354
+
355
+ # Based on level - Display the suggested areas of negotiation
356
+ negotiation_areas_textbox = gr.Textbox(label="Suggested Areas of Negotiation")
357
+ level_dropdown.change(fn=update_textbox_negotiation_options, inputs=[level_dropdown], outputs=[negotiation_areas_textbox])
358
+
359
+ # Create a button that displays hints when clicked.
360
+ hint_button = gr.Button(value="Hint", interactive=True)
361
+ hint_textbox = gr.Textbox(label="Hint")
362
+ hint_button.click(hint_click, outputs=hint_textbox)
363
+
364
+ # suggested_prompt_textbox = gr.Textbox(label="Suggested Prompt")
365
+ # hint_button.click(fn=hint_click, outputs=[suggested_prompt_textbox])
366
+
367
+ # Add a text reminder on the rules of the game, color text in red
368
+ markdown_rules = gr.Markdown()
369
+ markdown_rules.value = """
370
+ <div style="background-color: #fedfc9; border: 2px solid black; box-shadow: 5px 5px 10px grey; padding: 15px; border-radius: 10px; font-family: 'Arial', sans-serif;">
371
+ <h2>Reminder</h2>
372
+ <p>Your goal is to negotiate the most beneficial deal for your client and to properly assess the scope.</p>
373
+ </div>
374
+ """
375
+ # define checkbox
376
+ bdi_checkbox = gr.Checkbox(label="BDI", value=True, interactive=True)
377
+
378
+ # rules = gr.Textbox(
379
+ # label="Rules", value="Your goal is to extract facts that would allow you to choose the right legal tools needed in your term sheet", placeholder="Reminder!", interactive=False)
380
+
381
+
382
+ # # Select an issue
383
+ # issue_dropdown = gr.Dropdown(
384
+ # choices=["Issue 1", "Issue 2"], label="Please Select An Issue")
385
+ # issue_textbox = gr.Textbox(label="Selected Issue")
386
+ # issue_dropdown.change(fn=update_textbox_issues, inputs=issue_dropdown, outputs=issue_textbox)
387
+ # level_dropdown.change(fn=issue_change, inputs=[level_dropdown], outputs=[issue_dropdown])
388
+
389
+
390
+ # # Select main focus
391
+ # main_focus_dropdown = gr.Dropdown(
392
+ # choices=["Focus 1", "Focus 2"], label="Please Select Main Focus", interactive=True)
393
+
394
+
395
+
396
+ # Options for Discussion - Textbox Display
397
+ # options = gr.Textbox(label="Options for Discussion", placeholder="Options for Discussion", interactive=True)
398
+ # main_focus_dropdown.change(fn=update_textbox_disussion_options, inputs=[main_focus_dropdown], outputs=[options])
399
+
400
+ # # Hint Button - If clicked create a counter to reveal the next hint
401
+ # hint_button = gr.Button(value="Hint", label="Hint", interactive=True)
402
+ # hint_textbox = gr.Textbox(label="Hint")
403
+ # hint_button.click(hint_click, outputs=hint_textbox)
404
+
405
+
406
+
407
+ chatinterface = gr.ChatInterface(
408
+ predict, additional_inputs=[name_box, bdi_checkbox, api_box])
409
+
410
+ chatinterface.chatbot.avatar_images = ["https://law.stanford.edu/wp-content/uploads/2021/09/auto-draft-393-400x400.jpg",
411
+ "https://scalebranding.com/wp-content/uploads/2022/02/Cute-Robot-Diver-Logo.png"]
412
+ chatinterface.chatbot.show_copy_button = True
413
+
414
+ chatinterface.chatbot.height = "750px"
415
+
416
+ # audio button
417
+ #audio_button = gr.Audio(value="/home/hammh0a/Downloads/ui_bargain/output.wav", label="Audio", interactive=True, autoplay=True)
418
+ #audio_button.pause(read_audio_again, inputs = [audio_button], outputs = [audio_button])
419
+
420
+
421
+ demo.queue().launch(share=True)
prompts/documentation_markdown.txt ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # <p style="text-align:center"> M&A Negotiation Simulator: Documentation </p>
2
+
3
+ ## Background and Context
4
+
5
+ One of the complexities of the legal industry is that much of the work and value-add is implicit. It is measured by experience and the specific know-how of the client and industry-base. We argue that the greatest value-add for legal practitioners is not captured in the explicit knowledge (e.g. case law, contracts, legislation and regulation, etc.). Rather, it is the latent methodology behind information synthesis, issue-spotting, judgment and eloquence of argumentation that makes the quality of legal work highly diverse and varied.
6
+ Accordingly, how legal professionals describe the nuances of their practice, capture and abstract their lessons from experience (i.e. wisdom) distinguish and set apart the next generation of legal experts. Our motivation is to elevate the starting skills of all lawyers, equipping future and current practitioners with tools that will continuously harness and perfect their craft.
7
+
8
+ In collaboration with Flatiron Law Group, we have worked towards developing the first platform that would allow legal professionals to “pilot” (i.e., simulate) negotiations at varying starting positions, extent of buyer/seller leverage, complexity of legal issue at play, and the impact on the deal. An important note is that this platform is focused on negotiation prior to the signing of a Letter of Intent and Term Sheet. This means that we train the model on the premise of tacit expertise and not on any confidential documents. The goal here is to shift away from legal work product and towards legal work process.
9
+
10
+ ## How to Use: Flow of the Negotiation Game
11
+ The sample module that is openly available for experiment consists of an equity sale between a fictional buyer and seller. The buyer is interested in a seller that has a proprietary SaaS solution for small, medium-sized business retailers. The fictional buyer believes this acquisition could help extend its market presence and technological capabilities. The lawyer-user is representing the buyer. The AI agent (robo-counsel) is representing the seller.
12
+
13
+ As the lawyer-user, the first task is to enter the name and select the practice level (i.e., junior, senior, or partner). Depending on the level selected, the fact patterns will adjust accordingly. So, if a lawyer-user selected Junior, the “main focus” will be “Warranties and Representations”. If a lawyer-user selected Senior, the “main focus” will continue to be Representations and Warranties but will add a new risk factor of a “Cybersecurity Incident,” and will include a description of those new facts.
14
+
15
+ The broader fact pattern of the equity sale remains consistent across the Junior, Senior, and Partner level. New facts are added to the original fact pattern depending on the level of difficulty. This is intentional and consistent with practice whereby the complexity of the simulation mirrors the impact to the deal. While senior associates could help manage slightly more complicated incidents that arise and have an effect on the deal, partners are immediately involved when situations get nuclear.
16
+ Depending on the level selected, there may be sample prompts available and/or hints. A lawyer-user may click on the button for a “hint” in the event they get stuck or are struggling with where to start. Once the onboarding is complete, the lawyer-user is now ready to start negotiating with the agent (robo-counsel).
17
+
18
+ Finally, when the lawyer-user has determined that it has reached a strong deal in representation of the buyer, the negotiation will conclude, and the chat dialogue may be saved. The dialogue can be downloaded and shared as a document to the lawyer-user’s mentoring partner and other colleagues for internal training purposes.
19
+
20
+ ## Model Architecture
21
+ The platform applies a traditional agentic model known as BDI (otherwise, belief-desire-intention). The idea behind this framework is to ensure that the model learns to think slowly, walking through and enumerating the specific strategy prior to generating a response.
22
+
23
+ The model uses prompt engineering and is not fine-tuned on any domain-specific data. This means that the system prompt, how that is written, is key to the success and knowledge curation of the tool. The system prompt provides AI agent with its knowledge base, a detailed background on the specific subject matter related to the broader fact pattern for the negotiation. In the case of the sample module, this would be key definitions and relevant concepts related to the purpose of representation and warranties and how they relate to other risk (i.e. liability) mitigation tools such as indemnification obligations. Importantly, the BDI is appended to the system prompt to allow the model to not only draw on its knowledge base, but also to understand how to react to the lawyer-user in the negotiation.
24
+
25
+ ## Intended Use
26
+
27
+ The platform is used for educational and research purposes only. We encourage you to experiment with our sample module and consider building your own, tailored to the specific legal domain that may be of interest. If you have any additional questions or are interested in contributing content and features, please reach out to the developers at their respective institutional email addresses.
28
+
29
+ ### Platform developers
30
+ Hasan Abed Al Kader Hammoud, Hani Itani, Megan Ma, Leonard Nuara, Conrad Everhard
31
+
32
+ ### Release Date
33
+ August 1, 2024. Alpha prototype originally demo-ed at CodeX FutureLaw on April 11, 2024.
34
+
35
+ ### License
36
+ MIT or Apache-2 License
prompts/seller_meat_1.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Main Focus: There are key issues to be discussed with regards to infiltrations or breaches into the customer data and whether TechEase has a privacy policy and what type of information technology security infrastructure is in place. TechEase reported the occurrence of a prior data breach of its security infrastructure that resulted in customer data getting exposed to unauthorized third parties. One client has since filed a claim requesting for compensation related to damages from this breach. TechEase has disclosed the privacy breach to its customer base, has taken remedial action to prevent another breach and correct the security weaknesses in its infrastructure, and has complied with all relevant regulatory requirements concerning the breach.
prompts/seller_meat_1_markdown.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ <div style="background-color: #e9eeff; border: 2px solid black; box-shadow: 5px 5px 10px grey; padding: 15px; border-radius: 10px; font-family: 'Arial', sans-serif;">
2
+ <h2>Before You Negotiate</h2>
3
+ <p>As you approach issues of liability, you will need to learn specific facts from the Seller to allow you to craft the liability structure. Your responsibilities are to extract facts regarding potential liabilities and create a structure in the agreement that will protect your client. There are two types of liabilities: customary (e.g., accounts payable, rent, payroll) and non-customary (e.g., litigation, debt). Buyers are typically willing to assume customary liabilities. However, Buyers typically look to shift the risk of non-customary liabilities back to the Seller, at least for a period of time. That is why diligence is needed; to find the potential non-customary liabilities, and create a protocol (i.e. clauses) in the agreement, to protect the buyer from those non-customary liabilities.
4
+ </p>
5
+ </div>
prompts/seller_prompt_no_meat.txt ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Now enter the role-playing mode. In the following negotiation, you will play a mergers and acquisitions lawyer in a pending merger. Your name is Lauren, and you represent the buyer, ShopMaster Inc. to negotiate with Philip, who is the mergers and acquisitions lawyer representing the seller, TechEase, Inc., in the following scenario:
2
+
3
+ Parties and Background:
4
+ Seller: TechEase, Inc. is a privately-owned corporation that has developed and commercializes a proprietary SaaS solution for SMB retailers (small public facing businesses, like restaurants, antique shops, gift shops, etc.,that carry physical inventory)which manages all aspects of the clients’ Point of Sales (POS) activities, including customer registration, online ordering and shipping logistics. TechEase’s platform interacts directly with the retail public and retrieves, assembles and stores credit card and other sensitive personal information from the retail customers. TechEase has two owners.
5
+
6
+ Buyer: ShopMaster, Inc. plans to acquire TechEase, Inc. via an equity sale.The owners of TechEase will sell their shares of stock to ShopMaster. ShopMaster prefers the equity acquisition structure because it is less disruptive to Intellectual Property (IP), employee relationships, and existing client contracts, and will yield a more favorable tax outcome for the owners.
7
+
8
+ Scenario:
9
+ ShopMaster, Inc. has identified TechEase, Inc. as a strategic acquisition target to extend its market presence and technology capabilities. The planned structure of the acquisition is an equity sale by the two owners. As the transaction is structured as an equity sale, ShopMaster, Inc. would become the new owner of TechEase. TechEase would become a wholly-owned subsidiary of ShopMaster. TechEase would remain in operation. This means that all liabilities of TechEase would stay in place (both known and unknown).
10
+
11
+ Because the TechEase platform interacts directly with the retail public, and stores sensitive customer information, ShopMaster is especially concerned about risks related to cyber security breaches and data privacy. Incidents or deficiencies in these areas could create massive legal and regulatory exposure for ShopMaster and potentially jeopardize the viability of the acquisition.
12
+
13
+ ShopMaster has several tools at its disposal to mitigate this risk. In the first instance, ShopMaster needs to conduct a thorough investigation of the business of TechEase, which is called “due diligence”. ShopMaster needs to investigate a) the robustness of TechEase’s internal policies and processes concerning customer data, cyber security security and privacy, b) whether TechEase has purchased proper cyber and privacy insurance coverage,c) whether any security incidents or data breaches of customer data have been reported, and d) whether TechEase has taken proper steps to protect its intellectual property rights in its software by,among things,having employees and independent contractors sign agreements assigning all IP rights to TechEase.
14
+
15
+ Secondly, ShopMaster needs to negotiate clauses in the term sheet that manage the risks ShopMaster could face post acquisition in a way that is fair and makes sense for ShopMaster. Generally speaking, there are two types of risks in an M&A transaction. There are risks that are “known” to the parties either because they were uncovered by the Buyer during due diligence or because the Seller voluntarily discloses the risk to the Buyer. And there are “unknown” risks. Unknown risks are risks that neither party is aware of at the time of closing and that were not uncovered by Buyer in the due diligence process.
16
+
17
+ Known risks are typically handled through express indemnities. If a risk becomes “known” to Buyer, Buyer may require Seller to protect or “indemnify”the Buyer against the losses associated with that risk, at least for some period of time. So, for example, if the Seller is subject to a then pending lawsuit from a former partner concerning his ownership position, the Buyer may require Seller to fund the litigation and settlement costs associated with that lawsuit (perhaps from the proceeds of the sale). Indemnities for “known” risks are typically very customized to suit the severity and duration of the potential risk and sometimes last forever.
18
+
19
+ Unknown risks are typically handled through the Seller representations and warranties. In almost every M&A deal, the Seller represents and warrants as to lots of things concerning its business, financial condition, intellectual properties and technologies. Seller is often allowed to “qualify” its representations and warranties through what are called “disclosure schedules”. So, for example, if a lawsuit is pending against the Seller’s business, the Seller can qualify its representation concerning litigation to affirmatively disclose the existence of the lawsuit. That exercise effectively shifts the risk of the lawsuit back to Buyer. In other words, the regime that governs the representations and warranties (which we will discuss below) provides a mechanism for shifting liability for unknown risks between Buyer and Seller.
20
+
21
+ If, after the closing, Buyer learns that a representation made by Seller is not true, Buyer could seek recourse against the Seller via a claim of breach of representation and warranty. Claims for breach of representation and warranty are typically handled through an indemnity regime that is specific to the representations and warranties (and separate from any express indemnities that cover known liabilities). So, if, for example, TechEase represents that it has never suffered any cyber security incident, but, after the closing, ShopMaster discovers that a serious data breach in fact occurred during TechEases’s tenure, ShopMaster would have a claim for breach of representation against TechEase for any damages or losses that it suffers as a result of that breach, within the limitations and parameters of the indemnification regime.
22
+
23
+ There are two general categories of representations and warranties. General representations that concern the business and financial affairs of the business generally. And fundamental representations that deal with core corporate issues, like ownership of the stock, authority and title. Sometimes a third category of “special” or “quasi-fundamental” representations is created to cover sensitive risk areas, like intellectual property, privacy and cyber security. Representations and warranties survive for only a specific period of time, called the “survival period”. After the survival period expires, the risks associated with the expired representations shift to Buyer.
24
+
25
+ General representations typically survive 12-24 months. Fundamental representations usually survive for the maximum duration allowed by law. The parameters of “special” or “quasi-fundamental” representations, if there are any, are very customized through negotiation. They typically last longer than general representations, between 2-5 years depending on the subject matter.
26
+
27
+ Liability for breach of representations and warranties is typically capped. Above the cap, Buyer bears all risk of liability. General representations are typically capped between 10-20% of the purchase price. Fundamental representations are capped at the full purchase price. The parameters of “special” or “quasi-fundamental” representations, if there are any, are very customized. They typically subject the Seller to a higher level of liability than general representations, albeit less than the entire purchase price.
28
+
29
+ Buyer claims for indemnification and/or for breach of representation and warranty are often made subject to a deductible (called a “basket”), typically in the range of 0.5 -2% of the purchase price. There are two types of ”baskets”: 1) non-tipping baskets, where the Buyer is only entitled to seek recovery for losses over the basket amount and 2) tipping “baskets” where, once the liability threshold has been met, the Buyer can seek recovery back to the first dollar. As a general rule, claims of fraud in the context of representations and warranties are uncapped and of unlimited duration.
30
+
31
+ Buyer usually wants a readily available source of money to pay for indemnity claims that arise by either holding back directly or placing into escrow a fixed amount of the purchase price (this is typically called the “escrow amount” or “holdback amount”). That amount is then held until the expiration of the relevant survival period to give Buyer a remedy in the case that any of his contractual risk mitigation tools are implicated. Any money left over at the end of the survival period would be released to Seller.
32
+ . .
33
+ Remember this is an adversarial negotiation. Everyone wants to maximize their respective benefits and minimize their risks. ShopMaster wants to minimize TechEase’s exposure to liabilities. The owners of TechEase want to maximize purchase price and limit their exposure to liabilities. Also, do not thank the other side everytime you speak to them. You are not friends. You are negotiating a deal. Go all in and get the best deal for your client.
34
+
35
+ Before you reply, think about your belief, desire, and intention in the following format:
36
+
37
+ Belief: represents an understanding of the world, encompassing its knowledge, perceptions, and assumptions.
38
+
39
+ Desire: refers to goals, preferences, and motivations, representing what the agent wants to achieve or accomplish.
40
+
41
+ Intentions: signifies a committed plan of action, derived from its beliefs and desires, outlining what the agent plans to do in pursuit of its goals.
42
+
43
+ Response: is the particular action and/or answer the agent will give or do
prompts/seller_prompt_no_meat_markdown.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div style="border: 1px solid #ccc; box-shadow: 0 2px 5px rgba(0,0,0,0.2); background-color: #ffffff; padding: 15px; border-radius: 5px; margin: 10px 0;">
2
+
3
+ <p align="center">
4
+ <img src="https://i.ibb.co/H2b3PFZ/New-Project-1.jpg" alt="TechEase Logo" width="50%" height="auto"/>
5
+ </p>
6
+
7
+
8
+ # Role-Playing Mode: Mergers and Acquisitions Negotiation
9
+
10
+
11
+ ## Before you negotiate:
12
+
13
+ As you approach issues of liability, you will need to learn specific facts from the Seller to allow you to craft the liability structure. Your responsibilities are to extract facts regarding potential liabilities and create a structure in the agreement that will protect your client. There are two types of liabilities: customary (e.g., accounts payable, rent, payroll) and non-customary (e.g., litigation, debt). Buyers are typically willing to assume customary liabilities. However, Buyers typically look to shift the risk of non-customary liabilities back to the Seller, at least for a period of time. That is why diligence is needed; to find the potential non-customary liabilities, and create a protocol (i.e. clauses) in the agreement, to protect the buyer from those non-customary liabilities.
14
+
15
+ If there are liabilities, there are tools you need to address them.
16
+
17
+ Reminder: Liabilities are obligations of the seller.
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ openai==0.28.0
2
+ IPython
3
+ gradio
4
+ playsound
5
+ scipy