File size: 29,208 Bytes
130b487
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import os
import glob
import re
import base64
import pytz
import time
import streamlit.components.v1 as components

from urllib.parse import quote
from gradio_client import Client
from datetime import datetime

# ๐ŸŒณ๐Ÿค– AIKnowledgeTreeBuilder - Because every app needs a good costume!

Site_Name = 'AI Knowledge Tree Builder ๐Ÿ“ˆ๐ŸŒฟ Grow Smarter with Every Click'
title = "๐ŸŒณโœจAI Knowledge Tree Builder๐Ÿ› ๏ธ๐Ÿค“"
helpURL = 'https://huggingface.co/spaces/awacke1/AIKnowledgeTreeBuilder/'
bugURL = 'https://huggingface.co/spaces/awacke1/AIKnowledgeTreeBuilder/'
icons = '๐ŸŒณโœจ๐Ÿ› ๏ธ๐Ÿค“'

SidebarOutline="""
๐ŸŒณ๐Ÿค– AIKnowledgeTreeBuilder is designed with the following tenets:
1.๐Ÿ“ฑ **Portability** - Universal access via any device & link sharing
2.โšก **Speed of Build** - Rapid deployments (< 2min to production)
3.๐Ÿ”— **Linkiness** - Programmatic access to major AI knowledge sources
4.๐ŸŽฏ **Abstractive** - Core stays lean by isolating high-maintenance components
5.๐Ÿง  **Memory** - Shareable flows with deep-linked research paths
6.๐Ÿ‘ค **Personalized** - Rapidly adapts knowledge base to user needs
7.๐Ÿฆ **Living Brevity** - Easily cloneable, self modifies with data and public to shares results.
"""

st.set_page_config(
    page_title=title,
    page_icon=icons,
    layout="wide",
    initial_sidebar_state="auto",
    menu_items={
        'Get Help': helpURL,
        'Report a bug': bugURL,
        'About': title
    }
)

st.sidebar.markdown(SidebarOutline)


# Initialize session state variables
if 'selected_file' not in st.session_state:
    st.session_state.selected_file = None
if 'view_mode' not in st.session_state:
    st.session_state.view_mode = 'view'
if 'files' not in st.session_state:
    st.session_state.files = []


BiologyAndLevel36MagicUsers="""
0. Biology Core Rules and Future Exceptions
1. Central Dogma DNA RNA Protein
- Current CRISPR RNA editing ๐Ÿงช
- Research Gene therapy siRNA ๐Ÿ”ฌ
- Future Programmable genetics ๐Ÿš€

2. Cell Origin
- Current iPSCs organoids ๐Ÿฆ 
- Research Synthetic cells ๐Ÿ”ฌ
- Future De novo cell creation ๐Ÿš€

3. Form Function
- Current Bioprinting ๐Ÿซ€
- Research 4D printing ๐Ÿ”ฌ
- Future Self assembling structures ๐Ÿš€

4. Homeostasis
- Current Artificial pancreas ๐Ÿค–
- Research Nanorobots ๐Ÿ”ฌ
- Future Autonomous regulation ๐Ÿš€

5. Evolution
- Current Directed evolution ๐Ÿงซ
- Research Synthetic biology ๐Ÿ”ฌ
- Future Accelerated adaptation ๐Ÿš€

6. Energy Conservation
- Current Biofuel cells โšก
- Research Quantum biology ๐Ÿ”ฌ
- Future Biological perpetual motion ๐Ÿš€

7. Cellular Life
- Current Organoid systems ๐Ÿ”ฎ
- Research Hybrid cells ๐Ÿ”ฌ
- Future Silicon based life ๐Ÿš€

8. Inheritance Patterns
- Current Gene drives ๐Ÿงฉ
- Research Epigenetic control ๐Ÿ”ฌ
- Future Designed inheritance ๐Ÿš€

9. Energy Requirements
- Current Metabolic engineering ๐Ÿ”‹
- Research Synthetic photosynthesis ๐Ÿ”ฌ
- Future Zero energy life ๐Ÿš€

10. Random Mutation
- Current Base editing ๐ŸŽฏ
- Research Mutation prediction ๐Ÿ”ฌ
- Future Controlled evolution ๐Ÿš€

11. Carbon Based Life
- Current Alternative biochemistry ๐Ÿ’Ž
- Research Silicon biology ๐Ÿ”ฌ
- Future Non carbon life ๐Ÿš€

12. Size Limitations
- Current Nanostructures ๐Ÿ“
- Research Quantum biology ๐Ÿ”ฌ
- Future Scalable organisms ๐Ÿš€

13. Species Interdependence
- Current Synthetic ecosystems ๐ŸŒฟ
- Research Artificial symbiosis ๐Ÿ”ฌ
- Future Independent life ๐Ÿš€

14. Stimulus Response
- Current Brain computer interfaces ๐Ÿง 
- Research Neural engineering ๐Ÿ”ฌ
- Future Direct consciousness control ๐Ÿš€

15. Development Complexity
- Current Accelerated growth ๐ŸŒฑ
- Research Development control ๐Ÿ”ฌ
- Future Instant maturation ๐Ÿš€

16. Population Growth
- Current Population control ๐Ÿ“Š
- Research Sustainable ecosystems ๐Ÿ”ฌ
- Future Perfect equilibrium ๐Ÿš€

17. Energy Flow
- Current Enhanced photosynthesis ๐ŸŒž
- Research Energy optimization ๐Ÿ”ฌ
- Future Perpetual systems ๐Ÿš€

18. Environmental Adaptation
- Current Climate resistance ๐ŸŒ
- Research Universal adaptation ๐Ÿ”ฌ
- Future Environment independence ๐Ÿš€

19. Genetic Inheritance
- Current Gene editing ๐Ÿงฌ
- Research Trait programming ๐Ÿ”ฌ
- Future Perfect inheritance ๐Ÿš€

20. Reproduction
- Current Artificial wombs ๐Ÿ‘ถ
- Research Cloning advances ๐Ÿ”ฌ
- Future Asexual human reproduction ๐Ÿš€

21. Aging Death
- Current Longevity therapy โฐ
- Research Age reversal ๐Ÿ”ฌ
- Future Biological immortality ๐Ÿš€
"""

