File size: 92,255 Bytes
0c19b9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "DEMO_MODE = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import os\n",
    "import gzip\n",
    "import pickle\n",
    "from openai import OpenAI\n",
    "import torch.nn.functional as F\n",
    "import torch\n",
    "from tqdm import tqdm\n",
    "import json\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "client = OpenAI()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_openai_response(prompt):\n",
    "    tokens = 1000\n",
    "    model=\"gpt-4-turbo-preview\" if not DEMO_MODE else \"gpt-4o-mini\"\n",
    "    # model=\"gpt-3.5-turbo-0125\"\n",
    "    response = client.chat.completions.create(\n",
    "        model=model,\n",
    "        messages=[\n",
    "            {\n",
    "                \"role\": \"system\",\n",
    "                \"content\": \"You are a helpful assistant\"\n",
    "            },\n",
    "            {\n",
    "                \"role\": \"user\",\n",
    "                \"content\": prompt\n",
    "            }\n",
    "            ],\n",
    "        temperature=0,\n",
    "        max_tokens=tokens,\n",
    "        top_p=1,\n",
    "    )\n",
    "    choice = response.choices[0]\n",
    "\n",
    "    text = choice.message.content\n",
    "\n",
    "\n",
    "    return text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def process_thread(row):\n",
    "    try:\n",
    "        date = row[\"dates\"].split(\"<sep>\")[-1]\n",
    "\n",
    "        thread = \"\"\n",
    "        thread += \"Date: \" + date[:7] + \"\\n\"\n",
    "        thread += \"Topic: \" + row[\"topic\"] + \"\\n\"        \n",
    "        thread += \"### Original post:\\n\"\n",
    "        i = 1\n",
    "        for (post, date) in zip(row[\"post\"].split(\"<sep>\"), row[\"dates\"].split(\"<sep>\")):\n",
    "            if len(post) > 1200:\n",
    "                thread += post[:1200] + \"<rest of post truncated>\\n\\n\"\n",
    "                thread += f\"### Reply {i}:\\n\"\n",
    "                i += 1\n",
    "            elif len(post) < 5:\n",
    "                pass\n",
    "            else:\n",
    "                thread += post + \"\\n\\n\"\n",
    "                thread += f\"### Reply {i}:\\n\"\n",
    "                i += 1\n",
    "        #remove the last line\n",
    "        thread = thread[:-len(f\"### Reply {i-1}:\\n\")]\n",
    "        if len(thread) > 5000:\n",
    "            thread = thread[:5000] + \"<rest of thread truncated>\\n\"\n",
    "\n",
    "        return row[\"index\"], date, thread\n",
    "\n",
    "    except:\n",
    "        print(\"Error processing thread:\" + str(row[\"index\"]))\n",
    "        return None, None, None\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "refresh_df = False\n",
    "# refresh_df = True\n",
    "\n",
    "if refresh_df:\n",
    "    categories = [\n",
    "        \"groupbuys\",\n",
    "        \"hardware\",\n",
    "        \"miners\",\n",
    "        \"mining\",\n",
    "        \"mining_support\",\n",
    "        # \"pools\",\n",
    "    ]\n",
    "\n",
    "    df = pd.DataFrame()\n",
    "\n",
    "    #load every csv in the folder and append them\n",
    "    for cat in categories:\n",
    "        with gzip.open('../1_forum_dataset/cleaned-data/'+cat+'.pkl.gz', 'rb') as f:\n",
    "            df_cat = pickle.load(f)\n",
    "            df_cat['category'] = cat\n",
    "            df = pd.concat([df, df_cat], ignore_index=True)\n",
    "\n",
    "    df[\"index\"] = df.index\n",
    "    df.to_csv(\"cache.csv\", index=False)\n",
    "\n",
    "else:\n",
    "    df = pd.read_csv(\"cache.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>topic</th>\n",
       "      <th>post</th>\n",
       "      <th>date</th>\n",
       "      <th>dates</th>\n",
       "      <th>category</th>\n",
       "      <th>index</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[Group Buy in China]  Avalon batch #3</td>\n",
       "      <td>List of &lt;truncated&gt; Forum Name - Bitcoin Addre...</td>\n",
       "      <td>2013-03-25 11:06:33</td>\n",
       "      <td>2013-03-25 10:16:23&lt;sep&gt;2013-03-25 10:42:45&lt;se...</td>\n",
       "      <td>groupbuys</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Avalon Group buy - Germany</td>\n",
       "      <td>Hi, I'm in time to invest?&lt;sep&gt;too late, sorry</td>\n",
       "      <td>2013-03-25 13:13:44</td>\n",
       "      <td>2013-03-25 12:47:34&lt;sep&gt;2013-03-25 13:13:44</td>\n",
       "      <td>groupbuys</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Avalon Group buy - Germany - closed</td>\n",
       "      <td>I am willing to organize a community purchase ...</td>\n",
       "      <td>2013-03-25 13:14:29</td>\n",
       "      <td>2013-03-25 13:14:29</td>\n",
       "      <td>groupbuys</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>I'm about to buy Avalon asic 85</td>\n",
       "      <td>it sold out, its gone.&lt;sep&gt;People just order b...</td>\n",
       "      <td>2013-03-25 14:26:29</td>\n",
       "      <td>2013-03-25 13:46:12&lt;sep&gt;2013-03-25 14:26:29</td>\n",
       "      <td>groupbuys</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>CANCELLED [Group Buy in China]  Avalon batch #3</td>\n",
       "      <td>Do you not have enough BTC to buy a batch 3 Av...</td>\n",
       "      <td>2013-03-25 16:42:09</td>\n",
       "      <td>2013-03-25 16:42:09</td>\n",
       "      <td>groupbuys</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24184</th>\n",
       "      <td>S19 Amlogic control board brick ?</td>\n",
       "      <td>Hello everyone, I have an amlogic s19 j pro ca...</td>\n",
       "      <td>2023-10-23 15:51:19</td>\n",
       "      <td>2023-08-30 13:53:04&lt;sep&gt;2023-08-30 17:45:01&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>24184</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24185</th>\n",
       "      <td>S19jPro abnormal network - (Will not connect t...</td>\n",
       "      <td>Driving me nuts... after changing pool address...</td>\n",
       "      <td>2023-10-24 14:00:23</td>\n",
       "      <td>2023-02-24 15:37:21&lt;sep&gt;2023-02-24 15:59:12&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>24185</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24186</th>\n",
       "      <td>Flashing control Board S9 to R4</td>\n",
       "      <td>Hello,I recently purchased a control board tha...</td>\n",
       "      <td>2023-10-25 23:42:40</td>\n",
       "      <td>2023-10-05 14:14:14&lt;sep&gt;2023-10-09 05:06:58&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>24186</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24187</th>\n",
       "      <td>AvalonMiner 1166Pro-72</td>\n",
       "      <td>Hello,can someone help me find the problem wit...</td>\n",
       "      <td>2023-10-26 08:40:14</td>\n",
       "      <td>2023-10-09 07:54:00&lt;sep&gt;2023-10-09 11:50:47&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>24187</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24188</th>\n",
       "      <td>need advice to reduce noise and monitor asic m...</td>\n",
       "      <td>I think Awesomeminer supports this unit model ...</td>\n",
       "      <td>2023-10-27 16:39:20</td>\n",
       "      <td>2023-09-21 11:52:00&lt;sep&gt;2023-10-27 15:31:24&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>24188</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>24189 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                   topic  \\\n",
       "0                  [Group Buy in China]  Avalon batch #3   \n",
       "1                             Avalon Group buy - Germany   \n",
       "2                    Avalon Group buy - Germany - closed   \n",
       "3                        I'm about to buy Avalon asic 85   \n",
       "4        CANCELLED [Group Buy in China]  Avalon batch #3   \n",
       "...                                                  ...   \n",
       "24184                  S19 Amlogic control board brick ?   \n",
       "24185  S19jPro abnormal network - (Will not connect t...   \n",
       "24186                    Flashing control Board S9 to R4   \n",
       "24187                             AvalonMiner 1166Pro-72   \n",
       "24188  need advice to reduce noise and monitor asic m...   \n",
       "\n",
       "                                                    post                 date  \\\n",
       "0      List of <truncated> Forum Name - Bitcoin Addre...  2013-03-25 11:06:33   \n",
       "1         Hi, I'm in time to invest?<sep>too late, sorry  2013-03-25 13:13:44   \n",
       "2      I am willing to organize a community purchase ...  2013-03-25 13:14:29   \n",
       "3      it sold out, its gone.<sep>People just order b...  2013-03-25 14:26:29   \n",
       "4      Do you not have enough BTC to buy a batch 3 Av...  2013-03-25 16:42:09   \n",
       "...                                                  ...                  ...   \n",
       "24184  Hello everyone, I have an amlogic s19 j pro ca...  2023-10-23 15:51:19   \n",
       "24185  Driving me nuts... after changing pool address...  2023-10-24 14:00:23   \n",
       "24186  Hello,I recently purchased a control board tha...  2023-10-25 23:42:40   \n",
       "24187  Hello,can someone help me find the problem wit...  2023-10-26 08:40:14   \n",
       "24188  I think Awesomeminer supports this unit model ...  2023-10-27 16:39:20   \n",
       "\n",
       "                                                   dates        category  \\\n",
       "0      2013-03-25 10:16:23<sep>2013-03-25 10:42:45<se...       groupbuys   \n",
       "1            2013-03-25 12:47:34<sep>2013-03-25 13:13:44       groupbuys   \n",
       "2                                    2013-03-25 13:14:29       groupbuys   \n",
       "3            2013-03-25 13:46:12<sep>2013-03-25 14:26:29       groupbuys   \n",
       "4                                    2013-03-25 16:42:09       groupbuys   \n",
       "...                                                  ...             ...   \n",
       "24184  2023-08-30 13:53:04<sep>2023-08-30 17:45:01<se...  mining_support   \n",
       "24185  2023-02-24 15:37:21<sep>2023-02-24 15:59:12<se...  mining_support   \n",
       "24186  2023-10-05 14:14:14<sep>2023-10-09 05:06:58<se...  mining_support   \n",
       "24187  2023-10-09 07:54:00<sep>2023-10-09 11:50:47<se...  mining_support   \n",
       "24188  2023-09-21 11:52:00<sep>2023-10-27 15:31:24<se...  mining_support   \n",
       "\n",
       "       index  \n",
       "0          0  \n",
       "1          1  \n",
       "2          2  \n",
       "3          3  \n",
       "4          4  \n",
       "...      ...  \n",
       "24184  24184  \n",
       "24185  24185  \n",
       "24186  24186  \n",
       "24187  24187  \n",
       "24188  24188  \n",
       "\n",
       "[24189 rows x 6 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error processing thread:2967\n",
      "Error processing thread:13251\n",
      "Error processing thread:9306\n",
      "Error processing thread:9152\n",
      "Error processing thread:6543\n",
      "Error processing thread:2907\n",
      "Error processing thread:4609\n",
      "Error processing thread:6620\n",
      "Error processing thread:2344\n",
      "Error processing thread:12206\n",
      "Error processing thread:7170\n",
      "Error processing thread:6956\n",
      "Error processing thread:5493\n",
      "Error processing thread:14915\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "path = \"./\"\n",
    "file_name = \"dataset.csv\" if not DEMO_MODE else \"demo_dataset.csv\"\n",
    "\n",
    "already_processed_thread_ids = []\n",
    "\n",
    "if not os.path.exists(path+file_name):\n",
    "    dataset = pd.DataFrame(columns=['index','input','output'])    \n",
    "else:\n",
    "    dataset = pd.read_csv(path+file_name)\n",
    "    already_processed_thread_ids = dataset['index'].tolist()\n",
    "\n",
    "# for each unique year, sample x threads\n",
    "x = 230 if not DEMO_MODE else 1\n",
    "df2 = df.sample(24000,random_state=44)\n",
    "rows = pd.DataFrame()\n",
    "unique_years = np.arange(2010, 2023+1)\n",
    "year_counts = {year: 0 for year in unique_years}\n",
    "for i in range(len(df2)):\n",
    "    index, date, thread = process_thread(df2.iloc[i])\n",
    "    if index is None:\n",
    "        continue\n",
    "    year = int(date[:4])\n",
    "    if year_counts[year] < x:\n",
    "        rows = pd.concat([rows, pd.DataFrame(df2.iloc[i]).T], ignore_index=True)\n",
    "        year_counts[year] += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>topic</th>\n",
       "      <th>post</th>\n",
       "      <th>date</th>\n",
       "      <th>dates</th>\n",
       "      <th>category</th>\n",
       "      <th>index</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Selling another batch of 40 ICARUS - sold out</td>\n",
       "      <td>Those Icarus are batch 3, tested for several w...</td>\n",
       "      <td>2012-06-15 10:53:37</td>\n",
       "      <td>2012-06-15 03:19:09&lt;sep&gt;2012-06-15 10:53:12&lt;se...</td>\n",
       "      <td>hardware</td>\n",
       "      <td>4109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Advice -Adding additional 6 pin PCIE outputs o...</td>\n",
       "      <td>Hi AllI have a few modular/semi modular PC psu...</td>\n",
       "      <td>2022-09-22 01:12:31</td>\n",
       "      <td>2022-09-20 19:44:16&lt;sep&gt;2022-09-21 01:29:09&lt;se...</td>\n",
       "      <td>hardware</td>\n",
       "      <td>11208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Please Help: Mining with both cores of 5970 wi...</td>\n",
       "      <td>Hi, I'm having trouble setting up a 5970 and m...</td>\n",
       "      <td>2013-07-04 15:42:38</td>\n",
       "      <td>2013-03-27 13:50:47&lt;sep&gt;2013-03-27 20:16:41&lt;se...</td>\n",
       "      <td>miners</td>\n",
       "      <td>12483</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ASIC Not working!!! HELP</td>\n",
       "      <td>An ASIC is an Application Specific Integrated ...</td>\n",
       "      <td>2019-09-12 00:27:02</td>\n",
       "      <td>2019-09-10 15:56:23&lt;sep&gt;2019-09-10 16:04:48&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>23073</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>USB Block Erupter showing up as generic USB De...</td>\n",
       "      <td>I've been mining with two USB Block Erupter Sa...</td>\n",
       "      <td>2014-03-19 04:09:42</td>\n",
       "      <td>2014-03-18 05:11:47&lt;sep&gt;2014-03-19 03:06:55&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>19054</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>A little more proof the Cloudthink miner is fa...</td>\n",
       "      <td>How is this site still a thing? Has there not ...</td>\n",
       "      <td>2015-08-05 16:05:47</td>\n",
       "      <td>2015-08-05 07:06:39&lt;sep&gt;2015-08-05 08:36:31&lt;se...</td>\n",
       "      <td>hardware</td>\n",
       "      <td>9265</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>MOVED: [AJUDA] Montar Máquina de Mineração</td>\n",
       "      <td>This topic has been moved to Trashcan.&lt;link&gt; i...</td>\n",
       "      <td>2016-05-20 22:38:16</td>\n",
       "      <td>2016-05-20 22:38:16</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>21036</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Monitoring of hash rate over short time periods</td>\n",
       "      <td>HiI'm running cgminer with quite a few gpus. I...</td>\n",
       "      <td>2011-12-15 11:38:16</td>\n",
       "      <td>2011-12-15 10:36:13&lt;sep&gt;2011-12-15 10:51:52&lt;se...</td>\n",
       "      <td>miners</td>\n",
       "      <td>11702</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Ledger Nano Ether Wallet</td>\n",
       "      <td>Hi, first time using Ledger nano s, with MEW w...</td>\n",
       "      <td>2018-05-16 20:35:32</td>\n",
       "      <td>2018-05-16 05:40:54&lt;sep&gt;2018-05-16 06:38:50&lt;se...</td>\n",
       "      <td>hardware</td>\n",
       "      <td>10730</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>AntMiner R4 Stopped working</td>\n",
       "      <td>my Antminer R4 (Antminer R4, Batch 5(7.5TH/s))...</td>\n",
       "      <td>2017-11-25 08:10:50</td>\n",
       "      <td>2017-11-25 00:57:57&lt;sep&gt;2017-11-25 01:37:10&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>21854</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>BlackArrow Prospero X-3 [Help] (2020)</td>\n",
       "      <td>Hi,I just bought myself the Black Arrow X3, fo...</td>\n",
       "      <td>2020-04-25 11:10:31</td>\n",
       "      <td>2020-04-24 15:34:03&lt;sep&gt;2020-04-24 16:34:22&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>23255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Antminer S19 Control Board</td>\n",
       "      <td>The Antminer S19 Control Board is a powerful a...</td>\n",
       "      <td>2023-07-12 01:09:01</td>\n",
       "      <td>2023-07-06 08:22:08&lt;sep&gt;2023-07-06 08:44:39&lt;se...</td>\n",
       "      <td>hardware</td>\n",
       "      <td>11328</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Innosilcon is trying to get rid of heavily use...</td>\n",
       "      <td>Innosilicon is offering \"manufacturer refurbis...</td>\n",
       "      <td>2021-09-23 17:20:56</td>\n",
       "      <td>2021-08-29 12:41:40&lt;sep&gt;2021-08-29 21:47:04&lt;se...</td>\n",
       "      <td>mining</td>\n",
       "      <td>16133</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Buffer overflow</td>\n",
       "      <td>This has happened to me every time a hash with...</td>\n",
       "      <td>2010-11-29 17:21:55</td>\n",
       "      <td>2010-11-29 13:48:54&lt;sep&gt;2010-11-29 17:21:55</td>\n",
       "      <td>miners</td>\n",
       "      <td>11378</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                topic  \\\n",
       "0       Selling another batch of 40 ICARUS - sold out   \n",
       "1   Advice -Adding additional 6 pin PCIE outputs o...   \n",
       "2   Please Help: Mining with both cores of 5970 wi...   \n",
       "3                            ASIC Not working!!! HELP   \n",
       "4   USB Block Erupter showing up as generic USB De...   \n",
       "5   A little more proof the Cloudthink miner is fa...   \n",
       "6          MOVED: [AJUDA] Montar Máquina de Mineração   \n",
       "7     Monitoring of hash rate over short time periods   \n",
       "8                            Ledger Nano Ether Wallet   \n",
       "9                         AntMiner R4 Stopped working   \n",
       "10              BlackArrow Prospero X-3 [Help] (2020)   \n",
       "11                         Antminer S19 Control Board   \n",
       "12  Innosilcon is trying to get rid of heavily use...   \n",
       "13                                    Buffer overflow   \n",
       "\n",
       "                                                 post                 date  \\\n",
       "0   Those Icarus are batch 3, tested for several w...  2012-06-15 10:53:37   \n",
       "1   Hi AllI have a few modular/semi modular PC psu...  2022-09-22 01:12:31   \n",
       "2   Hi, I'm having trouble setting up a 5970 and m...  2013-07-04 15:42:38   \n",
       "3   An ASIC is an Application Specific Integrated ...  2019-09-12 00:27:02   \n",
       "4   I've been mining with two USB Block Erupter Sa...  2014-03-19 04:09:42   \n",
       "5   How is this site still a thing? Has there not ...  2015-08-05 16:05:47   \n",
       "6   This topic has been moved to Trashcan.<link> i...  2016-05-20 22:38:16   \n",
       "7   HiI'm running cgminer with quite a few gpus. I...  2011-12-15 11:38:16   \n",
       "8   Hi, first time using Ledger nano s, with MEW w...  2018-05-16 20:35:32   \n",
       "9   my Antminer R4 (Antminer R4, Batch 5(7.5TH/s))...  2017-11-25 08:10:50   \n",
       "10  Hi,I just bought myself the Black Arrow X3, fo...  2020-04-25 11:10:31   \n",
       "11  The Antminer S19 Control Board is a powerful a...  2023-07-12 01:09:01   \n",
       "12  Innosilicon is offering \"manufacturer refurbis...  2021-09-23 17:20:56   \n",
       "13  This has happened to me every time a hash with...  2010-11-29 17:21:55   \n",
       "\n",
       "                                                dates        category  index  \n",
       "0   2012-06-15 03:19:09<sep>2012-06-15 10:53:12<se...        hardware   4109  \n",
       "1   2022-09-20 19:44:16<sep>2022-09-21 01:29:09<se...        hardware  11208  \n",
       "2   2013-03-27 13:50:47<sep>2013-03-27 20:16:41<se...          miners  12483  \n",
       "3   2019-09-10 15:56:23<sep>2019-09-10 16:04:48<se...  mining_support  23073  \n",
       "4   2014-03-18 05:11:47<sep>2014-03-19 03:06:55<se...  mining_support  19054  \n",
       "5   2015-08-05 07:06:39<sep>2015-08-05 08:36:31<se...        hardware   9265  \n",
       "6                                 2016-05-20 22:38:16  mining_support  21036  \n",
       "7   2011-12-15 10:36:13<sep>2011-12-15 10:51:52<se...          miners  11702  \n",
       "8   2018-05-16 05:40:54<sep>2018-05-16 06:38:50<se...        hardware  10730  \n",
       "9   2017-11-25 00:57:57<sep>2017-11-25 01:37:10<se...  mining_support  21854  \n",
       "10  2020-04-24 15:34:03<sep>2020-04-24 16:34:22<se...  mining_support  23255  \n",
       "11  2023-07-06 08:22:08<sep>2023-07-06 08:44:39<se...        hardware  11328  \n",
       "12  2021-08-29 12:41:40<sep>2021-08-29 21:47:04<se...          mining  16133  \n",
       "13        2010-11-29 13:48:54<sep>2010-11-29 17:21:55          miners  11378  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# pd.set_option('display.max_rows', None)\n",
    "# rows.sort_values(by=\"date\", inplace=True)\n",
    "# rows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "prompt = \"\"\"User:\n",
    "In the given Bitcoin forum thread, pay close attention to the language used when mentioning hardware pieces. Look for explicit statements indicating ownership or hypothetical discussions.\n",
    "\n",
    "{}\n",
    "\n",
    "\n",
    "\n",
    "Reply with a formatted JSON document containing an array of objects. Each object should represent a piece of hardware mentioned in the thread and include the following fields:\n",
    "- hardware_name: A string containing the name of the hardware.\n",
    "- hardware_is_owned: A boolean. If the mention suggests concrete ownership by any user, write true. If the hardware is discussed in a hypothetical or speculative way, write false. \n",
    "\n",
    "\n",
    "Assistant:\n",
    "Sure! Here is the requested JSON file, with the correct ownership status for each piece of hardware:\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "indices, dates, threads = [], [], []\n",
    "for j in range(len(rows)):\n",
    "    row = rows.iloc[j]\n",
    "    if(len(row[\"post\"]) < 20):\n",
    "        print(f\"skipping {j} as it is too short\")\n",
    "        continue\n",
    "\n",
    "    id, date, thread = process_thread(row)\n",
    "\n",
    "    if id in already_processed_thread_ids:\n",
    "        print(f\"Skipping thread {id} as it is already processed\")\n",
    "        continue\n",
    "\n",
    "    indices.append(id)\n",
    "    dates.append(date)\n",
    "    threads.append(thread)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "14"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(indices)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "processing thread id 4109\n",
      "\n",
      "Date: 2012-06\n",
      "Topic: Selling another batch of 40 ICARUS - sold out\n",
      "### Original post:\n",
      "Those Icarus are batch 3, tested for several weeks by me. mostly test with cgminer rig development, use OpenWrt router as host.I will take orders from tomorrow, Wednesday, May 23 5:00AM UTC+8 (don't send email before this time) ---- until all 40 are sold.Price: 480USD + shipping cost.Package content: Icarus, usb cable, power adapter or power wireAll package will send by EMS (<link> time we only accept BTC. after I receive order email I will send a new btc address to you. then after i receice the btc, I will ship your package immediately.Orders take by email <truncated> please add [ICARUS] to the subject. there is no confirm email. I will send you one email after I get the EMS track NO.(means packages already sent out, shipping from Beijing/China with EMS). please write those information in email:1. How many Icarus you want.2. You want power adapter or power wire. I advise you using your own ATX power if you order more then 2 Icarus.3. Address detail: name: company(optional): address: city: province: country: ZIP: TEL:More Icarus info please check:<link><link>\n",
      "\n",
      "### Reply 1:\n",
      "wow!Now here is all sold out , anyone interested in ICArus boards should visit this topic:<link> still some ICA available there.\n",
      "\n",
      "### Reply 2:\n",
      "Another 10 Icarus.\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"ICARUS\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"ICARUS boards\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"ICA\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"ICARUS\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"ICARUS boards\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"ICA\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 11208\n",
      "\n",
      "Date: 2022-09\n",
      "Topic: Advice -Adding additional 6 pin PCIE outputs on a PC modular Power Supply?\n",
      "### Original post:\n",
      "Hi AllI have a few modular/semi modular PC psu's and was thinking of using the to pwer some S9 miners with 2 cards. Most of what i have are 1000w or higher.They will be worthless selling so might be better put to use on some S9s powered with2 cards, so i would need x7 ouputs all together.I think i could use an existing hard wired PCIE (6 pin or not) to power the control board.Then on the dedicated high amp PCIE modular ouputs could i not solder on connections and 'share' the load so x2 on each output?I have only seen x8 to x2 PCIE cables so could i not just splice in and solder another?If this works i could do a few more miers in thsi set up as it would be low power and quite when set to 700/800w.Anyone done this or got an opinion on it?The PSU's will either go to waste tbh.Pics attached.<link>\n",
      "\n",
      "### Reply 1:\n",
      "@NotFuzzyWarmYes i will be running only 2 boards @ 700w or 800w.Is that why 'common rail' modular PSUs are so expensive?The only PSUs i can see that have enough outputs (X7) are the EVGA ones and they are silly money, i'm surprised that nobody has found a decent PSU and 'modded' them for more outputs tbh.....I just can't find makes that suffice apart from that brand?I think if i open it i can see rails and go from there, 3 on each for the hash boards and an existing 12v ouput for the control board.Thanks for the advice.\n",
      "\n",
      "### Reply 2:\n",
      "Looks like the +12v are seperate rails and GND/-12v shared.I will just add an extra pin to each double 8pin >x2 6pin.So i will have a set of two 8pin >x3 6 pins.Current will be approx 800/12=66.67aIs this correct?<link>\n",
      "\n",
      "### Reply 3:\n",
      "To be honest, modular plug PSU's all have 1 major problem: They are pushing the maximum current rating through the contacts and generally have only 18ga wires between the PSU and PCIe plugs.Ok, that's 2 major problems...That said, since you are talking about running at reduced power it may not be an issue, just periodically check to see how warm the PSU connectors get. Yes, I've had a few rather spectacularly fry over the years from when I used them to power s3's & s5's...Other thing to keep in mind is that particular PSU has 2 independent output rails. DO NOT connect power from the 2 different rails to 1 hash board! They will be shorted together and fight each other.\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"S9 miners\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"PC modular power supply\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"EVGA power supply\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"hash boards\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"PCIe plugs\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"S3 miners\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"S5 miners\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"S9 miners\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"PC modular power supply\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"EVGA power supply\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"hash boards\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"PCIe plugs\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"S3 miners\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"S5 miners\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 12483\n",
      "\n",
      "Date: 2013-07\n",
      "Topic: Please Help: Mining with both cores of 5970 with cgminer?\n",
      "### Original post:\n",
      "Hi, I'm having trouble setting up a 5970 and mining with cgminer The rig is running Linux (Xubuntu) and the 5970 is the only card ( I've followed this guide which has always worked with my other setups.)When I run cgminer -n from the terminal emulator on the desktop I get the <truncated> -nCL Platform 0 vendor: Advanced Micro Devices, Inc. CL Platform 0 name: AMD Accelerated Parallel Processing CL Platform 0 version: OpenCL 1.1 AMD-APP-SDK-v2.5 (793.1) Platform 0 devices: 1 0 Cypress ADL found more devices than opencl! There is possibly at least one GPU that doesn't support OpenCL Use the gpu map feature to reliably map OpenCL to ADL WARNING: Number of OpenCL and ADL devices did not match! Hardware monitoring may NOT match up with devices! GPU 0 ATI Radeon HD 5900 Series hardware monitoring enabled 1 GPU devices max detected Seems to me, cgminer is not recognizing both cores of the 5970.(When I mine with cgminer from the terminal emulator on the Desktop, it's mining with only one core of the 5970)Interestingly, when I run the same command from a SSH terminal it gives me:Code:./cgminer -nCL Platform 0 vendor: Advanced Micro Devices, Inc. CL Platform 0 name: AMD Accelerated Parallel <rest of post truncated>\n",
      "\n",
      "### Reply 1:\n",
      "Do you have the newest drivers?\n",
      "\n",
      "### Reply 2:\n",
      "Usual instructions for when people DONT read the readme.Reconfigure xorg for all devices, start x and export the DISPLAY variable before starting cgminer.\n",
      "\n",
      "### Reply 3:\n",
      "I just find it so weird how people dont read something that specifically says \"READ ME!\"\n",
      "\n",
      "### Reply 4:\n",
      "Ahh, thanks guys I actually was exporting the DISPLAY variable in my mining startup script but I'd stupidly disabled this while installing/testing the card. That seems to have solved that problem! Unfortunately this led me on to a new issue: The Xubuntu computer loses power very quickly when I start mining on the 5970 with anything above intensity 1, but it mines fine (intensity 11) when installed in a different windows machine...When the linux comp powers off, it's without warning I have to wait a little and toggle the PSU switch before turning it on again. Both PC's have adequate PSU's (760W) and the 5790 is the only card being used. So it has me puzzled. Why would mining cause the linux machine to quickly shut off? Temps on the fan never get a chance to hit 80 before the power cuts off.I will start a new thread on this if it comes to me getting completely stuck (I can try a 7870 in the linux computer and see if it has the same problem), but I hoped someone may have a good idea why this is happening? ATI drivers are 11.11Thank you very much for ideas on this one and happy hashing!\n",
      "\n",
      "### Reply 5:\n",
      "Last problem now appears fixed after replacing PSU. Thanks again for the help!\n",
      "\n",
      "### Reply 6:\n",
      "Hi ckolivas,I read the readme, but I may be to \"slow\" to understand. I would definitely appreciate your help.I'm getting the same error. I triedsudo aticonfig --adapter=0,1 --initialI also have the following lines in my shell file to start cgminerexport DISPLAY=:0export <truncated> <truncated> I'm missing?\n",
      "\n",
      "### Reply 7:\n",
      "I realize I'm having issues with X server to start. So guess I need to fix that somehow.\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"5970\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"ATI Radeon HD 5900 Series\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"5790\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"7870\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"760W PSU\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"PSU\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"5970\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"ATI Radeon HD 5900 Series\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"5790\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"7870\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"760W PSU\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"PSU\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 23073\n",
      "\n",
      "Date: 2019-09\n",
      "Topic: ASIC Not working!!! HELP\n",
      "### Original post:\n",
      "An ASIC is an Application Specific Integrated Circuit, eg the chips used in a miner. I take it your MINER is not working and we are supposed to just check our crystal ball or guess what kind of miner it is? Try giving some useful information about it such <truncated> new or used?\n",
      "\n",
      "### Reply 1:\n",
      "a 17 second video is worthless.how about a guihow about api logshow about make and model?looks like an innosiliconlooks like it needs 2 psu'sis it this miner a6 or a6+\n",
      "\n",
      "### Reply 2:\n",
      "hey guys I bought AladdinMiner T1 and a psu but now the psu is not working, so I bought new \"bitmain APW3++\" and it was working fine the next day I increase the performance of the asic and it switched off now I can't turn it on!!!here is the video:<link> lights are not working.no ip address.fans starts and strops working.HELP\n",
      "\n",
      "### Reply 3:\n",
      "He clearly edited the post after you guys have commented, anyhow , this is the miner he is talking about I guess.<link> it does look like an Inno gear with a bit of modification, in that link they clearly saywhich means phill is right, you need at least two PSUs, each must be 1400w minimum , and according to the video, it does look like he got 2 PSUs connected, the miner's fan do spin for a while and then stop , and you saidWhich means you tried to overclock the miner, you either burned the miner or one of the PSUs, does it show on the network ?? can you access the user interface? please post more details.\n",
      "\n",
      "### Reply 4:\n",
      "Do note that the OP has not made any mention of trying to contact the distributor or manufacturer of this knock-off miner. That of course should be the very first thing the OP should have done...Nor have they posted anything else re what has been said so far.\n",
      "\n",
      "### Reply 5:\n",
      "He needs to know it's a knock-off in the first place, and honestly if the gear does 32th at 2800w as promised-- it does not matter what name they put on it, as for contacting the manufacturer, honestly this is usually the last thing I personally do simply because1-The support at these Chinese websites is terrible, had a ton of issues with my gears, most were solved by trial and error or from information I got online (mostly on this very forum) , while the manufacturer will give only give you the abc of trouble shooting only.2-In many places, the shipping cost for returning the miner back to china is unreasonable, to the extent that some people rather order new hash board/control board or a PSU than having to pay that much for shipping or wait for months to get their replacement.I think if OP provides enough information and kernel log, someone will be able to give him the solution for this problem without the need for a crystal ball.\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"AladdinMiner T1\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"bitmain APW3++\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"Innosilicon\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"PSU\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"knock-off miner\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"AladdinMiner T1\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"bitmain APW3++\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"Innosilicon\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"PSU\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"knock-off miner\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 19054\n",
      "\n",
      "Date: 2014-03\n",
      "Topic: USB Block Erupter showing up as generic USB Device instead of \"Port\", won't mine\n",
      "### Original post:\n",
      "I've been mining with two USB Block Erupter Sapphires without issue for at least a week now, properly cooled. Today, I've been messing around with things trying to get my Antminer U2 up and running and must've done something that now causes one of my erupters to show up under Device Manager as a usb device instead of under \"Ports\". When I try to mine with it, it just sits in standby doing nothing. However, if I plug it into my Win 7 machine it comes up normally under \"Ports\" instead of \"Universal Serial Bus Devices\" but I don't have an ethernet to that box to test if it will mine. I'm not sure what exactly is going on with this stick. Is it fried?\n",
      "\n",
      "### Reply 1:\n",
      "Maybe you installed a WinUSB driver?\n",
      "\n",
      "### Reply 2:\n",
      "Is the problem on a windows xp machine? This may be a device identifier issue. I've never seen it with 3 devices, but I suppose it is possible. There is a fix posted in these forums somewhere and if I have time to dig it up for you I will, but if you keep restarting and plugging it back in to different ports it may eventually pick up properly. Windows XP doesn't handle duplicate usb devices very well.\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"USB Block Erupter Sapphire\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"Antminer U2\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"USB Block Erupter Sapphire\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"Antminer U2\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 9265\n",
      "\n",
      "Date: 2015-08\n",
      "Topic: A little more proof the Cloudthink miner is fake... Shilled reddit accounts\n",
      "### Original post:\n",
      "How is this site still a thing? Has there not already been extensive proof uncovered that Cloudthink is a scam? I haven't talked to anyone within the Bitcoin community that has regarded as anything other than a scam.\n",
      "\n",
      "### Reply 1:\n",
      "Has anyone from Manchester walked to their supposed office? It wouldn't take much effort to provide verifiable evidence that this is a scam.\n",
      "\n",
      "### Reply 2:\n",
      "All I want to add is shame on any of the upstanding members that took on their Sig campaign and contributed to anyone getting taken advantage of. Betrayed by greed once again. I feel bad for anyone inexperienced that fell for this scam, it may have been obvious to most of us, but it was slightly less poorly planned out than many others.\n",
      "\n",
      "### Reply 3:\n",
      "Yes<link>\n",
      "\n",
      "### Reply 4:\n",
      "What about the dollar a day whores who signed up for the \"free\" packages and incessantly bumped this thread?<link> was plenty to be suspicious about when they signed up in the middle of June.\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware_mentions\": []\n",
      "}\n",
      "``` \n",
      "\n",
      "In the provided forum thread, there are no explicit mentions of any specific hardware pieces, nor are there any statements indicating ownership or hypothetical discussions about hardware. The conversation primarily revolves around the Cloudthink miner and its legitimacy, without referencing any particular hardware.\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware_mentions\": []\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 21036\n",
      "\n",
      "Date: 2016-05\n",
      "Topic: MOVED: [AJUDA] Montar Máquina de Mineração\n",
      "### Original post:\n",
      "This topic has been moved to Trashcan.<link> in English.\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "[\n",
      "    {\n",
      "        \"hardware_name\": \"Antminer S9\",\n",
      "        \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "        \"hardware_name\": \"AvalonMiner 741\",\n",
      "        \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "        \"hardware_name\": \"Bitmain Antminer L3+\",\n",
      "        \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "        \"hardware_name\": \"Innosilicon T2T\",\n",
      "        \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "        \"hardware_name\": \"Dragonmint T1\",\n",
      "        \"hardware_is_owned\": false\n",
      "    }\n",
      "]\n",
      "``` \n",
      "\n",
      "Note: The hardware names and ownership statuses are hypothetical, as the original post does not provide specific mentions of hardware ownership.\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "[\n",
      "    {\n",
      "        \"hardware_name\": \"Antminer S9\",\n",
      "        \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "        \"hardware_name\": \"AvalonMiner 741\",\n",
      "        \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "        \"hardware_name\": \"Bitmain Antminer L3+\",\n",
      "        \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "        \"hardware_name\": \"Innosilicon T2T\",\n",
      "        \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "        \"hardware_name\": \"Dragonmint T1\",\n",
      "        \"hardware_is_owned\": false\n",
      "    }\n",
      "]\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 11702\n",
      "\n",
      "Date: 2011-12\n",
      "Topic: Monitoring of hash rate over short time periods\n",
      "### Original post:\n",
      "HiI'm running cgminer with quite a few gpus. I want to tweak and monitor performance of each gpu at a time so I can fine tune them. Cgminer just offers average has hashrate for all. (6 gpus per client)Can I do this or is there another way I shud go about it? The average per gpu jumps around too much for my liking.Thank you.\n",
      "\n",
      "### Reply 1:\n",
      "You sure? Highlighted numbers are average per card AFAIK:\n",
      "\n",
      "### Reply 2:\n",
      "Yes but mine is constantly jumping around with very large variability . Is yours more stable? Upon further research I see a post where someone has mentioned switching to overclock makes the average more stable (6990) - ill test that out tho I wud prefer to keep it at 375W so I can predict electricity usage. In the meantime the average rate per gpu jumps around so much its ikpossible to gauge whether ur getting a small increase in hashing power.\n",
      "\n",
      "### Reply 3:\n",
      "The left figure (458.0) fluctuates a bit, I think its a 5s average; the right one that I highlighted (456.6), doesnt change at all (after running for a while). I think that is the average since starting the app?\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"gpu\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"6990\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"gpu\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"6990\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 10730\n",
      "\n",
      "Date: 2018-05\n",
      "Topic: Ledger Nano Ether Wallet\n",
      "### Original post:\n",
      "Hi, first time using Ledger nano s, with MEW wallet, i log in, it shows 5 different MEW address, are those all mine? who created those account, and how come I don't see private key when I log in those accounts? Also, I don't need any password like a normal wallet? little confused here how it works, can anyone explain? thanks\n",
      "\n",
      "### Reply 1:\n",
      "Consider Myetherwallet as an interface to interact with your Ledger nano S. You will still need to enter the PIN to unlock your Ledger or confirm the transactions from the device. The addresses are yours, pre-generated from your seed.\n",
      "\n",
      "### Reply 2:\n",
      "Ledger has its own HowTo for MyEtherWallet, have a look: <link> are also a ton of guides, blog articles and videos available: <link>\n",
      "\n",
      "### Reply 3:\n",
      "These wallets have already been built in you ledger nano s. When I'm bought trezor I got 5 eth addresses for my device. You can check your own cabinet on ledger where you can configure all functions\n",
      "\n",
      "### Reply 4:\n",
      "Thank you, but how come I am not able to see the private key for those pre-built 5 accounts? does it mean, I don't need private keys for those accounts?\n",
      "\n",
      "### Reply 5:\n",
      "Hello imteaz, look here:<link> hope the information will help you. All the best\n",
      "\n",
      "### Reply 6:\n",
      "The private-key is inside your Ledger. Putting in a simple way, MEW uses your public key (address) to see your balance and build the transaction, which its sent to the Ledger device, signed with the private-key and sent back to the computer, where its broadcasted. The private-key never leaves the device (reason why you can't see them, and why hardware wallets are so secure compared to normal desktop wallets).\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware_devices\": [\n",
      "    {\n",
      "      \"hardware_name\": \"Ledger Nano S\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"Trezor\",\n",
      "      \"hardware_is_owned\": true\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware_devices\": [\n",
      "    {\n",
      "      \"hardware_name\": \"Ledger Nano S\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"Trezor\",\n",
      "      \"hardware_is_owned\": true\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 21854\n",
      "\n",
      "Date: 2017-11\n",
      "Topic: AntMiner R4 Stopped working\n",
      "### Original post:\n",
      "my Antminer R4 (Antminer R4, Batch 5(7.5TH/s)) suddenly stopped working after reboot. i tried various options like reset using different methods but i cant get it to workeven the web based admin console was not reachable however afrer several reboots and holding the IP button i was able to connect to web based control panel...however strange problem is that i cant see the miner config screen though i can see other screensi updated firmware using web based console n got success message but still same problem persists...pfa screenshots and kindly advise ...<link>\n",
      "\n",
      "### Reply 1:\n",
      "too late you did firmware upgradei can't help you sorry.if you are usa based maybe bitmain warranty can help<link> r4 breaks alot and you muscled a firmware update on a broken r4.your best shot is bitmainwarranty good luck\n",
      "\n",
      "### Reply 2:\n",
      "is there a way to connect using ssh....\n",
      "\n",
      "### Reply 3:\n",
      "Too late .The r4 is very delicate,They break and break and break.Someone had a link that show how to reset to the original firmware.someone gave it to me it may work if you reset it.I will look for a link to the reset.In I reset it and it still did not work.I sent it in to bitmainwarranty and they did fix it.\n",
      "\n",
      "### Reply 4:\n",
      "You can ssh into it with username root and password admin.I doubt the firmware is causing this, at least, if it was installed correctly. I had an R4 controller fail and I replaced it with an S9 controller, flashing it with the R4 firmware and it works fine. If the image was installed properly, and your controller isn't broken, it should be working. Make sure you don't have anything preventing javascript from running on that page.The \"ant_data=;\" you see in the miner configuration page is there because the header has an inline script that begins with Code:echo \"ant_data = ${ant_result};\" The script is fetching cgi data from the config saved in <truncated> For some reason it is failing at that point.\n",
      "\n",
      "### Reply 5:\n",
      "thanks all for your suggestions ..\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"Antminer R4\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"S9 controller\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"Antminer R4\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"S9 controller\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 23255\n",
      "\n",
      "Date: 2020-04\n",
      "Topic: BlackArrow Prospero X-3 [Help] (2020)\n",
      "### Original post:\n",
      "Hi,I just bought myself the Black Arrow X3, for my personal collection of asics. But, I cannot connect to operate the machine. I saw that for the login it is: user = user, passworld = blackarrow but it shows me an error message that something is not valid. I contacted the seller and he said he knew nothing. Is it possible to reset the machine?\n",
      "\n",
      "### Reply 1:\n",
      "He might have sold you an unit which is affected by firmware virus. If he claims that he does not know what is wrong, that is probably because he was in same boat as you. Or he might have changed the password and forgot.But for your sake, try resetting your machine via reset button or recovery SD card.Also, isn't that unit like 5 years old? Why did you even buy it?\n",
      "\n",
      "### Reply 2:\n",
      "I make a collection of asic and I test it to find out how it works.\n",
      "\n",
      "### Reply 3:\n",
      "Check this post before firing them up, they have a history of burning down.<link>\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"Black Arrow X3\",\n",
      "      \"hardware_is_owned\": true\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"Black Arrow X3\",\n",
      "      \"hardware_is_owned\": true\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 11328\n",
      "\n",
      "Date: 2023-07\n",
      "Topic: Antminer S19 Control Board\n",
      "### Original post:\n",
      "The Antminer S19 Control Board is a powerful and essential component of the Antminer S19 mining rig. Designed to optimize performance and efficiency, this control board plays a crucial role in ensuring the smooth operation of your mining equipment.The Antminer S19 Control Board is engineered to deliver exceptional performance, allowing you to maximize the hashing power of your mining rig. With its advanced chipset and optimized firmware, this control board ensures efficient communication between the different components of your Antminer S19, resulting in higher mining productivity and increased profitability.The Antminer S19 Control Board features a user-friendly interface that simplifies the management and monitoring of your mining rig. With its intuitive design and easy-to-navigate settings, you can efficiently control various parameters such as fan speed, voltage, and temperature. To Know More:<link>\n",
      "\n",
      "### Reply 1:\n",
      "I think we all know what a Control Board is.However, what we don't know is why you're writing this, in a way worthy of an AI, and on top of that putting the link of a Whatsminer PSU which is completely off-topic.\n",
      "\n",
      "### Reply 2:\n",
      "I recently purchased Antminer S19 pro 110Th from 570OLLC. Here's the link if you guys are interested: <link>\n",
      "\n",
      "### Reply 3:\n",
      "Are you sure you purchased the s19 unit from that link?When exactly?Or are you just trying to promote it here just like on other forums with some other newbie alt accounts and trying to promote it with fake/sweet words?I'm talking about this forum as you can see all responses came from newbies so it's very risky to buy on this site.\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"Antminer S19 Control Board\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"Antminer S19 pro 110Th\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"Whatsminer PSU\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"Antminer S19 Control Board\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"Antminer S19 pro 110Th\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"Whatsminer PSU\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 16133\n",
      "\n",
      "Date: 2021-09\n",
      "Topic: Innosilcon is trying to get rid of heavily used miners\n",
      "### Original post:\n",
      "Innosilicon is offering \"manufacturer refurbished\" T3+ and other miners. I ordered a T3+ 57T Bitcoin miner. I had to wait for 4 weeks after I paid in full in Bitcoin until they shipped it out. When it arrived it was in horrible condition: <link> of dust, with scratches, stains, missing screws, rattling parts, rust...The firmware was locked and I was not able to enter my own pool settings. There was plenty of evidence that this miner was not manufacturer refurbished, not even cleaned. Otherwise at least the firmware would have been reset. Innosilicon has 3 departments: while the support is trying to help to unlock the miner, the sales and order team tells me: \"This is what you get when you order from us. Deal with it!\"\n",
      "\n",
      "### Reply 1:\n",
      "I think other ppl here ordered the refurb T3s. Would be great to have their feedbacks!\n",
      "\n",
      "### Reply 2:\n",
      "Yes, please. Who else bought a refurb T3+ ? What was your experience?\n",
      "\n",
      "### Reply 3:\n",
      "have you ever got to the bottom of the pool settings being pre-completed and not updating ?also, sorry to hear about your experience, I hope it all goes well in the end\n",
      "\n",
      "### Reply 4:\n",
      "Yeah, they use the term refurbished for a miner that was damaged and repaired by them or something returned and they've set it back running. They did warn a bit but you didn't take the warning seriously, usually in those cases light scratches mean run over by an excavator:Sucks and if I were in your place, even if support manages to help you unblock the settings I would play possum and try to get a refund and send it back. I won't be surprised if that thing wouldn't break in a few months, external scratched and missing screws ain't a big deal but you should take a look inside if possible and have a beer nearby when you do\n",
      "\n",
      "### Reply 5:\n",
      "Refurbished miners could be a great bargain if you get a diamond in the rough with no issues but that is playing a dangerous game if there is no warranty attached to them. Depending on the price and time to get to you it may pay itself off quickly but if it breaks it could quickly become a paperweight or something that ends u costing what a new unit would plus the downtime to ship it back for repairs. Would love to hear feedback as well from anyone who bought one.\n",
      "\n",
      "### Reply 6:\n",
      "Those Innosilicon refurbished miners are 6 months garanty\n",
      "\n",
      "### Reply 7:\n",
      "You are right with the firmware lock, but this is a straight-out scam if you ask me, these were supposed to be \"manufacturer refurbished\", the ones in the video don't look anything like it, in fact, REAL refurbished miners are a lot more expensive than clean used miners, a while back used S9js were going for $250 while the refurbished once were going for at least $400, but those looked as good as new, no scratches, no lost screws, everything seemed like brand new, the miner in the video is a Used Miner with C- condition, selling it as a refurbished piece is nothing but scam IMO.\n",
      "\n",
      "### Reply 8:\n",
      "Looks like this is a rare problem that has happened before.There are threads about a T2 miner that had it on here.. also one on the russian mining board:<link> might need to do a translate on it with your browser)Post 11 reads:Maybe worth reaching out. Seems they found someone at Inno that can unlock it remotely for you.\n",
      "\n",
      "### Reply 9:\n",
      "Watching some videos from your YouTube channel and I like the soundproofing you have setup. I'd probably be mining with more hashrate at my home if I had such a setup as well. I should also mention that I thought for a second this was a bodybuilding YouTube channel instead of being about Bitcoin mining. From the look of your biceps I thought you might go hulk and crush that thing when it wasn't working.\n",
      "\n",
      "### Reply 10:\n",
      "Interesting , they do that constantley , I heard that their ceo is a close friend to the founder of ETH\n",
      "\n",
      "### Reply 11:\n",
      "Figured they would carry some sort of limited warranty. That said, considering Inno was made aware of the Fixed Address issue on at least some miners and quickly responded by putting out a fix for it one can't fault them for their response on that part. They also said they were going to issue a mass email to all customers who bought one of the refurbed miners to notify of them of the possible problem and fix for it if they received a miner that was locked. Hopefully the OP just got a miner that had already been shipped just before Inno became aware of the problem and the miner had yet yet been updated to OEM firmwareMy take on things is that the miners are of course from some of the farms in China that got shut down. It makes sense that a farm would use locked firmware to make sure there is (near) zero chance of miners being hijacked either through hacking or actual theft. If stolen, as soon as the miner goes on line Inno will know which miner and what the ip address is.Biggest problem is Inno dropping the ball on making sure the miners are at least cleaned up and along with that definitely reset back<rest of thread truncated>\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"T3+ 57T Bitcoin miner\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"T3+\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"S9j\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"T2 miner\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "{\n",
      "  \"hardware\": [\n",
      "    {\n",
      "      \"hardware_name\": \"T3+ 57T Bitcoin miner\",\n",
      "      \"hardware_is_owned\": true\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"T3+\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"S9j\",\n",
      "      \"hardware_is_owned\": false\n",
      "    },\n",
      "    {\n",
      "      \"hardware_name\": \"T2 miner\",\n",
      "      \"hardware_is_owned\": false\n",
      "    }\n",
      "  ]\n",
      "}\n",
      "\n",
      "\n",
      "\n",
      "processing thread id 11378\n",
      "\n",
      "Date: 2010-11\n",
      "Topic: Buffer overflow\n",
      "### Original post:\n",
      "This has happened to me every time a hash with zeros is found on my 64-bit Atom system:Code:DBG: found zeroes in <truncated> 8150287 hashes, 123.22 khash/secPROOF OF WORK FOUND? submitting... *** buffer overflow detected ***: ./minerd terminated======= Backtrace: <truncated> mentioned the problems with -march=atom CFLAGS previously, but this does not go away when changing the -march.\n",
      "\n",
      "### Reply 1:\n",
      "Fixed in git commit <truncated> just pushed to cpuminer.git.\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "model response: \n",
      "\n",
      "```json\n",
      "[\n",
      "    {\n",
      "        \"hardware_name\": \"64-bit Atom system\",\n",
      "        \"hardware_is_owned\": true\n",
      "    }\n",
      "]\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "parsed response: \n",
      "\n",
      "[\n",
      "    {\n",
      "        \"hardware_name\": \"64-bit Atom system\",\n",
      "        \"hardware_is_owned\": true\n",
      "    }\n",
      "]\n",
      "\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "\n",
    "\n",
    "# for (date, thread) in tqdm(zip(dates, threads), total=len(dates)):\n",
    "for (threadid, date, thread) in zip(indices, dates, threads):\n",
    "\n",
    "    \n",
    "    print(f\"processing thread id {threadid}\\n\\n\"+ thread + \"\\n\\n\")\n",
    "\n",
    "    prompt2 = prompt.format(thread)\n",
    "    \n",
    "\n",
    "    response = get_openai_response(prompt2)\n",
    "\n",
    "    print(\"model response: \\n\\n\"+response+\"\\n\\n\\n\")\n",
    "\n",
    "    if not response.__contains__(\"```json\"):\n",
    "        print(\"ERROR: response does not contain JSON\")\n",
    "        continue\n",
    "\n",
    "    response = response.replace(\"```json\\n\",\"\")\n",
    "    response = response.split(\"```\")[0].strip()\n",
    "\n",
    "    print(\"parsed response: \\n\\n\"+response+\"\\n\\n\\n\")\n",
    "\n",
    "    try:\n",
    "        _ = json.loads(response)\n",
    "    except:\n",
    "        print(\"ERROR: could not parse response as JSON\")\n",
    "        continue\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "    # Append the new rows to the dataset\n",
    "    input = thread\n",
    "    output = response\n",
    "    dataset = pd.concat([dataset, pd.DataFrame({'index': [threadid],'input': [input], 'output': [output]})], ignore_index=True)\n",
    "\n",
    "\n",
    "\n",
    "    dataset.to_csv(path+file_name, index=False)\n",
    "    threadid+=1\n",
    "\n",
    "    # break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>topic</th>\n",
       "      <th>post</th>\n",
       "      <th>date</th>\n",
       "      <th>dates</th>\n",
       "      <th>category</th>\n",
       "      <th>index</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[Group Buy in China]  Avalon batch #3</td>\n",
       "      <td>List of &lt;truncated&gt; Forum Name - Bitcoin Addre...</td>\n",
       "      <td>2013-03-25 11:06:33</td>\n",
       "      <td>2013-03-25 10:16:23&lt;sep&gt;2013-03-25 10:42:45&lt;se...</td>\n",
       "      <td>groupbuys</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Avalon Group buy - Germany</td>\n",
       "      <td>Hi, I'm in time to invest?&lt;sep&gt;too late, sorry</td>\n",
       "      <td>2013-03-25 13:13:44</td>\n",
       "      <td>2013-03-25 12:47:34&lt;sep&gt;2013-03-25 13:13:44</td>\n",
       "      <td>groupbuys</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Avalon Group buy - Germany - closed</td>\n",
       "      <td>I am willing to organize a community purchase ...</td>\n",
       "      <td>2013-03-25 13:14:29</td>\n",
       "      <td>2013-03-25 13:14:29</td>\n",
       "      <td>groupbuys</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>I'm about to buy Avalon asic 85</td>\n",
       "      <td>it sold out, its gone.&lt;sep&gt;People just order b...</td>\n",
       "      <td>2013-03-25 14:26:29</td>\n",
       "      <td>2013-03-25 13:46:12&lt;sep&gt;2013-03-25 14:26:29</td>\n",
       "      <td>groupbuys</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>CANCELLED [Group Buy in China]  Avalon batch #3</td>\n",
       "      <td>Do you not have enough BTC to buy a batch 3 Av...</td>\n",
       "      <td>2013-03-25 16:42:09</td>\n",
       "      <td>2013-03-25 16:42:09</td>\n",
       "      <td>groupbuys</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24184</th>\n",
       "      <td>S19 Amlogic control board brick ?</td>\n",
       "      <td>Hello everyone, I have an amlogic s19 j pro ca...</td>\n",
       "      <td>2023-10-23 15:51:19</td>\n",
       "      <td>2023-08-30 13:53:04&lt;sep&gt;2023-08-30 17:45:01&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>24184</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24185</th>\n",
       "      <td>S19jPro abnormal network - (Will not connect t...</td>\n",
       "      <td>Driving me nuts... after changing pool address...</td>\n",
       "      <td>2023-10-24 14:00:23</td>\n",
       "      <td>2023-02-24 15:37:21&lt;sep&gt;2023-02-24 15:59:12&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>24185</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24186</th>\n",
       "      <td>Flashing control Board S9 to R4</td>\n",
       "      <td>Hello,I recently purchased a control board tha...</td>\n",
       "      <td>2023-10-25 23:42:40</td>\n",
       "      <td>2023-10-05 14:14:14&lt;sep&gt;2023-10-09 05:06:58&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>24186</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24187</th>\n",
       "      <td>AvalonMiner 1166Pro-72</td>\n",
       "      <td>Hello,can someone help me find the problem wit...</td>\n",
       "      <td>2023-10-26 08:40:14</td>\n",
       "      <td>2023-10-09 07:54:00&lt;sep&gt;2023-10-09 11:50:47&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>24187</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24188</th>\n",
       "      <td>need advice to reduce noise and monitor asic m...</td>\n",
       "      <td>I think Awesomeminer supports this unit model ...</td>\n",
       "      <td>2023-10-27 16:39:20</td>\n",
       "      <td>2023-09-21 11:52:00&lt;sep&gt;2023-10-27 15:31:24&lt;se...</td>\n",
       "      <td>mining_support</td>\n",
       "      <td>24188</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>24189 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                   topic  \\\n",
       "0                  [Group Buy in China]  Avalon batch #3   \n",
       "1                             Avalon Group buy - Germany   \n",
       "2                    Avalon Group buy - Germany - closed   \n",
       "3                        I'm about to buy Avalon asic 85   \n",
       "4        CANCELLED [Group Buy in China]  Avalon batch #3   \n",
       "...                                                  ...   \n",
       "24184                  S19 Amlogic control board brick ?   \n",
       "24185  S19jPro abnormal network - (Will not connect t...   \n",
       "24186                    Flashing control Board S9 to R4   \n",
       "24187                             AvalonMiner 1166Pro-72   \n",
       "24188  need advice to reduce noise and monitor asic m...   \n",
       "\n",
       "                                                    post                 date  \\\n",
       "0      List of <truncated> Forum Name - Bitcoin Addre...  2013-03-25 11:06:33   \n",
       "1         Hi, I'm in time to invest?<sep>too late, sorry  2013-03-25 13:13:44   \n",
       "2      I am willing to organize a community purchase ...  2013-03-25 13:14:29   \n",
       "3      it sold out, its gone.<sep>People just order b...  2013-03-25 14:26:29   \n",
       "4      Do you not have enough BTC to buy a batch 3 Av...  2013-03-25 16:42:09   \n",
       "...                                                  ...                  ...   \n",
       "24184  Hello everyone, I have an amlogic s19 j pro ca...  2023-10-23 15:51:19   \n",
       "24185  Driving me nuts... after changing pool address...  2023-10-24 14:00:23   \n",
       "24186  Hello,I recently purchased a control board tha...  2023-10-25 23:42:40   \n",
       "24187  Hello,can someone help me find the problem wit...  2023-10-26 08:40:14   \n",
       "24188  I think Awesomeminer supports this unit model ...  2023-10-27 16:39:20   \n",
       "\n",
       "                                                   dates        category  \\\n",
       "0      2013-03-25 10:16:23<sep>2013-03-25 10:42:45<se...       groupbuys   \n",
       "1            2013-03-25 12:47:34<sep>2013-03-25 13:13:44       groupbuys   \n",
       "2                                    2013-03-25 13:14:29       groupbuys   \n",
       "3            2013-03-25 13:46:12<sep>2013-03-25 14:26:29       groupbuys   \n",
       "4                                    2013-03-25 16:42:09       groupbuys   \n",
       "...                                                  ...             ...   \n",
       "24184  2023-08-30 13:53:04<sep>2023-08-30 17:45:01<se...  mining_support   \n",
       "24185  2023-02-24 15:37:21<sep>2023-02-24 15:59:12<se...  mining_support   \n",
       "24186  2023-10-05 14:14:14<sep>2023-10-09 05:06:58<se...  mining_support   \n",
       "24187  2023-10-09 07:54:00<sep>2023-10-09 11:50:47<se...  mining_support   \n",
       "24188  2023-09-21 11:52:00<sep>2023-10-27 15:31:24<se...  mining_support   \n",
       "\n",
       "       index  \n",
       "0          0  \n",
       "1          1  \n",
       "2          2  \n",
       "3          3  \n",
       "4          4  \n",
       "...      ...  \n",
       "24184  24184  \n",
       "24185  24185  \n",
       "24186  24186  \n",
       "24187  24187  \n",
       "24188  24188  \n",
       "\n",
       "[24189 rows x 6 columns]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "dataset = pd.read_csv(\"cache.csv\")\n",
    "dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "prompt = \"\"\"\n",
    "User:\n",
    "In the given Bitcoin forum thread, pay close attention to the language used when mentioning hardware pieces. Look for explicit statements indicating ownership or hypothetical discussions.\n",
    "\n",
    "```thread\n",
    "{}\n",
    "```\n",
    "\n",
    "\n",
    "\n",
    "Reply with the hardware names, all in the same line, separated by commas. Then, on a new line, list \"True\" or \"False\" for each piece of hardware to indicate ownership status. True if the mention suggests concrete ownership by any user, and False if the hardware is discussed in a hypothetical or speculative way.\n",
    "\n",
    "Assistant:\n",
    "Sure! Here is the requested output, with the correct ownership status for each piece of hardware:\n",
    "Hardware names:\n",
    "\"\"\".strip()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error processing thread:2344\n",
      "Error processing thread:2907\n",
      "Error processing thread:2967\n",
      "Error processing thread:4609\n",
      "Error processing thread:5493\n",
      "Error processing thread:6543\n",
      "Error processing thread:6620\n",
      "Error processing thread:6956\n",
      "Error processing thread:7170\n",
      "Error processing thread:9152\n",
      "Error processing thread:9306\n",
      "Error processing thread:12206\n",
      "Error processing thread:13251\n",
      "Error processing thread:14915\n"
     ]
    }
   ],
   "source": [
    "# create inputs that will be given to trained model\n",
    "inputs = pd.DataFrame()\n",
    "for i in range(len(df)):\n",
    "    index, date, thread = process_thread(df.iloc[i])\n",
    "    prompt2 = prompt.format(thread)\n",
    "    inputs = pd.concat([inputs, pd.DataFrame({'input': [prompt2]})], ignore_index=True)\n",
    "\n",
    "\n",
    "inputs.to_csv(\"inputs.csv\", index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "User:\n",
      "In the given Bitcoin forum thread, pay close attention to the language used when mentioning hardware pieces. Look for explicit statements indicating ownership or hypothetical discussions.\n",
      "\n",
      "```thread\n",
      "Date: 2013-03\n",
      "Topic:  [Group Buy in China]  Avalon batch #3\n",
      "### Original post:\n",
      "List of <truncated> Forum Name - Bitcoin Address - Amount Invested\n",
      "\n",
      "### Reply 1:\n",
      "Interesting!I am in China too.I will consider this investment.\n",
      "\n",
      "### Reply 2:\n",
      "Thanks for trusting me,225BTC received! <truncated> please PM or QQ me\n",
      "\n",
      "\n",
      "```\n",
      "\n",
      "\n",
      "\n",
      "Reply with the hardware names, all in the same line, separated by commas. Then, on a new line, list \"True\" or \"False\" for each piece of hardware to indicate ownership status. True if the mention suggests concrete ownership by any user, and False if the hardware is discussed in a hypothetical or speculative way.\n",
      "\n",
      "Assistant:\n",
      "Sure! Here is the requested output, with the correct ownership status for each piece of hardware:\n",
      "Hardware names:\n"
     ]
    }
   ],
   "source": [
    "print(inputs.iloc[0].values[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>input</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>User:\\nIn the given Bitcoin forum thread, pay ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>User:\\nIn the given Bitcoin forum thread, pay ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>User:\\nIn the given Bitcoin forum thread, pay ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>User:\\nIn the given Bitcoin forum thread, pay ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>User:\\nIn the given Bitcoin forum thread, pay ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24184</th>\n",
       "      <td>User:\\nIn the given Bitcoin forum thread, pay ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24185</th>\n",
       "      <td>User:\\nIn the given Bitcoin forum thread, pay ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24186</th>\n",
       "      <td>User:\\nIn the given Bitcoin forum thread, pay ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24187</th>\n",
       "      <td>User:\\nIn the given Bitcoin forum thread, pay ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24188</th>\n",
       "      <td>User:\\nIn the given Bitcoin forum thread, pay ...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>24189 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                   input\n",
       "0      User:\\nIn the given Bitcoin forum thread, pay ...\n",
       "1      User:\\nIn the given Bitcoin forum thread, pay ...\n",
       "2      User:\\nIn the given Bitcoin forum thread, pay ...\n",
       "3      User:\\nIn the given Bitcoin forum thread, pay ...\n",
       "4      User:\\nIn the given Bitcoin forum thread, pay ...\n",
       "...                                                  ...\n",
       "24184  User:\\nIn the given Bitcoin forum thread, pay ...\n",
       "24185  User:\\nIn the given Bitcoin forum thread, pay ...\n",
       "24186  User:\\nIn the given Bitcoin forum thread, pay ...\n",
       "24187  User:\\nIn the given Bitcoin forum thread, pay ...\n",
       "24188  User:\\nIn the given Bitcoin forum thread, pay ...\n",
       "\n",
       "[24189 rows x 1 columns]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "inputs"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "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.10.13"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "ad2bdc8ecc057115af97d19610ffacc2b4e99fae6737bb82f5d7fb13d2f2c186"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}