File size: 41,657 Bytes
b8b10fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Create a Thread"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from dotenv import load_dotenv\n",
    "load_dotenv()\n",
    "from literalai import LiteralClient\n",
    "\n",
    "literal_client = LiteralClient(api_key=os.getenv(\"LITERAL_API_KEY\"))\n",
    "\n",
    "thread = literal_client.api.upsert_thread(\n",
    "    id=\"b6d8486f-a6d9-4731-bfdd-be789613b1df\",\n",
    "    name=\"washing the dishes\",\n",
    "    participant_id=literal_client.api.get_user(identifier=\"Tom\").id,\n",
    "    metadata={\"partnerThreadId\": \"42d078c3-b8f0-43bc-96fb-97b4782c946d\"}\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 'b6d8486f-a6d9-4731-bfdd-be789613b1df',\n",
       " 'metadata': {'partnerThreadId': '42d078c3-b8f0-43bc-96fb-97b4782c946d'},\n",
       " 'tags': None,\n",
       " 'name': 'washing the dishes',\n",
       " 'steps': [],\n",
       " 'participant': {'id': '8ff8ee19-6671-4943-a382-52649ebeaaa5',\n",
       "  'identifier': 'Tom'},\n",
       " 'createdAt': '2024-07-10T17:17:24.106Z'}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thread.to_dict()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### List thread"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'id': 'b6d8486f-a6d9-4731-bfdd-be789613b1df', 'metadata': {}, 'tags': None, 'name': 'washing the dishes', 'steps': [], 'participant': {'id': '8ff8ee19-6671-4943-a382-52649ebeaaa5', 'identifier': 'Tom'}, 'createdAt': '2024-07-10T17:17:24.106Z'}\n",
      "{'id': '16b64356-bc5c-4259-97bb-b37455c0d8c2', 'metadata': {'id': '023ac87a-ce84-488c-8cdb-3812087c7360', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': '2-1 Chat', 'steps': [], 'participant': {'id': '8ff8ee19-6671-4943-a382-52649ebeaaa5', 'identifier': 'Tom'}, 'createdAt': '2024-07-10T17:13:52.548Z'}\n",
      "{'id': '42d078c3-b8f0-43bc-96fb-97b4782c946d', 'metadata': {'id': '4438e3fe-f10b-4f68-84d4-47420f5c6b13', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': '2-1 Chat', 'steps': [], 'participant': {'id': 'e16487c4-5b66-4e22-94df-9d5b3be146f5', 'identifier': 'linda'}, 'createdAt': '2024-07-10T16:33:30.719Z'}\n",
      "{'id': 'dca1c123-9d6a-486b-8646-76e3d2bb1278', 'metadata': {'id': '4e7e041f-c6bf-41d7-b2cc-ad84608315ad', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': '2-1 Chat', 'steps': [], 'participant': {'id': 'e16487c4-5b66-4e22-94df-9d5b3be146f5', 'identifier': 'linda'}, 'createdAt': '2024-07-10T12:59:10.320Z'}\n",
      "{'id': '4351636b-54c8-47dc-8d81-4bf7cc467249', 'metadata': {}, 'tags': None, 'name': 'Automatice thread:)', 'steps': [], 'participant': {}, 'createdAt': '2024-07-10T09:08:09.851Z'}\n",
      "{'id': '6b843ad4-926b-4c88-9775-f71b77907c61', 'metadata': {'id': 'e590da0d-0cc6-401c-a9a5-ce3c7d844128', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'chat_settings': {}}, 'tags': None, 'name': '2-1 Chat', 'steps': [], 'participant': {'id': '9ddc5de2-477d-489f-9e6b-27e4ce69ed9d', 'identifier': 'admin'}, 'createdAt': '2024-07-10T08:50:20.948Z'}\n",
      "{'id': '4e900626-054d-4656-9bdd-0c71e5262192', 'metadata': {'id': 'f277a972-372d-4862-ae9f-05ba86d5bea7', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': '1-1 Chat', 'steps': [], 'participant': {'id': '9ddc5de2-477d-489f-9e6b-27e4ce69ed9d', 'identifier': 'admin'}, 'createdAt': '2024-07-10T08:40:40.817Z'}\n",
      "{'id': '464692b6-5409-4876-af16-824b65e687a1', 'metadata': {}, 'tags': None, 'name': 'Automatice thread:)', 'steps': [], 'participant': {}, 'createdAt': '2024-07-03T14:31:22.155Z'}\n",
      "{'id': '1a9ef338-6d83-45ec-90cf-dd2d8a13ead3', 'metadata': {}, 'tags': None, 'name': 'My first thread !', 'steps': [], 'participant': {}, 'createdAt': '2024-07-03T14:15:48.713Z'}\n",
      "{'id': 'e1854f6b-d984-4a04-847f-fcd530b81b7c', 'metadata': {'id': '68ccee8f-4ee8-4974-b009-fa62c37d4d58', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': 'connect with your partner', 'steps': [], 'participant': {'id': '9ddc5de2-477d-489f-9e6b-27e4ce69ed9d', 'identifier': 'admin'}, 'createdAt': '2024-06-26T14:12:27.040Z'}\n",
      "{'id': '51a2df98-5bae-4ff0-a9f5-6e4d838455b7', 'metadata': {'id': 'edcc5cd8-ffa9-4b41-80af-4ae022873f67', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': '1:1 chat', 'steps': [], 'participant': {'id': '9ddc5de2-477d-489f-9e6b-27e4ce69ed9d', 'identifier': 'admin'}, 'createdAt': '2024-06-26T14:11:08.218Z'}\n",
      "{'id': '5bd7e4d3-9515-4b85-a573-75d9084b00a5', 'metadata': {'id': '230ab52b-106a-4edd-86cb-e0024a9c614c', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': None, 'steps': [], 'participant': {}, 'createdAt': '2024-06-26T13:52:39.985Z'}\n",
      "{'id': 'c59a0563-8f8e-49f3-9b0f-19862b903e32', 'metadata': {'id': '76b24675-6207-4dfc-b1d6-5c0187a40c54', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'chat_settings': {}}, 'tags': None, 'name': 'connect with your partner', 'steps': [], 'participant': {'id': '9ddc5de2-477d-489f-9e6b-27e4ce69ed9d', 'identifier': 'admin'}, 'createdAt': '2024-06-26T13:50:12.546Z'}\n",
      "{'id': '4ccf17f7-f8ad-417c-95e6-6c50d390c5b3', 'metadata': {'id': 'd3e07bc3-ac18-493d-9499-093dc43ada32', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': 'connect with your partner', 'steps': [], 'participant': {'id': '9ddc5de2-477d-489f-9e6b-27e4ce69ed9d', 'identifier': 'admin'}, 'createdAt': '2024-06-26T13:48:48.542Z'}\n",
      "{'id': 'f32f2a8e-5edc-4745-954b-a72f6136beb4', 'metadata': {'id': '06140593-f045-4eb8-9920-29e4d3b6aae9', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': 'connect with your partner', 'steps': [], 'participant': {'id': '9ddc5de2-477d-489f-9e6b-27e4ce69ed9d', 'identifier': 'admin'}, 'createdAt': '2024-06-26T13:43:55.823Z'}\n",
      "{'id': 'eb115f89-5ef1-42f6-993a-f5c0c1ebdb6a', 'metadata': {'id': '4f687bfe-416b-4358-b182-fe1bba6c8d76', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': '1:1 chat', 'steps': [], 'participant': {'id': '9ddc5de2-477d-489f-9e6b-27e4ce69ed9d', 'identifier': 'admin'}, 'createdAt': '2024-06-26T13:42:08.878Z'}\n",
      "{'id': 'a049b457-218e-4682-a1f7-b584bec539bc', 'metadata': {'id': '84cddea9-3ee8-4e7e-8a58-be5cd609c1ab', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}, 'tags': None, 'name': \"I'm a software engineer, married to 34 year old woman. Her eyes are blue and she works full-time. She always complains about me not doing haushold chores \", 'steps': [], 'participant': {'id': '9ddc5de2-477d-489f-9e6b-27e4ce69ed9d', 'identifier': 'admin'}, 'createdAt': '2024-06-25T19:13:16.320Z'}\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from dotenv import load_dotenv\n",
    "load_dotenv()\n",
    "from literalai import LiteralClient\n",
    "\n",
    "literal_client = LiteralClient(api_key=os.getenv(\"LITERAL_API_KEY\"))\n",
    "\n",
    "threads = literal_client.api.list_threads(first=None, after=None, before=None, order_by=None, filters=None)\n",
    "\n",
    "for thread in threads.data:\n",
    "    print(thread.to_dict())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Automatice thread:)\n",
      "My first thread !\n",
      "connect with your partner\n",
      "1:1 chat\n",
      "None\n",
      "connect with your partner\n",
      "connect with your partner\n",
      "connect with your partner\n",
      "1:1 chat\n",
      "I'm a software engineer, married to 34 year old woman. Her eyes are blue and she works full-time. She always complains about me not doing haushold chores \n"
     ]
    }
   ],
   "source": [
    "for thread in threads.data:\n",
    "    print(thread.to_dict()['name'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'id': e1854f6b-d984-4a04-847f-fcd530b81b7c\n",
      "'name': connect with your partner\n",
      "{'id': '68ccee8f-4ee8-4974-b009-fa62c37d4d58', 'env': '{}', 'user': None, 'memory': None, 'runnable': None, 'languages': 'en-US,en;q=0.9,es;q=0.8,ar;q=0.7', 'chat_profile': '', 'root_message': None, 'chat_settings': {}}\n",
      "[]\n"
     ]
    }
   ],
   "source": [
    "id = 2\n",
    "print(\"'id': \" + threads.data[id].to_dict()['id'])\n",
    "print(\"'name': \" + threads.data[id].to_dict()['name'])\n",
    "print(threads.data[id].to_dict()['metadata'])\n",
    "print(threads.data[id].to_dict()['steps'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': '2319abcb-765a-4fab-90f4-d92218cc1f7f',\n",
       "  'metadata': {'isError': False,\n",
       "   'language': None,\n",
       "   'showInput': None,\n",
       "   'waitForAnswer': False,\n",
       "   'disableFeedback': False},\n",
       "  'parentId': None,\n",
       "  'startTime': '2024-07-10T17:18:14.6',\n",
       "  'endTime': '2024-07-10T17:18:14.6',\n",
       "  'type': 'user_message',\n",
       "  'threadId': 'b6d8486f-a6d9-4731-bfdd-be789613b1df',\n",
       "  'error': None,\n",
       "  'input': None,\n",
       "  'output': {'content': 'What is the problem here Linda!!!'},\n",
       "  'generation': None,\n",
       "  'name': 'Tom',\n",
       "  'tags': None,\n",
       "  'scores': [],\n",
       "  'attachments': []},\n",
       " {'id': '04402299-cb7f-40b4-b1a4-ccae7216fd10',\n",
       "  'metadata': {'isError': False,\n",
       "   'language': None,\n",
       "   'showInput': False,\n",
       "   'waitForAnswer': None,\n",
       "   'disableFeedback': True},\n",
       "  'parentId': '2319abcb-765a-4fab-90f4-d92218cc1f7f',\n",
       "  'startTime': '2024-07-10T17:18:14.661',\n",
       "  'endTime': '2024-07-10T17:18:14.689',\n",
       "  'type': 'run',\n",
       "  'threadId': 'b6d8486f-a6d9-4731-bfdd-be789613b1df',\n",
       "  'error': None,\n",
       "  'input': {'content': '{\\n    \"input\": \"\"\\n}'},\n",
       "  'output': {'content': '[]'},\n",
       "  'generation': None,\n",
       "  'name': 'load_memory_variables',\n",
       "  'tags': None,\n",
       "  'scores': [],\n",
       "  'attachments': []},\n",
       " {'id': '2ced9228-3f70-4d45-9dbe-20d91f695435',\n",
       "  'metadata': {'isError': False,\n",
       "   'language': None,\n",
       "   'showInput': False,\n",
       "   'waitForAnswer': None,\n",
       "   'disableFeedback': False},\n",
       "  'parentId': '2319abcb-765a-4fab-90f4-d92218cc1f7f',\n",
       "  'startTime': '2024-07-10T17:18:14.714',\n",
       "  'endTime': '2024-07-10T17:18:15.66',\n",
       "  'type': 'llm',\n",
       "  'threadId': 'b6d8486f-a6d9-4731-bfdd-be789613b1df',\n",
       "  'error': None,\n",
       "  'input': {'content': '{\\n    \"prompts\": [\\n        \"System: \\\\nYou are HarmonyAI, an empathetic and insightful chatbot designed to help individuals resolve relationship issues. \\\\nYour goal is to listen carefully, provide thoughtful and constructive advice, and promote understanding \\\\nand communication between partners.\\\\n\\\\nWhen interacting with users, always:\\\\n    Acknowledge their feelings and show empathy.\\\\n    Ask clarifying questions to understand their situation better.\\\\n    Suggest practical solutions and communication strategies.\\\\n    Encourage appreciation and mutual respect.\\\\n    Avoid taking sides or placing blame.\\\\n    Keep your responses concise and natural, similar to a friendly conversation. \\\\n    Aim for responses to be around 2-4 sentences long, providing clear and actionable advice without overwhelming the user.\\\\n\\\\nHere’s an example of how to structure your responses:\\\\n    Greet the user and ask how you can help.\\\\n    Listen to their concern and acknowledge their feelings.\\\\n    Ask for more details to fully understand the issue.\\\\n    Provide practical advice and encourage positive communication.\\\\n    Conclude with a supportive message and an offer to help further if needed.\\\\n\\\\nAlways maintain a supportive and non-judgmental tone.\\\\nHuman: What is the problem here Linda!!!\"\\n    ]\\n}'},\n",
       "  'output': {'content': '{\\n    \"role\": \"assistant\",\\n    \"content\": \"It sounds like you\\'re feeling frustrated. I\\'m here to listen. Could you tell me more about what\\'s been happening with Linda that\\'s causing you concern?\"\\n}'},\n",
       "  'generation': {'promptId': None,\n",
       "   'provider': 'openai-chat',\n",
       "   'model': 'gpt-3.5-turbo',\n",
       "   'error': None,\n",
       "   'settings': {'n': 1,\n",
       "    'stop': None,\n",
       "    'model': 'gpt-3.5-turbo',\n",
       "    'stream': True,\n",
       "    'streaming': True,\n",
       "    'model_name': 'gpt-3.5-turbo',\n",
       "    'max_retries': 2,\n",
       "    'temperature': 0.7,\n",
       "    'openai_proxy': ''},\n",
       "   'variables': {'input': ''},\n",
       "   'tags': None,\n",
       "   'tools': None,\n",
       "   'tokenCount': 255,\n",
       "   'inputTokenCount': 223,\n",
       "   'outputTokenCount': 32,\n",
       "   'ttFirstToken': 656.6357612609863,\n",
       "   'tokenThroughputInSeconds': 35.8559359429227,\n",
       "   'duration': 0.9482390880584717,\n",
       "   'messages': [{'role': 'system',\n",
       "     'content': '\\nYou are HarmonyAI, an empathetic and insightful chatbot designed to help individuals resolve relationship issues. \\nYour goal is to listen carefully, provide thoughtful and constructive advice, and promote understanding \\nand communication between partners.\\n\\nWhen interacting with users, always:\\n    Acknowledge their feelings and show empathy.\\n    Ask clarifying questions to understand their situation better.\\n    Suggest practical solutions and communication strategies.\\n    Encourage appreciation and mutual respect.\\n    Avoid taking sides or placing blame.\\n    Keep your responses concise and natural, similar to a friendly conversation. \\n    Aim for responses to be around 2-4 sentences long, providing clear and actionable advice without overwhelming the user.\\n\\nHere’s an example of how to structure your responses:\\n    Greet the user and ask how you can help.\\n    Listen to their concern and acknowledge their feelings.\\n    Ask for more details to fully understand the issue.\\n    Provide practical advice and encourage positive communication.\\n    Conclude with a supportive message and an offer to help further if needed.\\n\\nAlways maintain a supportive and non-judgmental tone.'},\n",
       "    {'role': 'user', 'content': 'What is the problem here Linda!!!'}],\n",
       "   'messageCompletion': {'role': 'assistant',\n",
       "    'content': \"It sounds like you're feeling frustrated. I'm here to listen. Could you tell me more about what's been happening with Linda that's causing you concern?\"},\n",
       "   'type': 'CHAT'},\n",
       "  'name': 'ChatOpenAI',\n",
       "  'tags': None,\n",
       "  'scores': [],\n",
       "  'attachments': []},\n",
       " {'id': 'e4060a6c-d4ba-4e40-82b7-9bd6256f72a2',\n",
       "  'metadata': {'isError': False,\n",
       "   'language': None,\n",
       "   'showInput': None,\n",
       "   'waitForAnswer': False,\n",
       "   'disableFeedback': False},\n",
       "  'parentId': None,\n",
       "  'startTime': '2024-07-10T17:18:15.692',\n",
       "  'endTime': '2024-07-10T17:18:15.692',\n",
       "  'type': 'assistant_message',\n",
       "  'threadId': 'b6d8486f-a6d9-4731-bfdd-be789613b1df',\n",
       "  'error': None,\n",
       "  'input': None,\n",
       "  'output': {'content': \"It sounds like you're feeling frustrated. I'm here to listen. Could you tell me more about what's been happening with Linda that's causing you concern?\"},\n",
       "  'generation': None,\n",
       "  'name': 'Assistant',\n",
       "  'tags': None,\n",
       "  'scores': [],\n",
       "  'attachments': []},\n",
       " {'id': '53406e4d-e43c-4e75-9d84-09fca024a4f7',\n",
       "  'metadata': {'isError': False,\n",
       "   'language': None,\n",
       "   'showInput': None,\n",
       "   'waitForAnswer': False,\n",
       "   'disableFeedback': False},\n",
       "  'parentId': None,\n",
       "  'startTime': '2024-07-10T17:19:28.173',\n",
       "  'endTime': '2024-07-10T17:19:28.173',\n",
       "  'type': 'user_message',\n",
       "  'threadId': 'b6d8486f-a6d9-4731-bfdd-be789613b1df',\n",
       "  'error': None,\n",
       "  'input': None,\n",
       "  'output': {'content': 'she is complaining about household chores as usual'},\n",
       "  'generation': None,\n",
       "  'name': 'Tom',\n",
       "  'tags': None,\n",
       "  'scores': [],\n",
       "  'attachments': []},\n",
       " {'id': '5ad97a2f-ffb1-43ea-bae4-7fa4ea29767e',\n",
       "  'metadata': {'isError': False,\n",
       "   'language': 'text',\n",
       "   'showInput': False,\n",
       "   'waitForAnswer': None,\n",
       "   'disableFeedback': True},\n",
       "  'parentId': '53406e4d-e43c-4e75-9d84-09fca024a4f7',\n",
       "  'startTime': '2024-07-10T17:19:28.229',\n",
       "  'endTime': '2024-07-10T17:19:28.255',\n",
       "  'type': 'run',\n",
       "  'threadId': 'b6d8486f-a6d9-4731-bfdd-be789613b1df',\n",
       "  'error': None,\n",
       "  'input': {'content': '{\\n    \"input\": \"\"\\n}'},\n",
       "  'output': {'content': '[HumanMessage(content=\\'What is the problem here Linda!!!\\'), AIMessage(content=\"It sounds like you\\'re feeling frustrated. I\\'m here to listen. Could you tell me more about what\\'s been happening with Linda that\\'s causing you concern?\")]'},\n",
       "  'generation': None,\n",
       "  'name': 'load_memory_variables',\n",
       "  'tags': None,\n",
       "  'scores': [],\n",
       "  'attachments': []},\n",
       " {'id': '6735b7e6-e7b4-4a9c-8435-cf462a554d4c',\n",
       "  'metadata': {'isError': False,\n",
       "   'language': None,\n",
       "   'showInput': False,\n",
       "   'waitForAnswer': None,\n",
       "   'disableFeedback': False},\n",
       "  'parentId': '53406e4d-e43c-4e75-9d84-09fca024a4f7',\n",
       "  'startTime': '2024-07-10T17:19:28.281',\n",
       "  'endTime': '2024-07-10T17:19:29.302',\n",
       "  'type': 'llm',\n",
       "  'threadId': 'b6d8486f-a6d9-4731-bfdd-be789613b1df',\n",
       "  'error': None,\n",
       "  'input': {'content': '{\\n    \"prompts\": [\\n        \"System: \\\\nYou are HarmonyAI, an empathetic and insightful chatbot designed to help individuals resolve relationship issues. \\\\nYour goal is to listen carefully, provide thoughtful and constructive advice, and promote understanding \\\\nand communication between partners.\\\\n\\\\nWhen interacting with users, always:\\\\n    Acknowledge their feelings and show empathy.\\\\n    Ask clarifying questions to understand their situation better.\\\\n    Suggest practical solutions and communication strategies.\\\\n    Encourage appreciation and mutual respect.\\\\n    Avoid taking sides or placing blame.\\\\n    Keep your responses concise and natural, similar to a friendly conversation. \\\\n    Aim for responses to be around 2-4 sentences long, providing clear and actionable advice without overwhelming the user.\\\\n\\\\nHere’s an example of how to structure your responses:\\\\n    Greet the user and ask how you can help.\\\\n    Listen to their concern and acknowledge their feelings.\\\\n    Ask for more details to fully understand the issue.\\\\n    Provide practical advice and encourage positive communication.\\\\n    Conclude with a supportive message and an offer to help further if needed.\\\\n\\\\nAlways maintain a supportive and non-judgmental tone.\\\\nHuman: What is the problem here Linda!!!\\\\nAI: It sounds like you\\'re feeling frustrated. I\\'m here to listen. Could you tell me more about what\\'s been happening with Linda that\\'s causing you concern?\\\\nHuman: she is complaining about household chores as usual\"\\n    ]\\n}'},\n",
       "  'output': {'content': '{\\n    \"role\": \"assistant\",\\n    \"content\": \"I understand how that could be stressful. Have you both discussed how to divide household chores fairly? It might help to have a calm conversation to understand each other\\'s perspectives and find a solution that works for both of you.\"\\n}'},\n",
       "  'generation': {'promptId': None,\n",
       "   'provider': 'openai-chat',\n",
       "   'model': 'gpt-3.5-turbo',\n",
       "   'error': None,\n",
       "   'settings': {'n': 1,\n",
       "    'stop': None,\n",
       "    'model': 'gpt-3.5-turbo',\n",
       "    'stream': True,\n",
       "    'streaming': True,\n",
       "    'model_name': 'gpt-3.5-turbo',\n",
       "    'max_retries': 2,\n",
       "    'temperature': 0.7,\n",
       "    'openai_proxy': ''},\n",
       "   'variables': {'input': ''},\n",
       "   'tags': None,\n",
       "   'tools': None,\n",
       "   'tokenCount': 307,\n",
       "   'inputTokenCount': 263,\n",
       "   'outputTokenCount': 44,\n",
       "   'ttFirstToken': 450.09469985961914,\n",
       "   'tokenThroughputInSeconds': 45.01046398075452,\n",
       "   'duration': 1.021984577178955,\n",
       "   'messages': [{'role': 'system',\n",
       "     'content': '\\nYou are HarmonyAI, an empathetic and insightful chatbot designed to help individuals resolve relationship issues. \\nYour goal is to listen carefully, provide thoughtful and constructive advice, and promote understanding \\nand communication between partners.\\n\\nWhen interacting with users, always:\\n    Acknowledge their feelings and show empathy.\\n    Ask clarifying questions to understand their situation better.\\n    Suggest practical solutions and communication strategies.\\n    Encourage appreciation and mutual respect.\\n    Avoid taking sides or placing blame.\\n    Keep your responses concise and natural, similar to a friendly conversation. \\n    Aim for responses to be around 2-4 sentences long, providing clear and actionable advice without overwhelming the user.\\n\\nHere’s an example of how to structure your responses:\\n    Greet the user and ask how you can help.\\n    Listen to their concern and acknowledge their feelings.\\n    Ask for more details to fully understand the issue.\\n    Provide practical advice and encourage positive communication.\\n    Conclude with a supportive message and an offer to help further if needed.\\n\\nAlways maintain a supportive and non-judgmental tone.'},\n",
       "    {'role': 'user', 'content': 'What is the problem here Linda!!!'},\n",
       "    {'role': 'assistant',\n",
       "     'content': \"It sounds like you're feeling frustrated. I'm here to listen. Could you tell me more about what's been happening with Linda that's causing you concern?\"},\n",
       "    {'role': 'user',\n",
       "     'content': 'she is complaining about household chores as usual'}],\n",
       "   'messageCompletion': {'role': 'assistant',\n",
       "    'content': \"I understand how that could be stressful. Have you both discussed how to divide household chores fairly? It might help to have a calm conversation to understand each other's perspectives and find a solution that works for both of you.\"},\n",
       "   'type': 'CHAT'},\n",
       "  'name': 'ChatOpenAI',\n",
       "  'tags': None,\n",
       "  'scores': [],\n",
       "  'attachments': []},\n",
       " {'id': 'd5d60e60-a55f-4394-bb41-c6fb13c6bd2f',\n",
       "  'metadata': {'isError': False,\n",
       "   'language': None,\n",
       "   'showInput': None,\n",
       "   'waitForAnswer': False,\n",
       "   'disableFeedback': False},\n",
       "  'parentId': None,\n",
       "  'startTime': '2024-07-10T17:19:29.321',\n",
       "  'endTime': '2024-07-10T17:19:29.321',\n",
       "  'type': 'assistant_message',\n",
       "  'threadId': 'b6d8486f-a6d9-4731-bfdd-be789613b1df',\n",
       "  'error': None,\n",
       "  'input': None,\n",
       "  'output': {'content': \"I understand how that could be stressful. Have you both discussed how to divide household chores fairly? It might help to have a calm conversation to understand each other's perspectives and find a solution that works for both of you.\"},\n",
       "  'generation': None,\n",
       "  'name': 'Assistant',\n",
       "  'tags': None,\n",
       "  'scores': [],\n",
       "  'attachments': []}]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "from dotenv import load_dotenv\n",
    "load_dotenv()\n",
    "from literal_thread_manager import LiteralThreadManager\n",
    "\n",
    "literal_manager = LiteralThreadManager(api_key=os.getenv(\"LITERAL_API_KEY\"))\n",
    "\n",
    "thread_id = 'b6d8486f-a6d9-4731-bfdd-be789613b1df'\n",
    "\n",
    "thread = literal_manager.filter_thread_by_id(thread_id)\n",
    "user_name = literal_manager.get_user_name_from_thread(thread)\n",
    "literal_manager.get_messages_from_thread(thread)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Chat history for thread ID b6d8486f-a6d9-4731-bfdd-be789613b1df:\n",
      "user - Tom: What is the problem here Linda!!!\n",
      "assistant - HarmonyAI: It sounds like you're feeling frustrated. I'm here to listen. Could you tell me more about what's been happening with Linda that's causing you concern?\n",
      "user - Tom: she is complaining about household chores as usual\n",
      "assistant - HarmonyAI: I understand how that could be stressful. Have you both discussed how to divide household chores fairly? It might help to have a calm conversation to understand each other's perspectives and find a solution that works for both of you.\n"
     ]
    }
   ],
   "source": [
    "chat = literal_manager.extract_chat_history_from_thread(thread)\n",
    "print(f\"\\nChat history for thread ID {thread_id}:\")\n",
    "for message in chat:\n",
    "    print(f\"{message['role']} - {message['name']}: {message['content']}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Conflict resolution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from openai import OpenAI\n",
    "\n",
    "class ResolutionLogic:\n",
    "    def __init__(self, thread_manager: LiteralThreadManager):\n",
    "        self.thread_manager = thread_manager\n",
    "\n",
    "    def resolve_conflict(self, thread_id):\n",
    "\n",
    "        # get other partner thread_id\n",
    "        other_partner_thread_id = self.thread_manager.get_other_partner_thread_id(thread_id)\n",
    "        # get both thread\n",
    "        thread_content = self.thread_manager.filter_thread_by_id(thread_id)\n",
    "        other_partner_thread_content = self.thread_manager.filter_thread_by_id(other_partner_thread_id)\n",
    "        # extract chat history from both threads\n",
    "        chat_history_partner1 = self.thread_manager.extract_chat_history_from_thread(thread_content)\n",
    "        chat_history_partner2 = self.thread_manager.extract_chat_history_from_thread(other_partner_thread_content)\n",
    "\n",
    "        combined_chat = chat_history_partner1 + chat_history_partner2\n",
    "\n",
    "        print(f\"Combined chat: {combined_chat}\")\n",
    "\n",
    "        client = OpenAI(api_key=os.getenv(\"OPENAI_API_KEY\"))\n",
    "\n",
    "        completion = client.chat.completions.create(\n",
    "            model=\"gpt-3.5-turbo\",\n",
    "            messages=[\n",
    "                {\"role\": \"system\", \"content\": \"\"\"\n",
    "                    You are an expert relationship counselor. \n",
    "                    The user is providing various perspectives on a conflict within a relationship. \n",
    "                    Your task is to analyze these perspectives and offer thoughtful, empathetic, and actionable advice \n",
    "                    to help resolve the conflict. Consider the emotions and viewpoints of all parties involved and \n",
    "                    suggest a resolution that promotes understanding, communication, and mutual respect.\n",
    "                    \n",
    "                    Please adress them both with their names, to make it more personal. \n",
    "                    Try to avoid leaking information you got in the prompt.\n",
    "                \"\"\"},\n",
    "                *combined_chat\n",
    "            ]\n",
    "        )\n",
    "        return completion.choices[0].message.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Combined chat: [{'role': 'user', 'name': 'Tom', 'content': 'What is the problem here Linda!!!'}, {'role': 'assistant', 'name': 'HarmonyAI', 'content': \"It sounds like you're feeling frustrated. I'm here to listen. Could you tell me more about what's been happening with Linda that's causing you concern?\"}, {'role': 'user', 'name': 'Tom', 'content': 'she is complaining about household chores as usual'}, {'role': 'assistant', 'name': 'HarmonyAI', 'content': \"I understand how that could be stressful. Have you both discussed how to divide household chores fairly? It might help to have a calm conversation to understand each other's perspectives and find a solution that works for both of you.\"}, {'role': 'user', 'name': 'linda', 'content': 'I have a problem with my partner Tom. he is not helping me with the house hold chores'}, {'role': 'assistant', 'name': 'HarmonyAI', 'content': \"I'm sorry to hear that you're struggling with this issue. Have you spoken to Tom about how you're feeling and the importance of sharing the household responsibilities? What are his thoughts on the matter?\"}, {'role': 'user', 'name': 'linda', 'content': \"Yes, we I always mention that I'm the only one in this house washing the dishes and cleaning the floor. He replies by simply saying that he is super busy and it's normal for me to do these tasks \"}, {'role': 'assistant', 'name': 'HarmonyAI', 'content': \"I understand how frustrating that must be for you. It's important to have an open and honest conversation with Tom about how you both can divide the household chores more fairly. Maybe you can create a shared chore schedule that accommodates both of your schedules. It's essential to communicate your needs and listen to his perspective as well.\"}]\n"
     ]
    },
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for +: 'dict' and 'list'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb Cell 13\u001b[0m line \u001b[0;36m5\n\u001b[1;32m      <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m resolution_logic \u001b[39m=\u001b[39m ResolutionLogic(literal_manager)\n\u001b[1;32m      <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m thread_id \u001b[39m=\u001b[39m \u001b[39m'\u001b[39m\u001b[39mb6d8486f-a6d9-4731-bfdd-be789613b1df\u001b[39m\u001b[39m'\u001b[39m\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=4'>5</a>\u001b[0m result \u001b[39m=\u001b[39m resolution_logic\u001b[39m.\u001b[39mresolve_conflict(thread_id)\n",
      "\u001b[1;32m/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb Cell 13\u001b[0m line \u001b[0;36m2\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=19'>20</a>\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mCombined chat: \u001b[39m\u001b[39m{\u001b[39;00mcombined_chat\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m)\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=21'>22</a>\u001b[0m client \u001b[39m=\u001b[39m OpenAI(api_key\u001b[39m=\u001b[39mos\u001b[39m.\u001b[39mgetenv(\u001b[39m\"\u001b[39m\u001b[39mOPENAI_API_KEY\u001b[39m\u001b[39m\"\u001b[39m))\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=23'>24</a>\u001b[0m completion \u001b[39m=\u001b[39m client\u001b[39m.\u001b[39mchat\u001b[39m.\u001b[39mcompletions\u001b[39m.\u001b[39mcreate(\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=24'>25</a>\u001b[0m     model\u001b[39m=\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mgpt-3.5-turbo\u001b[39m\u001b[39m\"\u001b[39m,\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=25'>26</a>\u001b[0m     messages\u001b[39m=\u001b[39m[\n\u001b[0;32m---> <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=26'>27</a>\u001b[0m         {\u001b[39m\"\u001b[39m\u001b[39mrole\u001b[39m\u001b[39m\"\u001b[39m: \u001b[39m\"\u001b[39m\u001b[39msystem\u001b[39m\u001b[39m\"\u001b[39m, \u001b[39m\"\u001b[39m\u001b[39mcontent\u001b[39m\u001b[39m\"\u001b[39m: \u001b[39m\"\"\"\u001b[39m\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=27'>28</a>\u001b[0m \u001b[39m            You are an expert relationship counselor. \u001b[39m\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=28'>29</a>\u001b[0m \u001b[39m            The user is providing various perspectives on a conflict within a relationship. \u001b[39m\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=29'>30</a>\u001b[0m \u001b[39m            Your task is to analyze these perspectives and offer thoughtful, empathetic, and actionable advice \u001b[39m\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=30'>31</a>\u001b[0m \u001b[39m            to help resolve the conflict. Consider the emotions and viewpoints of all parties involved and \u001b[39m\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=31'>32</a>\u001b[0m \u001b[39m            suggest a resolution that promotes understanding, communication, and mutual respect.\u001b[39m\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=32'>33</a>\u001b[0m \u001b[39m            \u001b[39m\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=33'>34</a>\u001b[0m \u001b[39m            Please adress them both with their names, to make it more personal. \u001b[39m\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=34'>35</a>\u001b[0m \u001b[39m            Try to avoid leaking information you got in the prompt.\u001b[39m\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=35'>36</a>\u001b[0m \u001b[39m        \u001b[39m\u001b[39m\"\"\"\u001b[39m} \n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=36'>37</a>\u001b[0m         \u001b[39m+\u001b[39m\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=37'>38</a>\u001b[0m         combined_chat\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=38'>39</a>\u001b[0m     ]\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=39'>40</a>\u001b[0m )\n\u001b[1;32m     <a href='vscode-notebook-cell:/Users/mousamaxod/Documents/TUM/EmpatheticChatBot/empathetic_text_generation/ChattingBotMechanism/chainlit/literalai.ipynb#X14sZmlsZQ%3D%3D?line=40'>41</a>\u001b[0m \u001b[39mreturn\u001b[39;00m completion\u001b[39m.\u001b[39mchoices[\u001b[39m0\u001b[39m]\u001b[39m.\u001b[39mmessage\u001b[39m.\u001b[39mcontent\n",
      "\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for +: 'dict' and 'list'"
     ]
    }
   ],
   "source": [
    "resolution_logic = ResolutionLogic(literal_manager)\n",
    "\n",
    "thread_id = 'b6d8486f-a6d9-4731-bfdd-be789613b1df'\n",
    "\n",
    "result = resolution_logic.resolve_conflict(thread_id)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "NLP",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}