AITopicsToInnovate1="""
1. Major AI Industry Players ๐ŸŒ
   1. Research Leaders ๐ŸŽฏ
      - OpenAI: GPT-4 DALL-E Foundation Models ๐Ÿ”ต
      - Google: PaLM Gemini LLMs ๐ŸŸฆ
      - Anthropic: Claude Constitutional AI โšก
      - Meta: LLaMA Open Source LLMs ๐Ÿ‘ค
      - xAI: Grok Conversational AI ๐Ÿค–
   
2. Technical AI Development ๐Ÿ› ๏ธ
   1. Architecture Advances ๐Ÿ’ซ
      - Transformer Models Attention Mechanisms ๐Ÿง 
      - Mixture of Experts MoE Architecture ๐ŸŽช
      - Sparse Neural Networks ๐Ÿ•ธ๏ธ
      - Multi-modal LLM Systems ๐ŸŒˆ
      - Flash Attention Optimization โš”๏ธ
   
   2. Training Methodologies ๐Ÿ“š
      - LLM Supervised Fine-tuning ๐Ÿ‘จโ€๐Ÿซ
      - RLHF Reward Models ๐Ÿค
      - Constitutional AI Training ๐Ÿ“œ
      - RLAIF Feedback Models ๐Ÿ”„
      - Synthetic Data LLM Training ๐ŸŽฒ
      - Chain of Thought Prompting ๐Ÿงฉ
      - Tree of Thoughts Reasoning ๐ŸŒณ
   
   3. Post-Training Implementation ๐Ÿ”ง
      - Neural Network Distillation ๐Ÿงช
      - LLM Quantization Methods ๐Ÿ“Š
      - Neural Network Pruning โœ‚๏ธ
      - Knowledge Distillation Transfer ๐Ÿ“–
      - Few-shot LLM Learning ๐ŸŽฏ

3. Mechanistic Interpretability ๐Ÿ”ฌ
   1. Core Concepts ๐Ÿ’ก
      - Neural Network Growth Analysis ๐ŸŒฑ
      - LLM Architecture Analysis ๐Ÿ—๏ธ
      - Training Loss Optimization ๐ŸŽจ
      - Neural Network Analogies ๐Ÿงฌ
   
   2. Technical Features ๐Ÿ“
      - LLM Linear Representations โžก๏ธ
      - Neural Vector Arithmetic ๐Ÿ”ข
      - Neural Activation Patterns ๐ŸŒŠ
      - LLM Feature Detection ๐Ÿ”
      - Neural Sparse Autoencoders ๐ŸŽญ
   
   3. Network Analysis ๐Ÿ•ต๏ธ
      - LLM Induction Heads ๐Ÿ‘€
      - Transformer Attention Analysis ๐ŸŽช
      - Neural Circuit Analysis ๐Ÿ”Œ
      - LLM Feature Visualization ๐Ÿ“ˆ
      - Neural Concept Directions ๐ŸŽณ

4. Future AI Developments ๐Ÿš€
   1. AGI Timeline โฐ
      - AGI Capability Projections ๐Ÿ“…
      - Neural Hardware Scaling ๐Ÿ’พ
      - LLM Training Data Limits ๐Ÿ“‰
      - AI Compute Resources ๐Ÿ—บ๏ธ
   
   2. Integration Fields ๐ŸŽก
      - AI Biology Integration ๐Ÿ”ฎ
      - AI Drug Discovery Systems ๐Ÿ’Š
      - AI Clinical Trial Analysis ๐Ÿฅ
      - AI Code Generation ๐Ÿคน
      - AI Scientific Discovery ๐Ÿงฎ

5. Industry Best Practices ๐Ÿ’Ž
   1. AI Team Building ๐Ÿข
      - AI Talent Development ๐Ÿ‘ฅ
      - AI Research Alignment ๐ŸŽช
      - AI Team Scaling ๐Ÿ“Š
      - AI Research Culture ๐ŸŒŸ
   
   2. AI Research Qualities ๐ŸŽ“
      - AI Research Methodology ๐Ÿงญ
      - AI Experimentation Protocols ๐Ÿ—๏ธ
      - AI Innovation Thinking ๐Ÿ’ซ
      - AI Testing Framework โš–๏ธ
   
   3. AI Safety Standards ๐Ÿ›ก๏ธ
      - LLM Behavioral Specifications ๐Ÿ“‹
      - AI Safety Guidelines ๐ŸŽฎ
      - AI Ethics Framework โ›‘๏ธ
      - AI Industry Standards ๐Ÿคฒ

6. Emerging Research Areas ๐Ÿ”ฎ
   1. Technical Focus ๐ŸŽฏ
      - LLM Long Context Learning โณ
      - LLM Multi-agent Interaction ๐Ÿ‘พ
      - AI Evaluation Metrics ๐Ÿ“Œ
      - Neural Interpretability Methods ๐Ÿ”ญ
   
   2. AI Applications ๐Ÿ’ผ
      - AI Automated Research ๐Ÿงซ
      - AI Code Synthesis โŒจ๏ธ
      - AI Biological Modeling ๐Ÿงฏ
      - AI Medical Diagnostics ๐Ÿ’‰

7. Model Intelligence ๐Ÿงฟ
   1. LLM System Development ๐ŸŽช
      - LLM Prompt Engineering ๐Ÿ“
      - LLM Response Generation โ™Ÿ๏ธ
      - LLM Behavioral Training ๐ŸŽน
      - LLM Personality Development ๐ŸŽช
   
   2. LLM User Interaction ๐ŸŽญ
      - LLM Autonomy Alignment ๐ŸŽช
      - LLM Safety Boundaries ๐Ÿ”’
      - LLM Communication Patterns ๐Ÿ—ฃ๏ธ
      - LLM Performance Tuning ๐ŸŽข
"""

