-
Notifications
You must be signed in to change notification settings - Fork 24
/
p_init.js
11189 lines (8657 loc) · 419 KB
/
p_init.js
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
//console.log("document.URL: ", document.URL);
let s = new Date().toLocaleString();
//console.log("local time: ", s); // not really used for anything?
window.deferreds = []; // not used?
window.language_names = {}; // lookup table po pulated with data from browser
window.current_service_worker = null; // current active registration
window.clone_prefill = null;
window.audio_module_loaded = true;
window.main_audio_context = null;
window.main_audio_context_sample_rate = null;
window.mediaStream = null;
window.simple_vad = null;
window.simple_vad_source = null;
window.last_vad_recording = [];
window.last_vad_recording_length = 0;
window.simple_vad_worklet_added = false;
window.busy_recording_simple_vad = false;
window.vad_paused = false;
window.idle = true; // If no AI tasks are being executed this becomes false;
window.internet = true; // Set to false if there is no internet connection
window.skip_a_beat = false; // let the interval wait one more beat
window.task_started = 0; // counts down from 10 to 0 to add a delay to the main interval
window.page_focus_loss_counter = 0; // increases by 1 every second the page doesn't have focus. When it reached 120 seconds all AI's are unloaded
window.page_has_focus = true;
window.chat_footer_transition_threshold_height = 130; // 190
window.generate_ui_first_run = true;
window.timers_recreated = false;
window.last_time_ai_responded = {}; // data about when the last interaction occured is kept in a separate dictionary to avoid storing that information
window.only_allow_voice_commands = false;
window.last_selected_paragraph = null; // used when selecting previous/next paragraphs via voice control
window.last_selected_paragraph_text = null; // used when selecting previous/next paragraphs via voice control
window.files_loaded = false;
window.unread_messages = {};
//window.last_time_context_menu_clicked = 0; // for some reason the file manager menu keeps getting bubbled-up clicks, even though it shouldn't. Horrible hack to fix it.
window.question_text = null; // the question being asked about a document
window.question_document = null;
window.question_selection = null; // the sub-selection of the document that a question is being asked about
window.last_user_query = 'unnamed'; // used to suggest file name
window.currently_running_llm = null;
//window.current_task = null; // already in index.html
window.ai_being_edited = null; // switched to true while an AI is being modified
window.selection_hint_timeout = null;
window.do_after_command = null;
// rewrite tags are in window.settings.rewrite_tags
window.myvad = null;
window.document_tasks = [
'continue',
'rewrite',
'summarize',
'summarize_docment',
'translate',
'translate_document',
'prompt_at_line'
];
window.irrelevant_task_states = ['completed','interrupted','failed','reviewing','reviewed','hidden'];
const allowed_share_url_parameters = ['ai','prompt','custom_name','custom_description','emoji','emoji_bg','download_url','config_url','context','temperature','system_prompt','second_prompt','cache_type_k','seed','chatter','model_type','size','markdown_supported','brevity_supported','license','add_timestamps','privacy_level','voice_gender'];
window.sidebar_shrink_timer = null;
window.running_ai = [];
window.sentence_counter = 0;
window.minimum_proofread_length = 10;
window.minimum_rewrite_length = 50;
window.maximum_rewrite_length = 1500;
window.minimal_summarize_length = 300;
window.audio_to_play = []; // deprecated
window.stt_tasks_left = 0; // used by handle_task_complete
//window.stt_recordings_in_buffer = 0;
window.tts_tasks_left = 0; // used by handle_task_complete
//window.tts_sentences_in_buffer = 0;
window.doing_low_memory_tts_chat_response = false;
window.chat_messages_to_answer = 0;
window.music_to_generate = 0;
window.images_to_generate = 0;
window.images_to_process = 0;
window.blueprint_tasks_left = 0;
window.mp3_to_encode = 0;
window.rag_tasks_left = 0;
window.assistant_tasks_left = 0;
window.chat_tasks_left = 0; // used by handle_task_complete
window.audio_output_tasks_left = 0; // used by handle_task_complete
window.blueprint_tasks_left = 0;
window.play_document_tasks_left = 0;
window.should_tasks_left = 0;
window.doing_tasks_left = 0;
window.audio_files_in_buffer = 0;
window.audio_files_to_buffer = 3; // maximum to buffer before playing
window.interrupt_speaking_task_index = null; // only tasks with a bigger index are allowed to generate TTS
window.recording_to_listening_ratio = 0; // is the VAD more in listening mode (1) or in recording mode (0)? Between 0 and 1.
window.tts_counter = 0;
window.browser_tts_voices_raw = [];
window.browser_tts_voices = {};
window.tts_worker = null;
window.tts_worker_exists = false;
window.tts_worker_busy = false;
window.busy_loading_tts = false;
window.tts_worker_loaded = false;
window.easy_speech_loaded = false; // library that simplifies browser voice synth
window.translate_stt = false;
//let tts_worker_error_count = 0; // not implemented yet
window.last_time_audio_started = null;
window.last_time_scribe_started = null;
window.scribe_precise_sentences_count = 0;
//window.scribe_continuous_stt_count = null; // maybe not necessary, let vad_audio_worklet hand out an index when continuous recording
window.maximum_scribe_duration = 3600000 * 2; // 7200000
window.scribe_clock_time_elapsed_el = null;
window.scribe_clock_time_remaining_el = null;
window.scribe_clock_progress_el = null;
window.whisper_worker = null;
window.whisper_worker_busy = false;
window.whisper_loaded = false;
window.whisper_saw_exclamation_marks = false; // can indicate an issue with sample rate
window.busy_loading_whisper = false; // messy..
window.preloading_whisper = false; // also messy
window.whisper_loading = false; // messy..
window.stopped_whisper_because_of_low_memory = false;
window.last_verified_speaker = null; // e.g. "Speaker1"
window.previous_note_time = null;
window.last_subtitle_relative_end_time = 0;
window.current_scribe_voice_parent_task_id = null;
window.measured_microphone_sample_rate = null;
window.skip_first_vad_recording = true;
window.add_timestamp_options = ['None','Minutes','Minutes_elapsed','Minutes_and_minutes_elapsed','Detailed','Precise'];
window.continuous_mic_options = ['Detect_fast','Detect_slow','Detect_slower','Continuous_recording'];
window.transcription_quality_options = ['Fast','Medium','High'];
window.mp3_worker = null;
window.mp3_worker_busy = false;
window.minimum_prompt_height = 92;
window.audio_player_busy = false;
// WLLAMA
window.tokenizer = null;
window.llama_cpp_app = null;
window.llama_cpp_fresh = true;
window.llama_cpp_busy = false;
window.interrupt_wllama = false;
window.doing_llama_cpp_refresh = false;
window.llama_cpp_model_being_loaded = null;
window.llama_cpp_model_being_downloaded = null;
window.currently_loaded_llama_cpp_assistant = null;
window.currently_loaded_llama_cpp_assistant_general_name = null;
// WEB_LLM
window.web_llm_busy = false;
window.web_llm_engine = null;
window.web_llm_script_loaded = true; // script is now always loaded
window.web_llm_assistants = ['fast_mistral','fast_phi']; // holds assistant ID's of LLM models that should be handled by WebLLM. Populated by generate_ui
window.web_llm_model_being_loaded = null
window.doing_web_llm_refresh = false;
window.currently_loaded_web_llm__assistant = null;
//console.log("window.llama_cpp_busy? ", window['llama_cpp_busy']);
window.diffusion_worker = null;
window.diffusion_worker_busy = false;
window.busy_loading_diffusion_worker = false;
window.diffusion_worker_loaded = false;
// TEXT TO IMAGE
window.text_to_image_worker = null;
window.text_to_image_worker_loaded = false;
window.real_text_to_image_worker = null;
window.text_to_image_worker_busy = false;
window.busy_loading_text_to_image = false;
//window.transformers_worker = null; // not used?
//window.transformers_worker_busy = false;
window.summarize_worker = null;
window.summarize_worker_busy == false
window.translation_worker = null;
window.translation_worker_exists = false;
window.real_translation_worker = null;
window.translation_worker_busy = false;
window.musicgen_worker = null;
window.real_musicgen_worker = null;
window.musicgen_worker_busy = false;
window.musicgen_script_loaded = false;
window.musicgen_loaded = false;
window.busy_loading_musicgen = false;
window.active_destination = 'chat'; // chat, document - where LLM output can be sent
window.active_section = 'chat'; // tools, document, chat, sidebar - which UI section was last clicked on. For handling keyboard/voice previous/next commands
window.other_ai_to_switch_to = 'phi3_mini'; // when the user clicks on a 'switch to other assistant' chat message it will switch to this value
window.stt_warmup_complete = false;
//window.stt_warmed_up = false;
window.current_origin_file = null;
window.blueprint_origin_file = null;
window.busy_doing_blueprint_task = false;
window.playing_document = false;
window.update_task_viewer = true;
window.update_simple_task_list = true;
window.blueprint_counter = 0;
window.blueprint_command_counter = 0;
window.blueprint_done_counter = 0;
// CAMERA & OCR
window.camera_on = false; // whether it should be on
window.camera_streaming = false; // whether is's actually on. Camera can sometimes stop, e.g. when a laptop lid is closed, etc.
window.busy_starting_camera = false;
window.opencv_interval = null;
window.doing_ocr_scan = 0; // counts down from 5 to 0 while gathering camera frame blobs with small intervals
window.ocr_worker_busy = false;
window.ocr_scans = [];
window.continuous_ocr_scans = [];
window.continuous_ocr_enabled = false;
window.opencv_jscanify = null;
window.detecting_page_in_video = false;
window.secondary_contour_detect_delay = 0; // if jscanify failed to detect a page in the camera stream, this is set to 300, creating an additional delay before the next attempt at detection is made
var biggest_contour_x_seen = 0;
var biggest_contour_y_seen = 0;
//window.camera_width = 1280;
//window.camera_height = 720;
window.camera_width = 1920;
window.camera_height = 1080;
window.camera_ratio = null;
window.camera_crop_box = null;
window.video_stream_meta = null;
// IMAGE TO TEXT
window.image_to_text_worker_busy = false;
window.busy_loading_image_to_text = null;
window.image_to_text_worker_loaded = false;
window.continuous_image_to_text_enabled = false;
window.last_time_continuous_image_to_text_started = null;
window.last_time_continuous_image_to_text_frame_grabbed = null;
window.continuous_image_to_text_scan_counter = 0;
window.waiting_for_image_to_text = false;
window.image_to_text_worker = null;
window.real_image_to_text_worker = null;
window.image_to_text_counter = 0;
window.image_to_text_start_time = 0;
window.image_to_text_delta = 100; // initially assume it takes 100 second to do an image_to_text task
window.last_image_to_text_blob = null;
window.last_image_to_text_blob_file = null;
window.showing_camera_still = null;
window.coder_script_loaded = false;
window.rag_counter = 0;
window.rag_worker = null;
window.promise_rag_worker = null;
window.rag_worker_busy = false;
window.selected_rag_documents = {};
window.busy_doing_research = false;
window.language_detector_loaded = false;
window.translation_module_loaded = false;
window.input_language = null;
window.output_language = null;
// OLLAMA
window.ollama = null;
window.ollama_module_loaded = false;
window.ollama_busy = false;
window.ollama_model_being_loaded == null;
window.doing_ollama_refresh = false;
window.ollama_abort_controller = null;
window.ollama_online = false;
window.ollama_models = null;
window.ollama_model_settings = null;
window.currently_preloading = [];
window.max_preload_attempts = 3;
window.recovered_download_shards = {};
// PICTURE IN PICTURE
window.pip_started = false;
window.pip_canvas = null;
window.pip_canvas_context = null;
window.pip_header_canvas = null;
//window.auto_detect_input_language = true;
const translation_languages_raw = [ // for OPUS-MT
"en-cs",
"en-mul",
"en-jap",
"en-id",
"en-hu",
"en-hi",
"en-af",
"de-fr",
"de-es",
"de-en",
"en-de",
"es-en",
"en-es",
"fr-en",
"en-fr",
"af-en",
"hu-en",
"fr-ru",
"fr-ro",
"fr-es",
"es-ru",
"es-it",
"es-fr",
"es-de",
"en-xh",
"en-uk",
"en-sv",
"en-ro",
"xh-en",
"uk-ru",
"uk-en",
"ru-uk",
"ru-fr",
"ru-es",
"ro-fr",
"jap-en",
"it-es",
"it-en",
"it-fr",
"en-vi",
"en-fi",
"nl-fr",
"en-da",
"vi-en",
"th-en",
"en-ar",
"et-en",
"en-nl",
"nl-en",
"hi-en",
"fi-de",
"no-de",
"da-de",
"fr-de",
"ja-en"];
//window.gmw_languages = ["afr","ang_Latn","deu","eng","enm_Latn","frr","fry","gos","gsw","ksh","ltz","nds","nld","pdc","sco","stq","swg","yid"];
//"gmw-gmw",
/*
source language(s): afr ang_Latn deu eng enm_Latn frr fry gos gsw ksh ltz nds nld pdc sco stq swg yid
target language(s): afr ang_Latn deu eng enm_Latn frr fry gos gsw ksh ltz nds nld pdc sco stq swg yid
*/
//window.romance_languages = ["fr","fr_BE","fr_CA","fr_FR","wa","frp","oc","ca","rm","lld","fur","lij","lmo","es","es_AR","es_CL","es_CO","es_CR","es_DO","es_EC","es_ES","es_GT","es_HN","es_MX","es_NI","es_PA","es_PE","es_PR","es_SV","es_UY","es_VE","pt","pt_br","pt_BR","pt_PT","gl","lad","an","mwl","it","it_IT","co","nap","scn","vec","sc","ro","la"]
//"ROMANCE-en",
/*
source languages: fr,fr_BE,fr_CA,fr_FR,wa,frp,oc,ca,rm,lld,fur,lij,lmo,es,es_AR,es_CL,es_CO,es_CR,es_DO,es_EC,es_ES,es_GT,es_HN,es_MX,es_NI,es_PA,es_PE,es_PR,es_SV,es_UY,es_VE,pt,pt_br,pt_BR,pt_PT,gl,lad,an,mwl,it,it_IT,co,nap,scn,vec,sc,ro,la
target languages: en
*/
window.en_mul_languages = ["abk","acm","ady","afb","afh_Latn","afr","akl_Latn","aln","amh","ang_Latn","apc","ara","arg","arq","ary","arz","asm","ast","avk_Latn","awa","aze_Latn","bak","bam_Latn","bel","bel_Latn","ben","bho","bod","bos_Latn","bre","brx","brx_Latn","bul","bul_Latn","cat","ceb","ces","cha","che","chr","chv","cjy_Hans","cjy_Hant","cmn","cmn_Hans","cmn_Hant","cor","cos","crh","crh_Latn","csb_Latn","cym","dan","deu","dsb","dtp","dws_Latn","egl","ell","enm_Latn","epo","est","eus","ewe","ext","fao","fij","fin","fkv_Latn","fra","frm_Latn","frr","fry","fuc","fuv","gan","gcf_Latn","gil","gla","gle","glg","glv","gom","gos","got_Goth","grc_Grek","grn","gsw","guj","hat","hau_Latn","haw","heb","hif_Latn","hil","hin","hnj_Latn","hoc","hoc_Latn","hrv","hsb","hun","hye","iba","ibo","ido","ido_Latn","ike_Latn","ile_Latn","ilo","ina_Latn","ind","isl","ita","izh","jav","jav_Java","jbo","jbo_Cyrl","jbo_Latn","jdt_Cyrl","jpn","kab","kal","kan","kat","kaz_Cyrl","kaz_Latn","kek_Latn","kha","khm","khm_Latn","kin","kir_Cyrl","kjh","kpv","krl","ksh","kum","kur_Arab","kur_Latn","lad","lad_Latn","lao","lat_Latn","lav","ldn_Latn","lfn_Cyrl","lfn_Latn","lij","lin","lit","liv_Latn","lkt","lld_Latn","lmo","ltg","ltz","lug","lzh","lzh_Hans","mad","mah","mai","mal","mar","max_Latn","mdf","mfe","mhr","mic","min","mkd","mlg","mlt","mnw","moh","mon","mri","mwl","mww","mya","myv","nan","nau","nav","nds","niu","nld","nno","nob","nob_Hebr","nog","non_Latn","nov_Latn","npi","nya","oci","ori","orv_Cyrl","oss","ota_Arab","ota_Latn","pag","pan_Guru","pap","pau","pdc","pes","pes_Latn","pes_Thaa","pms","pnb","pol","por","ppl_Latn","prg_Latn","pus","quc","qya","qya_Latn","rap","rif_Latn","roh","rom","ron","rue","run","rus","sag","sah","san_Deva","scn","sco","sgs","shs_Latn","shy_Latn","sin","sjn_Latn","slv","sma","sme","smo","sna","snd_Arab","som","spa","sqi","srp_Cyrl","srp_Latn","stq","sun","swe","swg","swh","tah","tam","tat","tat_Arab","tat_Latn","tel","tet","tgk_Cyrl","tha","tir","tlh_Latn","tly_Latn","tmw_Latn","toi_Latn","ton","tpw_Latn","tso","tuk","tuk_Latn","tur","tvl","tyv","tzl","tzl_Latn","udm","uig_Arab","uig_Cyrl","ukr","umb","urd","uzb_Cyrl","uzb_Latn","vec","vie","vie_Hani","vol_Latn","vro","war","wln","wol","wuu","xal","xho","yid","yor","yue","yue_Hans","yue_Hant","zho","zho_Hans","zho_Hant","zlm_Latn","zsm_Latn","zul","zza"];
window.mul_en_languages = window.en_mul_languages; //["abk","acm","ady","afb","afh_Latn","afr","akl_Latn","aln","amh","ang_Latn","apc","ara","arg","arq","ary","arz","asm","ast","avk_Latn","awa","aze_Latn","bak","bam_Latn","bel","bel_Latn","ben","bho","bod","bos_Latn","bre","brx","brx_Latn","bul","bul_Latn","cat","ceb","ces","cha","che","chr","chv","cjy_Hans","cjy_Hant","cmn","cmn_Hans","cmn_Hant","cor","cos","crh","crh_Latn","csb_Latn","cym","dan","deu","dsb","dtp","dws_Latn","egl","ell","enm_Latn","epo","est","eus","ewe","ext","fao","fij","fin","fkv_Latn","fra","frm_Latn","frr","fry","fuc","fuv","gan","gcf_Latn","gil","gla","gle","glg","glv","gom","gos","got_Goth","grc_Grek","grn","gsw","guj","hat","hau_Latn","haw","heb","hif_Latn","hil","hin","hnj_Latn","hoc","hoc_Latn","hrv","hsb","hun","hye","iba","ibo","ido","ido_Latn","ike_Latn","ile_Latn","ilo","ina_Latn","ind","isl","ita","izh","jav","jav_Java","jbo","jbo_Cyrl","jbo_Latn","jdt_Cyrl","jpn","kab","kal","kan","kat","kaz_Cyrl","kaz_Latn","kek_Latn","kha","khm","khm_Latn","kin","kir_Cyrl","kjh","kpv","krl","ksh","kum","kur_Arab","kur_Latn","lad","lad_Latn","lao","lat_Latn","lav","ldn_Latn","lfn_Cyrl","lfn_Latn","lij","lin","lit","liv_Latn","lkt","lld_Latn","lmo","ltg","ltz","lug","lzh","lzh_Hans","mad","mah","mai","mal","mar","max_Latn","mdf","mfe","mhr","mic","min","mkd","mlg","mlt","mnw","moh","mon","mri","mwl","mww","mya","myv","nan","nau","nav","nds","niu","nld","nno","nob","nob_Hebr","nog","non_Latn","nov_Latn","npi","nya","oci","ori","orv_Cyrl","oss","ota_Arab","ota_Latn","pag","pan_Guru","pap","pau","pdc","pes","pes_Latn","pes_Thaa","pms","pnb","pol","por","ppl_Latn","prg_Latn","pus","quc","qya","qya_Latn","rap","rif_Latn","roh","rom","ron","rue","run","rus","sag","sah","san_Deva","scn","sco","sgs","shs_Latn","shy_Latn","sin","sjn_Latn","slv","sma","sme","smo","sna","snd_Arab","som","spa","sqi","srp_Cyrl","srp_Latn","stq","sun","swe","swg","swh","tah","tam","tat","tat_Arab","tat_Latn","tel","tet","tgk_Cyrl","tha","tir","tlh_Latn","tly_Latn","tmw_Latn","toi_Latn","ton","tpw_Latn","tso","tuk","tuk_Latn","tur","tvl","tyv","tzl","tzl_Latn","udm","uig_Arab","uig_Cyrl","ukr","umb","urd","uzb_Cyrl","uzb_Latn","vec","vie","vie_Hani","vol_Latn","vro","war","wln","wol","wuu","xal","xho","yid","yor","yue","yue_Hans","yue_Hant","zho","zho_Hans","zho_Hant","zlm_Latn","zsm_Latn","zul","zza"];
// Some models use 2-letter language codes, some use 3-letter ones. This is used to standardise on 2-letter codes.
window.language_codes_lookup = {
"afr":"af",
"ang_Latn":"ang_Latn", // Old english
"deu":"de",
"eng":"en",
"enm_Latn":"enm_Latn", // middle English
"frr":"frr", // noord-frys
"fry":"fry", // frys
"gos":"gos", // gronings
"gsw":"gsw", // swiss-german
"ksh":"ksh", // Kölsch
"ltz":"lb", // Luxembourgish
"nds":"nds", // low-german, Low German, Low Saxon, (niedersaxisch?)
"nld":"nl", // Dutch, Flemish
"pdc":"pdc", // Pennsylvania German
"sco":"sco", // Scots
"stq":"stq", // Saterfriesisch
"swg":"swg", // Swabian
"yid":"yi", // Yiddisch
"ukr":"uk", // Ukranian
}
window.translation_languages = {};
/*
// Add GMW West Germanic languages first
for(let gl = 0; gl < gmw_languages.length; gl++){
let lang_code = gmw_languages[gl];
if(typeof window.language_codes_lookup[lang_code] == 'string'){
lang_code = window.language_codes_lookup[lang_code];
}
if(typeof window.translation_languages[lang_code] == 'undefined'){
window.translation_languages[lang_code] = {};
}
for(let gl2 = 0; gl2 < gmw_languages.length; gl2++){
let lang_code2 = gmw_languages[gl2];
if(typeof window.language_codes_lookup[lang_code2] == 'string'){
lang_code2 = window.language_codes_lookup[lang_code2];
}
if(lang_code == lang_code2){continue}
window.translation_languages[ lang_code ][ lang_code2 ] = {
'language':lang_code2,
'runner':'transformers',
//'model_base':'opus-mt',
'model':'opus-mt-gmw-gmw'
}
}
}
console.log("window.translation_languages after adding west-germanic languages: ", keyz(window.translation_languages).length, window.translation_languages);
*/
for(let tl = 0; tl < translation_languages_raw.length; tl++){
let translation_parts = translation_languages_raw[tl].split('-');
//console.log("translation_parts: ", translation_parts);
if(translation_parts.length == 2){
if(typeof translation_parts[0] == 'string' && typeof translation_parts[1] == 'string'){
if(typeof window.translation_languages[translation_parts[0]] == 'undefined'){
//console.log("creating empty translation array for: ", translation_parts[0])
window.translation_languages[translation_parts[0]] = {};
}
//console.log("adding translation output_language: ", translation_parts[0], " -+-> ", translation_parts[1])
/*
if(typeof window.translation_languages[ translation_parts[0] ][ translation_parts[1] ] == 'undefined'){
window.translation_languages[ translation_parts[0] ][ translation_parts[1] ] = {
'language':translation_parts[1],
'runner':'transformers',
//'model_base':'opus-mt',
'model':'opus-mt-' + translation_languages_raw[tl]
}
}
else{
console.warn("window.translation_languages: skipping add a specialised translation model because it was already provided by the GMW model: ", translation_languages_raw[tl]);
}
*/
// this overrides WGM with: en-af, af-en, en-nl
if(translation_parts[0] == translation_parts[1]){
continue
}
window.translation_languages[ translation_parts[0] ][ translation_parts[1] ] = {
'language':translation_parts[1],
'runner':'transformers',
//'model_base':'Xenova/opus-mt', // model base isn't reallty used for anything
'model':'Xenova/opus-mt-' + translation_languages_raw[tl]
}
}
}
}
//console.log("window.translation_languages after adding specialized language models: ", keyz(window.translation_languages).length, window.translation_languages);
/*
for(let rl = 0; rl < window.romance_languages.length; rl++){
let lang_code = window.romance_languages[rl];
if(lang_code.indexOf('_') != -1){
lang_code = lang_code.split('_')[1].toLowerCase();
}
if(typeof window.language_codes_lookup[lang_code] == 'string'){
lang_code = window.language_codes_lookup[lang_code];
}
if(lang_code != 'en' && typeof window.translation_languages[lang_code] == 'undefined'){
window.translation_languages[lang_code] = {"en":{
'language':"en",
'runner':'transformers',
//'model_base':'opus-mt',
'model':'opus-mt-ROMANCE-en'
}};
}
}
console.log("window.translation_languages after adding Romance languages: ", keyz(window.translation_languages).length, window.translation_languages);
*/
for(let rl = 0; rl < window.mul_en_languages.length; rl++){
let lang_code = window.mul_en_languages[rl];
if(lang_code.endsWith('Latn')){
//console.log("adding translation language: mul_en: spotted _Latn language, skipping: ", lang_code);
continue
}
if(lang_code.indexOf('_') != -1){
lang_code = lang_code.split('_')[1].toLowerCase();
}
if(typeof window.language_codes_lookup[lang_code] == 'string'){
lang_code = window.language_codes_lookup[lang_code];
}
if(lang_code != 'en' && typeof window.translation_languages[lang_code] == 'undefined'){
window.translation_languages[lang_code] = {"en":{
'language':"en",
'runner':'transformers',
//'model_base':'opus-mt',
'model':'Xenova/opus-mt-mul-en'
}};
}
}
//console.log("FINAL window.translation_languages after adding Mul-En languages: ", keyz(window.translation_languages).length, window.translation_languages);
for(let rl = 0; rl < window.en_mul_languages.length; rl++){
let lang_code = window.en_mul_languages[rl];
if(lang_code.endsWith('Latn')){
//console.log("adding translation language: en-mul: spotted _Latn language, skipping: ", lang_code);
continue
}
if(typeof window.language_codes_lookup[lang_code] == 'string'){
lang_code = window.language_codes_lookup[lang_code];
}
if(lang_code != 'en' && typeof window.translation_languages['en'][lang_code] == 'undefined'){
window.translation_languages['en'][lang_code] = {
'language':lang_code,
'runner':'transformers',
//'model_base':'opus-mt',
'model':'Xenova/opus-mt-en-mul'
};
}
}
// Xenova/mbart-large-50-many-to-many-mmt
window.bart_languages = ['ar', 'cs', 'de', 'en', 'es', 'et', 'fi', 'fr', 'gu', 'hi', 'it', 'ja', 'kk', 'ko', 'lt', 'lv', 'my', 'ne', 'nl', 'ro', 'ru', 'si', 'tr', 'vi', 'zh'];
/*
const raw_bart_languages = 'ar_AR,cs_CZ,de_DE,en_XX,es_XX,et_EE,fi_FI,fr_XX,gu_IN,hi_IN,it_IT,ja_XX,kk_KZ,ko_KR,lt_LT,lv_LV,my_MM,ne_NP,nl_XX,ro_RO,ru_RU,si_LK,tr_TR,vi_VN,zh_CN'
let bart_lookup = {};
let raw_bart_array = raw_bart_languages.split(',');
for(let barti = 0; barti < raw_bart_array.length; barti++){
let short_code = raw_bart_array[barti].split('_')[0];
bart_lookup[short_code] = raw_bart_array[barti];
window.bart_languages.push( short_code );
}
console.log("bart_lookup: ", bart_lookup);
console.log("bart_languages: ", bart_languages);
*/
for(let inputi = 0; inputi < window.bart_languages.length; inputi++){
let lang_code = window.bart_languages[inputi];
if(typeof window.translation_languages[lang_code] == 'undefined'){
window.translation_languages[lang_code] = {};
}
for(let outputi = 0; outputi < window.bart_languages.length; outputi++){
let output_code = window.bart_languages[outputi];
if(typeof window.translation_languages[lang_code][output_code] == 'undefined' && lang_code != output_code){
window.translation_languages[lang_code][output_code] = {
'language':output_code,
'runner':'transformers',
//'model_base':'mbart-large-50',
'model':'Xenova/mbart-large-50-many-to-many-mmt'
};
}
}
}
// facebook/m2m100_418M
// ss = Swati
// ba = Bashkir
// ff = Fulah
// jap
window.m2m_languages = ['af', 'am', 'ar', 'ast', 'az', 'ba', 'be', 'bg', 'bn', 'br', 'bs', 'ca', 'ceb', 'cs', 'cy', 'da', 'de', 'el', 'en', 'es', 'et', 'fa', 'ff', 'fi', 'fr', 'fy', 'ga', 'gd', 'gl', 'gu', 'ha', 'he', 'hi', 'hr', 'ht', 'hu', 'hy', 'id', 'ig', 'ilo', 'is', 'it', 'ja', 'jv', 'ka', 'kk', 'km', 'kn', 'ko', 'lb', 'lg', 'ln', 'lo', 'lt', 'lv', 'mg', 'mk', 'ml', 'mn', 'mr', 'ms', 'my', 'ne', 'nl', 'no', 'ns', 'or', 'oc', 'pa', 'pl', 'ps', 'pt', 'ro', 'ru', 'sd', 'si', 'sk', 'sl', 'so', 'sq', 'sr', 'ss', 'su', 'sv', 'sw', 'ta', 'th', 'tl', 'tn', 'tr', 'uk', 'ur', 'uz', 'vi', 'wo', 'xh', 'yi', 'yo', 'zh', 'zu'];
//const raw_m2m_languages = 'Afrikaans (af), Amharic (am), Arabic (ar), Asturian (ast), Azerbaijani (az), Bashkir (ba), Belarusian (be), Bulgarian (bg), Bengali (bn), Breton (br), Bosnian (bs), Catalan; Valencian (ca), Cebuano (ceb), Czech (cs), Welsh (cy), Danish (da), German (de), Greeek (el), English (en), Spanish (es), Estonian (et), Persian (fa), Fulah (ff), Finnish (fi), French (fr), Western Frisian (fy), Irish (ga), Gaelic; Scottish Gaelic (gd), Galician (gl), Gujarati (gu), Hausa (ha), Hebrew (he), Hindi (hi), Croatian (hr), Haitian; Haitian Creole (ht), Hungarian (hu), Armenian (hy), Indonesian (id), Igbo (ig), Iloko (ilo), Icelandic (is), Italian (it), Japanese (ja), Javanese (jv), Georgian (ka), Kazakh (kk), Central Khmer (km), Kannada (kn), Korean (ko), Luxembourgish; Letzeburgesch (lb), Ganda (lg), Lingala (ln), Lao (lo), Lithuanian (lt), Latvian (lv), Malagasy (mg), Macedonian (mk), Malayalam (ml), Mongolian (mn), Marathi (mr), Malay (ms), Burmese (my), Nepali (ne), Dutch; Flemish (nl), Norwegian (no), Northern Sotho (ns), Occitan (post 1500) (oc), Oriya (or), Panjabi; Punjabi (pa), Polish (pl), Pushto; Pashto (ps), Portuguese (pt), Romanian; Moldavian; Moldovan (ro), Russian (ru), Sindhi (sd), Sinhala; Sinhalese (si), Slovak (sk), Slovenian (sl), Somali (so), Albanian (sq), Serbian (sr), Swati (ss), Sundanese (su), Swedish (sv), Swahili (sw), Tamil (ta), Thai (th), Tagalog (tl), Tswana (tn), Turkish (tr), Ukrainian (uk), Urdu (ur), Uzbek (uz), Vietnamese (vi), Wolof (wo), Xhosa (xh), Yiddish (yi), Yoruba (yo), Chinese (zh), Zulu (zu)'
//let raw_m2m_array = raw_m2m_languages.split('), ');
//for(let mimi = 0; mimi < raw_m2m_array.length; mimi++){
// window.m2m_languages.push( raw_m2m_array[mimi].split('(')[1] )
//}
//console.log("window.m2m_languages: ", window.m2m_languages);
for(let inputi = 0; inputi < window.m2m_languages.length; inputi++){
let lang_code = window.m2m_languages[inputi];
if(lang_code == 'jap'){
lang_code = 'jp';
}
if(typeof window.translation_languages[lang_code] == 'undefined'){
window.translation_languages[lang_code] = {};
}
for(let outputi = 0; outputi < window.m2m_languages.length; outputi++){
let output_code = window.m2m_languages[outputi];
if(output_code == 'jap'){
output_code = 'jp';
}
if(typeof window.translation_languages[lang_code][output_code] == 'undefined' && lang_code != output_code){
window.translation_languages[lang_code][output_code] = {
'language':output_code,
'runner':'transformers',
//'model_base':'m2m100',
'model':'Xenova/m2m100_418M'
};
}
}
}
//console.log("FINAL window.translation_languages after adding Mul-En languages: ", keyz(window.translation_languages).length, window.translation_languages);
//console.log("FINAL window.translation_languages: ", keyz(window.translation_languages).length, window.translation_languages);
window.last_user_activity_time = Date.now();
let start_time = Math.floor(Date.now()/1000);
//console.log("start_time: ", start_time);
let current_time = start_time;
let previous_time = start_time;
let start_time_delta = 0;
let intro_time = 0;
let busy_selecting_assistants = false;
window.assistant_switches_made_count = 0;
//window.assistants_loading_count = 0;
//window.assistants_loaded_count = 0;
window.intro_explanations_given = {};
let developer_input_hidden = false; // part of easter egg of talking to developer
// not really used outside the tts_worker?
window.voice_to_file_lookup = {
'US female 1':'cmu_us_slt_arctic-wav-arctic_a0001',
'US female 2':'cmu_us_clb_arctic-wav-arctic_a0001',
'US male 1':'cmu_us_bdl_arctic-wav-arctic_a0003',
'US male 2':'cmu_us_rms_arctic-wav-arctic_a0003',
'Canadian male':'cmu_us_jmk_arctic-wav-arctic_a0002',
'Scottish male':'cmu_us_awb_arctic-wav-arctic_b0002',
'Indian male':'cmu_us_ksp_arctic-wav-arctic_a0007',
}
// SIDEBAR
// open-sidebar-button and close-sidebar-button are handled in playground's ui.js with open_sidebar() and close_siebar()
const sidebar_filter_input_el = document.getElementById('sidebar-filter-input');
// LEFT SIDEBAR FILE MANAGER TAB
const download_all_files_button_el = document.getElementById('download-all-files-button');
const sidebar_rag_select_all_button_el = document.getElementById('sidebar-rag-select-all-button');
const sidebar_rag_close_button_el = document.getElementById('sidebar-rag-close-button');
//const toggle_rag_search_button_el = document.getElementById('toggle-rag-search-button');
window.rag_search_prompt_el = document.getElementById('rag-search-prompt');
const start_rag_search_button_el = document.getElementById('start-rag-search-button');
const rag_info_container_el = document.getElementById('rag-info-container');
const file_manager_files_list_el = document.getElementById('file-manager-files-list');
const upload_file_input_el = document.getElementById('upload-file-input');
const file_upload_progress_container_el = document.getElementById('file-upload-progress-container');
// ASSISTANTS SIDEBAR
const contacts_list_el = document.getElementById('contacts-list');
const select_assistants_hint_container_el = document.getElementById('add-assistants-hint-container');
const add_custom_assistant_button_el = document.getElementById('add-custom-assistant-button');
const select_assistants_button_el = document.getElementById('select-assistants-button');
// SETTINGS SIDEBAR
const running_tasks_list_el = document.getElementById('running-tasks-list-container');
const simple_tasks_list_el = document.getElementById('simple-tasks-list-container');
const setting_language_dropdown_el = document.getElementById('settings-tab-language-dropdown');
const setting_brightness_dropdown_el = document.getElementById('settings-brightness-select');
const speaker_voice_select_el = document.getElementById('speaker-voice-select');
const interrupt_speaking_select_el = document.getElementById('interrupt-speaking-select');
const enable_notifications_checkbox_el = document.getElementById('enable-notifications-checkbox');
const show_models_list_button_el = document.getElementById('show-models-list-button');
const total_disk_space_used_el = document.getElementById('total-disk-space-used');
const clear_site_cache_button_el = document.querySelector("#clear-site-cache-button");
const clear_local_storage_button_el = document.querySelector("#clear-local-storage-button");
//const clear_cache_button_el = document.querySelector("#clear-cache-button");
const clear_data_button_el = document.querySelector("#clear-data-button");
const clear_everything_button_el = document.querySelector("#clear-everything-button");
// TASKS SIDEBAR
const used_memory_el = document.getElementById('used-memory');
// CHAT
// CHAT HEADER
const back_button_container_el = document.getElementById('back-button-container');
const chat_header_icon_container_el = document.getElementById('chat-header-icon-container');
const chat_header_icon_el = document.getElementById('chat-header-icon');
const chat_header_emoji_icon_container_el = document.getElementById('chat-header-emoji-icon-container');
const chat_header_name_el = document.getElementById('chat-header-name');
const shrink_assistant_button_el = document.getElementById('shrink-assistant-button');
const mobile_back_to_document_button_el = document.getElementById('mobile-back-to-document-button');
const stop_assistant_icon_button_el = document.getElementById('stop-assistant-button-assistant-icon-container');
const stop_assistant_button_el = document.getElementById('stop-assistant-button');
const stop_assistant_button_assistant_icon_el = document.getElementById('stop-assistant-button-assistant-icon');
const clear_assistant_button_el = document.getElementById('clear-assistant-button');
// CHAT CONTENT
const chat_content_el = document.getElementById('chat-content');
const message_downloads_container_el = document.getElementById('message-downloads-container');
const message_container_el = document.getElementById('message-content-container');
// CHAT MODEL INFO
const model_info_container_el = document.getElementById('model-info-container');
const model_info_close_button_el = document.getElementById('model-info-close-button');
// CHAT FOOTER
const musicgen_duration_slider_el = document.getElementById('musicgen-duration-slider');
const musicgen_duration_output_el = document.getElementById('musicgen-duration-output');
const speaker_voice_buttons_background_ball_pusher = document.getElementById('speaker-voice-buttons-background-ball-pusher');
const settings_complexity_select_el = document.getElementById('settings-complexity-select');
const message_form_container_el = document.getElementById('message-form-container');
const message_form_resize_handle_el = document.getElementById('message-form-resize-handle');
const microphone_icon_el = document.getElementById("microphone-icon");
const microphone_meta_hint_el = document.getElementById('microphone-meta-hint');
const microphone_tasks_counter_container_el = document.getElementById('microphone-tasks-counter-container');
const speaker_icon_el = document.getElementById("speaker-icon");
const speaker_tasks_counter_container_el = document.getElementById('speaker-tasks-counter-container');
const chat_prompt_textarea_eraser_el = document.querySelector("#chat-prompt-textarea-eraser");
const textareaPrompt = document.querySelector("textarea#prompt"); // double
const prompt_el = document.getElementById('prompt');
const negative_prompt_el = document.getElementById('negative-prompt');
const document_chat_upload_input_el = document.querySelector("#document-chat-upload-input");
const submit_prompt_button_el = document.querySelector("#submit-prompt-button");
const submit_prompt_at_line_button_el = document.querySelector("#submit-prompt-at-line-button");
//const submit_question_button_el = document.querySelector("#submit-question-button");
const question_prompt_document_title_el = document.querySelector("#question-prompt-document-title");
const question_prompt_textarea_el = document.querySelector("#question-prompt-textarea");
const question_prompt_clear_button_el = document.querySelector("#question-prompt-clear-button");
const prompt_adjustments_el = document.getElementById('prompt-adjustments');
// TOOLS
const tools_el = document.getElementById('tools');
const close_tools_button_el = document.getElementById('close-tools-button');
// PROMPT AT LINE
const prompt_at_line_dialog_el = document.getElementById('prompt-at-line-dialog');
const prompt_at_line_submit_button_el = document.getElementById('prompt-at-line-submit-button');
window.prompt_at_line_input_el = document.getElementById('prompt-at-line-input');
// PROOFREAD
const proofread_details_el = document.getElementById('proofread-details');
window.proofread_prompt_el = document.getElementById('proofread-prompt');
window.proofread_dialog_content_toggles_container_el = document.getElementById('proofread-dialog-content-toggles-container');
window.proofread_dialog_content_tags_container_el = document.getElementById('proofread-dialog-content-tags-container');
const proofread_auto_detect_language_input_el = document.getElementById("proofread-auto-detect-language-input");
const proofread_auto_detected_language_el = document.getElementById('proofread-auto-detected-language');
//const dialog_proofread_submit_prompt_button_el = document.getElementById('dialog-proofread-submit-prompt-button');
// REWRITE DIALOGS
const rewrite_results_dialog_el = document.getElementById('rewrite-results-dialog');
const close_rewrite_dialog_button_el = document.getElementById('close-rewrite-dialog-button');
// SUMMARIZE
const summarize_details_el = document.getElementById('summarize-details');
window.summarize_prompt_el = document.getElementById('summarize-prompt');
window.summarize_dialog_content_toggles_container_el = document.getElementById('summarize-dialog-content-toggles-container');
window.summarize_dialog_content_tags_container_el = document.getElementById('summarize-dialog-content-tags-container');
const summarize_new_file_name_input_el = document.getElementById("summarize-new-file-name-input");
const summarize_save_as_new_file_button_el = document.getElementById("summarize-save-as-new-file-button");
const summarize_new_file_container_close_button_el = document.getElementById("summarize-new-file-container-close-button");
// REWRITE
const rewrite_details_el = document.getElementById('rewrite-details');
const rewrite_dialog_el = document.getElementById("rewrite-dialog");
const rewrite_dialog_selected_text_el = document.getElementById("rewrite-dialog-selected-text");
window.rewrite_dialog_selected_text_el = rewrite_dialog_selected_text_el;
window.rewrite_prompt_el = document.getElementById('rewrite-prompt');
//const rewrite_results_container_el = document.getElementById('rewrite-results-dialog-creations-container');
const rewrite_results_dialog_content_container_el = document.getElementById('rewrite-results-dialog-content-container');
//const rewrite_results_dialog_original_text_el = document.getElementById('rewrite-results-dialog-original-text');
window.rewrite_dialog_content_toggles_container_el = document.getElementById('rewrite-dialog-content-toggles-container');
window.rewrite_dialog_content_tags_container_el = document.getElementById('rewrite-dialog-content-tags-container');
const rewrite_status_progress_container_el = document.getElementById('rewrite-status-progress-container'); // not reallt used anymore?
const rewrite_status_progress_el = document.getElementById('rewrite-status-progress');
// TRANSLATION
const translation_details_el = document.getElementById('translation-details');
const translation_input_language_select_el = document.getElementById("translation-input-language-select");
const translation_output_language_select_el = document.getElementById("translation-output-language-select");
const translation_auto_detect_language_input_el = document.getElementById("translation-auto-detect-language-input");
const translation_flip_languages_button_el = document.getElementById("translation-flip-languages-button");
const live_translation_output_container_el = document.getElementById("live-translation-output-container");
const translation_auto_detected_language_el = document.getElementById('translation-auto-detected-language');
const translation_new_file_name_input_el = document.getElementById("translation-new-file-name-input");
const translation_save_as_new_file_button_el = document.getElementById("translation-save-as-new-file-button");
const translation_new_file_container_close_button_el = document.getElementById("translation-new-file-container-close-button");
//const load_text_ai_hint_el = document.getElementById("load-text-ai-hint");
const load_a_text_based_ai_button_el = document.getElementById("load-a-text-based-ai-button");
const tools_submit_form_container_el = document.getElementById('tools-submit-form-container');
// CAMERA
const start_ocr_button_el = document.getElementById("start-ocr-button");
const stop_camera_button_el = document.getElementById("stop-camera-button");
const camera_container_el = document.getElementById("camera-container");
const video_el = document.getElementById("camera-video");
//const camera_video_flasher_el = document.getElementById("camera-video-flasher");
const video_canvas_el = document.getElementById("video-canvas");
const video_context = video_canvas_el.getContext('2d', { willReadFrequently: true });
const camera_overlay_canvas_el = document.getElementById("camera-overlay-canvas");
const camera_overlay_context = camera_overlay_canvas_el.getContext('2d', { willReadFrequently: false });
const camera_overlay_svg_container_el = document.getElementById("camera-overlay-svg-container");
const camera_overlay_scan_hint_container_el = document.getElementById("camera-overlay-scan-hint-container");
// OCR
const camera_do_ocr_summary_button_el = document.getElementById("camera-do-ocr-summary-button");
const camera_do_ocr_details_el = document.getElementById("camera-do-ocr-details");
const scan_hands_free_hint_el = document.getElementById('live-ocr-scans-say-scan-hint');
const live_ocr_scans_container_el = document.getElementById("live-ocr-scans-container");
const live_ocr_output_el = document.getElementById("live-ocr-output");
const camera_ocr_scan_button_el = document.getElementById("camera-ocr-scan-button");
const camera_ocr_improve_button_el = document.getElementById("camera-ocr-improve-button");
const camera_ocr_scan_progress_el = document.getElementById("camera-ocr-scan-progress");
const camera_ocr_insert_button_el = document.getElementById('camera-ocr-insert-button');
const camera_ocr_new_document_button_el = document.getElementById("camera-ocr-new-document-button");
const doing_ocr_scan_counter_el = document.getElementById("doing-ocr-scan-counter");
const camera_ocr_scan_intensity_input_el = document.getElementById('camera-ocr-scan-intensity-input');
const camera_ocr_auto_scan_input_el = document.getElementById("camera-ocr-auto-scan-input");
const camera_ocr_save_auto_scan_input_el = document.getElementById("camera-ocr-save-scan-input");
// IMAGE TO TEXT
const camera_image_to_text_summary_button_el = document.getElementById("camera-image_to_text-summary-button");
const camera_image_to_text_details_el = document.getElementById("camera-image-to-text-details");
const live_image_to_text_scans_container_el = document.getElementById("live-image_to_text-scans-container");
const live_image_to_text_thumbnail_container = document.getElementById('live-image_to_text-thumbnail-container');
window.live_image_to_text_prompt_el = document.getElementById("live-image_to_text-prompt");
const live_image_to_text_output_el = document.getElementById("live-image_to_text-output");
//const camera_image_to_text_scan_button_el = document.getElementById("camera-image_to_text-scan-button");
const camera_image_to_text_describe_button_el = document.getElementById("camera-image_to_text-describe-button");
//const camera_image_to_text_improve_button_el = document.getElementById("camera-image_to_text-improve-button");
const camera_image_to_text_scan_progress_el = document.getElementById("camera-image_to_text-scan-progress");
const camera_image_to_text_insert_button_el = document.getElementById('camera-image_to_text-insert-button');
const camera_image_to_text_new_document_button_el = document.getElementById("camera-image_to_text-new-document-button");
//const doing_image_to_text_scan_counter_el = document.getElementById("doing-image_to_text-scan-counter");
const camera_image_to_text_auto_scan_input_el = document.getElementById("camera-image_to_text-auto-scan-input");
const camera_image_to_text_save_auto_scan_input_el = document.getElementById("camera-image_to_text-save-auto-scan-input");
const image_to_text_prompt_image_el = document.getElementById("image-to-text-prompt-image");
const image_to_text_prompt_camera_button_el = document.getElementById("image-to-text-prompt-settings-take-camera-picture-button");
const image_to_text_upload_input_el = document.getElementById("image-to-text-upload-input");
// CAMERA LIVE TRANSLATION
const live_translation_output_el = document.getElementById("live-translation-output");
const live_translation_insert_button_el = document.getElementById('live-translation-insert-button');
const live_translation_new_document_button_el = document.getElementById("live-translation-new-document-button");
// TUTORIAL
const tutorial_el = document.getElementById("tutorial");
/*
const chat_functionalities_list_el = document.getElementById("chat-functionalities-list");
const document_functionalities_list_el = document.getElementById("document-functionalities-list");
const media_functionalities_list_el = document.getElementById("chat-functionalities-list");