Multiplayer_Custom_Hosting_Game_Servers_For_Simulated_Worlds = """
Active Multiplayer Games 2024 ๐ŸŽฎ

1 Traditional MMORPGs ๐Ÿ—ก๏ธ

1.1 Major MMORPGs ๐Ÿฐ
- Final Fantasy XIV Dawntrail 2024 โš”๏ธ
  - Advanced Job System Rework ๐ŸŽญ
  - Cross Platform Integration ๐ŸŽช
  - New Housing Districts ๐Ÿ˜๏ธ

- World of Warcraft 2024 Season ๐Ÿฒ
  - Dragon Combat System ๐Ÿฆ‹
  - Cross Faction Features โšœ๏ธ
  - Mythic Plus Seasons ๐Ÿ†

- Elder Scrolls Online Gold Road ๐Ÿ—๏ธ
  - Dynamic Event System ๐ŸŒŸ
  - Housing Construction ๐Ÿ›๏ธ
  - Champion System 2.0 ๐Ÿ“Š

- Lost Ark Western T4 Update โšก
  - Legion Raid Content ๐Ÿ‘พ
  - Island Adventure System ๐Ÿ๏ธ
  - Class Balance Rework ๐Ÿ”ฐ

- Black Desert Online Remaster ๐ŸŽช
  - Combat System Update ๐ŸŽฏ
  - Node Empire System ๐Ÿน
  - Life Skill Evolution ๐ŸŒณ

1.2 Emerging MMORPGs ๐ŸŒ 
- Throne and Liberty Launch ๐Ÿ‘‘
  - Weather Combat System ๐ŸŒฆ๏ธ
  - Territory Wars ๐Ÿ—บ๏ธ
  - Transformation System ๐Ÿ‰

- Pax Dei Medieval MMO โš”๏ธ
  - City Management ๐Ÿฐ
  - Faith Based Magic โœจ
  - Global Trading ๐Ÿ’Ž

- Blue Protocol Western Release ๐ŸŒŒ
  - Action Combat Design ๐ŸŽญ
  - Class Change System โšก
  - Dungeon Scaling ๐Ÿ—ผ

2 Survival MMOs ๐Ÿน

2.1 Established Survival ๐Ÿ›ก๏ธ
- Rust 2024 Updates ๐Ÿฆพ
  - Electricity Programming ๐Ÿ’ก
  - Vehicle System Update ๐Ÿš—
  - Automated Defenses โšก

- ARK Survival Ascended ๐Ÿฆ–
  - Cross ARK System ๐ŸŒ
  - Creature Breeding 2.0 ๐Ÿฅš
  - Base Defense Network ๐Ÿฐ

- DayZ 2024 Content ๐ŸงŸ
  - Medical System Update ๐Ÿ’‰
  - Disease Mechanics ๐Ÿฆ 
  - Base Building 2.0 ๐Ÿ—๏ธ

- 7 Days to Die Alpha 22 ๐Ÿš๏ธ
  - Physics Engine Update ๐Ÿ’ฅ
  - AI Pathfinding System ๐Ÿง 
  - Vehicle Customization ๐Ÿš™

2.2 New Survival MMOs ๐Ÿ†•
- Once Human Launch ๐Ÿงฌ
  - Mutation System ๐Ÿงช
  - Base Building Tech ๐Ÿญ
  - Weather Impact System ๐ŸŒช๏ธ

- Nightingale Release ๐ŸŒ™
  - Portal Realm System ๐ŸŒŒ
  - Victorian Crafting ๐ŸŽฉ
  - Fae World Design ๐Ÿงš

3 Hybrid MMOs ๐ŸŽฏ

3.1 Looter Shooters ๐Ÿ”ซ
- Destiny 2 2024 Season ๐Ÿ›ธ
  - Build System 3.0 ๐Ÿ› ๏ธ
  - Raid Mechanics โญ
  - Season Structure ๐Ÿ“ˆ

- The Division 2 Year 6 ๐Ÿ™๏ธ
  - Loadout Expansion ๐ŸŽ’
  - Dark Zone Update ๐ŸŒƒ
  - Manhunt System ๐ŸŽฏ

- Warframe 2024 Update ๐Ÿค–
  - Movement Tech 2.0 ๐Ÿƒ
  - Mod System Rework โš™๏ธ
  - Open World Expansion ๐ŸŒ…

3.2 Action RPG MMOs ๐Ÿ’ซ
- Path of Exile 2 Beta ๐Ÿ’Ž
  - Gem System Rework ๐Ÿ’ซ
  - New Skill Tree ๐ŸŒฒ
  - League Content ๐Ÿ†

- Diablo 4 Season Structure ๐Ÿ˜ˆ
  - Season Journey System ๐ŸŽญ
  - World Boss Events ๐Ÿฒ
  - PvP Territories ๐Ÿ—ก๏ธ

4 Simulation MMOs ๐ŸŒ

4.1 Space Simulation ๐Ÿš€
- EVE Online 2024 ๐Ÿ›ธ
  - Corporation Warfare ๐Ÿดโ€โ˜ ๏ธ
  - Market System Update ๐Ÿ“Š
  - Fleet Operations ๐Ÿšข

- Elite Dangerous Update ๐ŸŒŒ
  - Ground Combat System ๐Ÿ‘จโ€๐Ÿš€
  - Fleet Carrier Content โญ
  - Planet Exploration ๐Ÿช

- Star Citizen Alpha ๐Ÿ›ธ
  - Persistent Universe ๐ŸŒ
  - Ship Combat Update โš”๏ธ
  - Trading System 2.0 ๐Ÿ’ฐ

4.2 World Simulation ๐ŸŒŽ
- New World Eternal ๐Ÿ—บ๏ธ
  - Territory System ๐Ÿฐ
  - Crafting Update ๐Ÿ› ๏ธ
  - War System 2.0 โš”๏ธ

- Albion Online 2024 ๐Ÿน
  - Guild Warfare Update โš”๏ธ
  - Economy System 2.0 ๐Ÿ’ฐ
  - Territory Control ๐Ÿฐ

5 Unique Multiplayer Games ๐ŸŽฒ

5.1 Adventure Multiplayer ๐Ÿ—บ๏ธ
- Sea of Thieves 2024 โ›ต
  - Ship Combat Physics ๐ŸŒŠ
  - Crew Management ๐Ÿดโ€โ˜ ๏ธ
  - World Events ๐ŸŽช

- Valheim Updates โšก
  - Building System 2.0 ๐Ÿ—๏ธ
  - Boss Progression ๐Ÿ‘น
  - Exploration Update ๐Ÿ—บ๏ธ

5.2 Combat Focused ๐Ÿ—ก๏ธ
- Mordhau 2024 โš”๏ธ
  - Combat Physics Update ๐Ÿคบ
  - Map System Rework ๐Ÿฐ
  - Tournament System ๐Ÿ†

- For Honor Year 8 ๐Ÿ›ก๏ธ
  - Faction War Update โš”๏ธ
  - Hero Rework System ๐ŸŽญ
  - Seasonal Content ๐ŸŒŸ

6 Upcoming 2024 Games ๐Ÿ”ฎ

6.1 Launching Soon ๐Ÿ“…
- Gray Zone Warfare ๐ŸŽ–๏ธ
  - Tactical Systems ๐ŸŽฏ
  - Base Operations ๐Ÿข
  - Territory Control ๐Ÿ—บ๏ธ

- Fractured Online ๐ŸŒŸ
  - City Building ๐Ÿ—๏ธ
  - Knowledge System ๐Ÿ“š
  - Player Economy ๐Ÿ’ฐ

6.2 In Development ๐Ÿ› ๏ธ
- Ashes of Creation ๐Ÿฐ
  - Node System ๐ŸŒฑ
  - Castle Siege โš”๏ธ
  - Caravan System ๐Ÿช

- Pantheon Rise of the Fallen ๐ŸŒ…
  - Climate System ๐ŸŒฆ๏ธ
  - Group Content Focus ๐Ÿ‘ฅ
  - Perception System ๐Ÿ‘๏ธ
"""

def get_display_name(filename):
    """Extract text from parentheses or return filename as is."""
    match = re.search(r'\((.*?)\)', filename)
    if match:
        return match.group(1)
    return filename

def get_time_display(filename):
    """Extract just the time portion from the filename."""
    time_match = re.match(r'(\d{2}\d{2}[AP]M)', filename)
    if time_match:
        return time_match.group(1)
    return filename

def sanitize_filename(text):
    """Create a safe filename from text while preserving spaces."""
    # First replace unsafe characters with spaces
    safe_text = re.sub(r'[^\w\s-]', ' ', text)
    # Remove any multiple spaces
    safe_text = re.sub(r'\s+', ' ', safe_text)
    # Trim leading/trailing spaces
    safe_text = safe_text.strip()
    return safe_text[:50]  # Limit length to 50 chars

def generate_timestamp_filename(query):
    """Generate filename with format: 1103AM 11032024 (Query).md"""
    # Get current time in Central timezone
    central = pytz.timezone('US/Central')
    current_time = datetime.now(central)
    
    # Format the timestamp parts
    time_str = current_time.strftime("%I%M%p")  # 1103AM format
    date_str = current_time.strftime("%m%d%Y")  # 11032024 format
    
    # Clean up the query for filename - now preserving spaces
    safe_query = sanitize_filename(query)
    
    # Construct filename: "1103AM 11032024 (Input with spaces).md"
    filename = f"{time_str} {date_str} ({safe_query}).md"
    
    return filename

def delete_file(file_path):
    """Delete a file and return success status."""
    try:
        os.remove(file_path)
        return True
    except Exception as e:
        st.error(f"Error deleting file: {e}")
        return False

def save_ai_interaction(query, ai_result, is_rerun=False):
    """Save AI interaction to a markdown file with new filename format."""
    filename = generate_timestamp_filename(query)
    
    # Format the content differently for rerun vs normal query
    if is_rerun:
        content = f"""# Rerun Query
Original file content used for rerun:

{query}

# AI Response (Fun Version)
{ai_result}
"""
    else:
        content = f"""# Query: {query}

## AI Response
{ai_result}
"""
    
    # Save to file
    try:
        with open(filename, 'w', encoding='utf-8') as f:
            f.write(content)
        return filename
    except Exception as e:
        st.error(f"Error saving file: {e}")
        return None

def get_file_download_link(file_path):
    """Generate a base64 download link for a file."""
    try:
        with open(file_path, 'r', encoding='utf-8') as f:
            content = f.read()
        b64 = base64.b64encode(content.encode()).decode()
        filename = os.path.basename(file_path)
        return f'<a href="data:text/markdown;base64,{b64}" download="{filename}">{get_display_name(filename)}</a>'
    except Exception as e:
        st.error(f"Error creating download link: {e}")
        return None

def extract_terms(markdown_text):
    """Parse markdown text and extract terms."""
    lines = markdown_text.strip().split('\n')
    terms = []
    for line in lines:
        line = re.sub(r'^[#*\->\d\.\s]+', '', line).strip()
        if line:
            terms.append(line)
    return terms

def extract_urls(text):
    try:
        date_pattern = re.compile(r'### (\d{2} \w{3} \d{4})')
        abs_link_pattern = re.compile(r'\[(.*?)\]\((https://arxiv\.org/abs/\d+\.\d+)\)')
        pdf_link_pattern = re.compile(r'\[โฌ‡๏ธ\]\((https://arxiv\.org/pdf/\d+\.\d+)\)')
        title_pattern = re.compile(r'### \d{2} \w{3} \d{4} \| \[(.*?)\]')
        date_matches = date_pattern.findall(text)
        abs_link_matches = abs_link_pattern.findall(text)
        pdf_link_matches = pdf_link_pattern.findall(text)
        title_matches = title_pattern.findall(text)

        # markdown with the extracted fields
        markdown_text = ""
        for i in range(len(date_matches)):
            date = date_matches[i]
            title = title_matches[i]
            abs_link = abs_link_matches[i][1]
            pdf_link = pdf_link_matches[i]
            markdown_text += f"**Date:** {date}\n\n"
            markdown_text += f"**Title:** {title}\n\n"
            markdown_text += f"**Abstract Link:** [{abs_link}]({abs_link})\n\n"
            markdown_text += f"**PDF Link:** [{pdf_link}]({pdf_link})\n\n"
            markdown_text += "---\n\n"
        return markdown_text
    
    except:
        st.write('.')
        return ''


# HTML5 based Speech Synthesis (Text to Speech in Browser)
@st.cache_resource
def SpeechSynthesis(result):
    documentHTML5='''
    <!DOCTYPE html>
    <html>
    <head>
        <title>Read It Aloud</title>
        <script type="text/javascript">
            function readAloud() {
                const text = document.getElementById("textArea").value;
                const speech = new SpeechSynthesisUtterance(text);
                window.speechSynthesis.speak(speech);
            }
        </script>
    </head>
    <body>
        <h1>๐Ÿ”Š Read It Aloud</h1>
        <textarea id="textArea" rows="10" cols="80">
    '''
    documentHTML5 = documentHTML5 + result
    documentHTML5 = documentHTML5 + '''
        </textarea>
        <br>
        <button onclick="readAloud()">๐Ÿ”Š Read Aloud</button>
    </body>
    </html>
    '''
    components.html(documentHTML5, width=1280, height=300)

def display_terms_with_links(terms):
    """Display terms with various search links."""
    search_urls = {
        "๐Ÿ“š๐Ÿ“–ArXiv": lambda k: f"/?q={quote(k)}",            # Academic/paper theme
        "๐Ÿ”ฎ<sup>Google</sup>": lambda k: f"https://www.google.com/search?q={quote(k)}",    # Crystal ball for search
        "๐Ÿ“บ<sup>Youtube</sup>": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}", # TV for videos
        "๐Ÿ”ญ<sup>Bing</sup>": lambda k: f"https://www.bing.com/search?q={quote(k)}",        # Telescope for search
        "๐Ÿ’ก<sup>Truth</sup>": lambda k: f"https://truthsocial.com/search?q={quote(k)}",    # Light bulb for insight
        "๐Ÿ“ฑX": lambda k: f"https://twitter.com/search?q={quote(k)}",                        # Phone for social media
    }
    for term in terms:
        links_md = ' '.join([f"[{emoji}]({url(term)})" for emoji, url in search_urls.items()])
        st.markdown(f"- **{term}** {links_md}", unsafe_allow_html=True)

def search_arxiv(query):
    
    st.write("Performing AI Lookup...")
    client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
    
    result1 = client.predict(
        prompt=query,
        llm_model_picked="mistralai/Mixtral-8x7B-Instruct-v0.1",
        stream_outputs=True,
        api_name="/ask_llm"
    )
    st.markdown("### Mixtral-8x7B-Instruct-v0.1 Result")
    st.markdown(result1)

    result2 = client.predict(
        prompt=query,
        llm_model_picked="mistralai/Mistral-7B-Instruct-v0.2",
        stream_outputs=True,
        api_name="/ask_llm"
    )
    st.markdown("### Mistral-7B-Instruct-v0.2 Result")
    st.markdown(result2)
    combined_result = f"{result1}\n\n{result2}"
    #return combined_result

    return responseall


def perform_ai_lookup(query):
    start_time = time.strftime("%Y-%m-%d %H:%M:%S")
    client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
    response1 = client.predict(
        query,
        20,
        "Semantic Search",
        "mistralai/Mixtral-8x7B-Instruct-v0.1",
        api_name="/update_with_rag_md"
    )
    Question = '### ๐Ÿ”Ž ' + query + '\r\n'  # Format for markdown display with links
    References =  response1[0]  
    ReferenceLinks = extract_urls(References)

    RunSecondQuery = True
    results=''
    if RunSecondQuery:
        # Search 2 - Retrieve the Summary with Papers Context and Original Query
        response2 = client.predict(
            query,
            "mistralai/Mixtral-8x7B-Instruct-v0.1",
            True,
            api_name="/ask_llm"
        )
        if len(response2) > 10:
            Answer = response2
            SpeechSynthesis(Answer)
            # Restructure results to follow format of Question, Answer, References, ReferenceLinks
            results = Question + '\r\n' + Answer + '\r\n' + References + '\r\n' + ReferenceLinks
            st.markdown(results)

    st.write('๐Ÿ”Run of Multi-Agent System Paper Summary Spec is Complete')
    end_time = time.strftime("%Y-%m-%d %H:%M:%S")
    start_timestamp = time.mktime(time.strptime(start_time, "%Y-%m-%d %H:%M:%S"))
    end_timestamp = time.mktime(time.strptime(end_time, "%Y-%m-%d %H:%M:%S"))
    elapsed_seconds = end_timestamp - start_timestamp
    st.write(f"Start time: {start_time}")
    st.write(f"Finish time: {end_time}")
    st.write(f"Elapsed time: {elapsed_seconds:.2f} seconds")
    filename = generate_filename(query, "md")
    create_file(filename, query, results, should_save)
    return results

def display_file_content(file_path):
    """Display file content with editing capabilities."""
    try:
        with open(file_path, 'r', encoding='utf-8') as f:
            content = f.read()
        
        if st.session_state.view_mode == 'view':
            # Display as markdown when viewing
            st.markdown(content)
        else:
            # Edit functionality
            edited_content = st.text_area(
                "Edit content",
                content,
                height=400,
                key=f"edit_{os.path.basename(file_path)}"
            )
            
            if st.button("Save Changes", key=f"save_{os.path.basename(file_path)}"):
                try:
                    with open(file_path, 'w', encoding='utf-8') as f:
                        f.write(edited_content)
                    st.success(f"Successfully saved changes to {file_path}")
                except Exception as e:
                    st.error(f"Error saving changes: {e}")
    except Exception as e:
        st.error(f"Error reading file: {e}")

def file_management_sidebar():
    """Redesigned sidebar with improved layout and additional functionality."""
    st.sidebar.title("๐Ÿ“ File Management")

    # Get list of .md files excluding README.md
    md_files = [file for file in glob.glob("*.md") if file.lower() != 'readme.md']
    md_files.sort()
    st.session_state.files = md_files
    
    if md_files:
        st.sidebar.markdown("### Saved Files")
        for idx, file in enumerate(md_files):
            st.sidebar.markdown("---")  # Separator between files
            
            # Display time
            st.sidebar.text(get_time_display(file))
            
            # Display download link with simplified text
            download_link = get_file_download_link(file)
            if download_link:
                st.sidebar.markdown(download_link, unsafe_allow_html=True)
            
            # Action buttons in a row
            col1, col2, col3, col4 = st.sidebar.columns(4)
            
            with col1:
                if st.button("๐Ÿ“„ View", key=f"view_{idx}"):
                    st.session_state.selected_file = file
                    st.session_state.view_mode = 'view'
            
            with col2:
                if st.button("โœ๏ธ Edit", key=f"edit_{idx}"):
                    st.session_state.selected_file = file
                    st.session_state.view_mode = 'edit'
            
            with col3:
                if st.button("๐Ÿ”„ Rerun", key=f"rerun_{idx}"):
                    try:
                        with open(file, 'r', encoding='utf-8') as f:
                            content = f.read()
                            
                        # Prepare the prompt with the prefix
                        rerun_prefix = """For the markdown below reduce the text to a humorous fun outline with emojis and markdown outline levels in outline that convey all the facts and adds wise quotes and funny statements to engage the reader:

"""
                        full_prompt = rerun_prefix + content
                        
                        # Perform AI lookup and save results
                        ai_result = perform_ai_lookup(full_prompt)
                        saved_file = save_ai_interaction(content, ai_result, is_rerun=True)
                        
                        if saved_file:
                            st.success(f"Created fun version in {saved_file}")
                            st.session_state.selected_file = saved_file
                            st.session_state.view_mode = 'view'
                            
                    except Exception as e:
                        st.error(f"Error during rerun: {e}")
            
            with col4:
                if st.button("๐Ÿ—‘๏ธ Delete", key=f"delete_{idx}"):
                    if delete_file(file):
                        st.success(f"Deleted {file}")
                        st.rerun()
                    else:
                        st.error(f"Failed to delete {file}")

        st.sidebar.markdown("---")
        # Option to create a new markdown file
        if st.sidebar.button("๐Ÿ“ Create New Note"):
            filename = generate_timestamp_filename("New Note")
            with open(filename, 'w', encoding='utf-8') as f:
                f.write("# New Markdown File\n")
            st.sidebar.success(f"Created: {filename}")
            st.session_state.selected_file = filename
            st.session_state.view_mode = 'edit'
    else:
        st.sidebar.write("No markdown files found.")
        if st.sidebar.button("๐Ÿ“ Create First Note"):
            filename = generate_timestamp_filename("New Note")
            with open(filename, 'w', encoding='utf-8') as f:
                f.write("# New Markdown File\n")
            st.sidebar.success(f"Created: {filename}")
            st.session_state.selected_file = filename
            st.session_state.view_mode = 'edit'

def main():
    st.markdown("### AI Knowledge Tree Builder ๐Ÿง ๐ŸŒฑ Cultivate Your AI Mindscape!")

    # Process query parameters and AI lookup first
    query_params = st.query_params
    query = query_params.get('q', '')
    show_initial_content = True  # Flag to control initial content display
    
    # First priority: Handle active query
    if query:
        show_initial_content = False  # Hide initial content when showing query results
        st.write(f"### Search query received: {query}")
        try:
            ai_result = perform_ai_lookup(query)
            
            # Save the interaction
            saved_file = save_ai_interaction(query, ai_result)
            if saved_file:
                st.success(f"Saved interaction to {saved_file}")
                st.session_state.selected_file = saved_file
                st.session_state.view_mode = 'view'
        except Exception as e:
            st.error(f"Error during AI lookup: {e}")

    # File management sidebar
    file_management_sidebar()

    # Second priority: Display selected file content if any
    if st.session_state.selected_file:
        show_initial_content = False  # Hide initial content when showing file content
        if os.path.exists(st.session_state.selected_file):
            st.markdown(f"### Current File: {st.session_state.selected_file}")
            display_file_content(st.session_state.selected_file)
        else:
            st.error("Selected file no longer exists.")
            st.session_state.selected_file = None
            st.rerun()

# Show initial content: Either when first landing or when no interactive elements are active
    if show_initial_content:
        # First show the clickable terms with links
        terms1 = extract_terms(AITopicsToInnovate1)
        terms2 = extract_terms(Multiplayer_Custom_Hosting_Game_Servers_For_Simulated_Worlds)
        terms3 = extract_terms(BiologyAndLevel36MagicUsers)
        
        all_terms = terms1 + terms2 + terms3

        col1, col2, col3, col4, col5, col6 = st.columns(6)
        
        with col1:
            st.markdown("#### AI Topics to Innovate With")
            st.markdown(AITopicsToInnovate1)
        with col2:
            st.markdown("#### AI Agent Links")
            display_terms_with_links(terms1)
        with col3:
            st.markdown("#### Biology Innovation with Data Science and AI Solutions")
            st.markdown(BiologyAndLevel36MagicUsers)
        with col4:
            st.markdown("#### Biology Innovation Agent Links")
            display_terms_with_links(terms3)
        with col5:
            st.markdown("#### Multiplayer Games and MMOs")
            st.markdown(Multiplayer_Custom_Hosting_Game_Servers_For_Simulated_Worlds)
        with col6:
            st.markdown("#### Multiplayer Game and MMO Links")
            display_terms_with_links(terms2)

if __name__ == "__main__":
    main()