awacke1 commited on
Commit
130b487
1 Parent(s): 1053e8d

Create backup7.app.py

Browse files
Files changed (1) hide show
  1. backup7.app.py +898 -0
backup7.app.py ADDED
@@ -0,0 +1,898 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import glob
4
+ import re
5
+ import base64
6
+ import pytz
7
+ import time
8
+ import streamlit.components.v1 as components
9
+
10
+ from urllib.parse import quote
11
+ from gradio_client import Client
12
+ from datetime import datetime
13
+
14
+ # 🌳🤖 AIKnowledgeTreeBuilder - Because every app needs a good costume!
15
+
16
+ Site_Name = 'AI Knowledge Tree Builder 📈🌿 Grow Smarter with Every Click'
17
+ title = "🌳✨AI Knowledge Tree Builder🛠️🤓"
18
+ helpURL = 'https://huggingface.co/spaces/awacke1/AIKnowledgeTreeBuilder/'
19
+ bugURL = 'https://huggingface.co/spaces/awacke1/AIKnowledgeTreeBuilder/'
20
+ icons = '🌳✨🛠️🤓'
21
+
22
+ SidebarOutline="""
23
+ 🌳🤖 AIKnowledgeTreeBuilder is designed with the following tenets:
24
+ 1.📱 **Portability** - Universal access via any device & link sharing
25
+ 2.⚡ **Speed of Build** - Rapid deployments (< 2min to production)
26
+ 3.🔗 **Linkiness** - Programmatic access to major AI knowledge sources
27
+ 4.🎯 **Abstractive** - Core stays lean by isolating high-maintenance components
28
+ 5.🧠 **Memory** - Shareable flows with deep-linked research paths
29
+ 6.👤 **Personalized** - Rapidly adapts knowledge base to user needs
30
+ 7.🐦 **Living Brevity** - Easily cloneable, self modifies with data and public to shares results.
31
+ """
32
+
33
+ st.set_page_config(
34
+ page_title=title,
35
+ page_icon=icons,
36
+ layout="wide",
37
+ initial_sidebar_state="auto",
38
+ menu_items={
39
+ 'Get Help': helpURL,
40
+ 'Report a bug': bugURL,
41
+ 'About': title
42
+ }
43
+ )
44
+
45
+ st.sidebar.markdown(SidebarOutline)
46
+
47
+
48
+ # Initialize session state variables
49
+ if 'selected_file' not in st.session_state:
50
+ st.session_state.selected_file = None
51
+ if 'view_mode' not in st.session_state:
52
+ st.session_state.view_mode = 'view'
53
+ if 'files' not in st.session_state:
54
+ st.session_state.files = []
55
+
56
+
57
+ BiologyAndLevel36MagicUsers="""
58
+ 0. Biology Core Rules and Future Exceptions
59
+ 1. Central Dogma DNA RNA Protein
60
+ - Current CRISPR RNA editing 🧪
61
+ - Research Gene therapy siRNA 🔬
62
+ - Future Programmable genetics 🚀
63
+
64
+ 2. Cell Origin
65
+ - Current iPSCs organoids 🦠
66
+ - Research Synthetic cells 🔬
67
+ - Future De novo cell creation 🚀
68
+
69
+ 3. Form Function
70
+ - Current Bioprinting 🫀
71
+ - Research 4D printing 🔬
72
+ - Future Self assembling structures 🚀
73
+
74
+ 4. Homeostasis
75
+ - Current Artificial pancreas 🤖
76
+ - Research Nanorobots 🔬
77
+ - Future Autonomous regulation 🚀
78
+
79
+ 5. Evolution
80
+ - Current Directed evolution 🧫
81
+ - Research Synthetic biology 🔬
82
+ - Future Accelerated adaptation 🚀
83
+
84
+ 6. Energy Conservation
85
+ - Current Biofuel cells ⚡
86
+ - Research Quantum biology 🔬
87
+ - Future Biological perpetual motion 🚀
88
+
89
+ 7. Cellular Life
90
+ - Current Organoid systems 🔮
91
+ - Research Hybrid cells 🔬
92
+ - Future Silicon based life 🚀
93
+
94
+ 8. Inheritance Patterns
95
+ - Current Gene drives 🧩
96
+ - Research Epigenetic control 🔬
97
+ - Future Designed inheritance 🚀
98
+
99
+ 9. Energy Requirements
100
+ - Current Metabolic engineering 🔋
101
+ - Research Synthetic photosynthesis 🔬
102
+ - Future Zero energy life 🚀
103
+
104
+ 10. Random Mutation
105
+ - Current Base editing 🎯
106
+ - Research Mutation prediction 🔬
107
+ - Future Controlled evolution 🚀
108
+
109
+ 11. Carbon Based Life
110
+ - Current Alternative biochemistry 💎
111
+ - Research Silicon biology 🔬
112
+ - Future Non carbon life 🚀
113
+
114
+ 12. Size Limitations
115
+ - Current Nanostructures 📏
116
+ - Research Quantum biology 🔬
117
+ - Future Scalable organisms 🚀
118
+
119
+ 13. Species Interdependence
120
+ - Current Synthetic ecosystems 🌿
121
+ - Research Artificial symbiosis 🔬
122
+ - Future Independent life 🚀
123
+
124
+ 14. Stimulus Response
125
+ - Current Brain computer interfaces 🧠
126
+ - Research Neural engineering 🔬
127
+ - Future Direct consciousness control 🚀
128
+
129
+ 15. Development Complexity
130
+ - Current Accelerated growth 🌱
131
+ - Research Development control 🔬
132
+ - Future Instant maturation 🚀
133
+
134
+ 16. Population Growth
135
+ - Current Population control 📊
136
+ - Research Sustainable ecosystems 🔬
137
+ - Future Perfect equilibrium 🚀
138
+
139
+ 17. Energy Flow
140
+ - Current Enhanced photosynthesis 🌞
141
+ - Research Energy optimization 🔬
142
+ - Future Perpetual systems 🚀
143
+
144
+ 18. Environmental Adaptation
145
+ - Current Climate resistance 🌍
146
+ - Research Universal adaptation 🔬
147
+ - Future Environment independence 🚀
148
+
149
+ 19. Genetic Inheritance
150
+ - Current Gene editing 🧬
151
+ - Research Trait programming 🔬
152
+ - Future Perfect inheritance 🚀
153
+
154
+ 20. Reproduction
155
+ - Current Artificial wombs 👶
156
+ - Research Cloning advances 🔬
157
+ - Future Asexual human reproduction 🚀
158
+
159
+ 21. Aging Death
160
+ - Current Longevity therapy ⏰
161
+ - Research Age reversal 🔬
162
+ - Future Biological immortality 🚀
163
+ """
164
+
165
+ AITopicsToInnovate1="""
166
+ 1. Major AI Industry Players 🌐
167
+ 1. Research Leaders 🎯
168
+ - OpenAI: GPT-4 DALL-E Foundation Models 🔵
169
+ - Google: PaLM Gemini LLMs 🟦
170
+ - Anthropic: Claude Constitutional AI ⚡
171
+ - Meta: LLaMA Open Source LLMs 👤
172
+ - xAI: Grok Conversational AI 🤖
173
+
174
+ 2. Technical AI Development 🛠️
175
+ 1. Architecture Advances 💫
176
+ - Transformer Models Attention Mechanisms 🧠
177
+ - Mixture of Experts MoE Architecture 🎪
178
+ - Sparse Neural Networks 🕸️
179
+ - Multi-modal LLM Systems 🌈
180
+ - Flash Attention Optimization ⚔️
181
+
182
+ 2. Training Methodologies 📚
183
+ - LLM Supervised Fine-tuning 👨‍🏫
184
+ - RLHF Reward Models 🤝
185
+ - Constitutional AI Training 📜
186
+ - RLAIF Feedback Models 🔄
187
+ - Synthetic Data LLM Training 🎲
188
+ - Chain of Thought Prompting 🧩
189
+ - Tree of Thoughts Reasoning 🌳
190
+
191
+ 3. Post-Training Implementation 🔧
192
+ - Neural Network Distillation 🧪
193
+ - LLM Quantization Methods 📊
194
+ - Neural Network Pruning ✂️
195
+ - Knowledge Distillation Transfer 📖
196
+ - Few-shot LLM Learning 🎯
197
+
198
+ 3. Mechanistic Interpretability 🔬
199
+ 1. Core Concepts 💡
200
+ - Neural Network Growth Analysis 🌱
201
+ - LLM Architecture Analysis 🏗️
202
+ - Training Loss Optimization 🎨
203
+ - Neural Network Analogies 🧬
204
+
205
+ 2. Technical Features 📐
206
+ - LLM Linear Representations ➡️
207
+ - Neural Vector Arithmetic 🔢
208
+ - Neural Activation Patterns 🌊
209
+ - LLM Feature Detection 🔍
210
+ - Neural Sparse Autoencoders 🎭
211
+
212
+ 3. Network Analysis 🕵️
213
+ - LLM Induction Heads 👀
214
+ - Transformer Attention Analysis 🎪
215
+ - Neural Circuit Analysis 🔌
216
+ - LLM Feature Visualization 📈
217
+ - Neural Concept Directions 🎳
218
+
219
+ 4. Future AI Developments 🚀
220
+ 1. AGI Timeline ⏰
221
+ - AGI Capability Projections 📅
222
+ - Neural Hardware Scaling 💾
223
+ - LLM Training Data Limits 📉
224
+ - AI Compute Resources 🗺️
225
+
226
+ 2. Integration Fields 🎡
227
+ - AI Biology Integration 🔮
228
+ - AI Drug Discovery Systems 💊
229
+ - AI Clinical Trial Analysis 🏥
230
+ - AI Code Generation 🤹
231
+ - AI Scientific Discovery 🧮
232
+
233
+ 5. Industry Best Practices 💎
234
+ 1. AI Team Building 🏢
235
+ - AI Talent Development 👥
236
+ - AI Research Alignment 🎪
237
+ - AI Team Scaling 📊
238
+ - AI Research Culture 🌟
239
+
240
+ 2. AI Research Qualities 🎓
241
+ - AI Research Methodology 🧭
242
+ - AI Experimentation Protocols 🗝️
243
+ - AI Innovation Thinking 💫
244
+ - AI Testing Framework ⚖️
245
+
246
+ 3. AI Safety Standards 🛡️
247
+ - LLM Behavioral Specifications 📋
248
+ - AI Safety Guidelines 🎮
249
+ - AI Ethics Framework ⛑️
250
+ - AI Industry Standards 🤲
251
+
252
+ 6. Emerging Research Areas 🔮
253
+ 1. Technical Focus 🎯
254
+ - LLM Long Context Learning ⏳
255
+ - LLM Multi-agent Interaction 👾
256
+ - AI Evaluation Metrics 📌
257
+ - Neural Interpretability Methods 🔭
258
+
259
+ 2. AI Applications 💼
260
+ - AI Automated Research 🧫
261
+ - AI Code Synthesis ⌨️
262
+ - AI Biological Modeling 🧯
263
+ - AI Medical Diagnostics 💉
264
+
265
+ 7. Model Intelligence 🧿
266
+ 1. LLM System Development 🎪
267
+ - LLM Prompt Engineering 📝
268
+ - LLM Response Generation ♟️
269
+ - LLM Behavioral Training 🎹
270
+ - LLM Personality Development 🎪
271
+
272
+ 2. LLM User Interaction 🎭
273
+ - LLM Autonomy Alignment 🎪
274
+ - LLM Safety Boundaries 🔒
275
+ - LLM Communication Patterns 🗣️
276
+ - LLM Performance Tuning 🎢
277
+ """
278
+
279
+ Multiplayer_Custom_Hosting_Game_Servers_For_Simulated_Worlds = """
280
+ Active Multiplayer Games 2024 🎮
281
+
282
+ 1 Traditional MMORPGs 🗡️
283
+
284
+ 1.1 Major MMORPGs 🏰
285
+ - Final Fantasy XIV Dawntrail 2024 ⚔️
286
+ - Advanced Job System Rework 🎭
287
+ - Cross Platform Integration 🎪
288
+ - New Housing Districts 🏘️
289
+
290
+ - World of Warcraft 2024 Season 🐲
291
+ - Dragon Combat System 🦋
292
+ - Cross Faction Features ⚜️
293
+ - Mythic Plus Seasons 🏆
294
+
295
+ - Elder Scrolls Online Gold Road 🗝️
296
+ - Dynamic Event System 🌟
297
+ - Housing Construction 🏛️
298
+ - Champion System 2.0 📊
299
+
300
+ - Lost Ark Western T4 Update ⚡
301
+ - Legion Raid Content 👾
302
+ - Island Adventure System 🏝️
303
+ - Class Balance Rework 🔰
304
+
305
+ - Black Desert Online Remaster 🎪
306
+ - Combat System Update 🎯
307
+ - Node Empire System 🏹
308
+ - Life Skill Evolution 🌳
309
+
310
+ 1.2 Emerging MMORPGs 🌠
311
+ - Throne and Liberty Launch 👑
312
+ - Weather Combat System 🌦️
313
+ - Territory Wars 🗺️
314
+ - Transformation System 🐉
315
+
316
+ - Pax Dei Medieval MMO ⚔️
317
+ - City Management 🏰
318
+ - Faith Based Magic ✨
319
+ - Global Trading 💎
320
+
321
+ - Blue Protocol Western Release 🌌
322
+ - Action Combat Design 🎭
323
+ - Class Change System ⚡
324
+ - Dungeon Scaling 🗼
325
+
326
+ 2 Survival MMOs 🏹
327
+
328
+ 2.1 Established Survival 🛡️
329
+ - Rust 2024 Updates 🦾
330
+ - Electricity Programming 💡
331
+ - Vehicle System Update 🚗
332
+ - Automated Defenses ⚡
333
+
334
+ - ARK Survival Ascended 🦖
335
+ - Cross ARK System 🌐
336
+ - Creature Breeding 2.0 🥚
337
+ - Base Defense Network 🏰
338
+
339
+ - DayZ 2024 Content 🧟
340
+ - Medical System Update 💉
341
+ - Disease Mechanics 🦠
342
+ - Base Building 2.0 🏗️
343
+
344
+ - 7 Days to Die Alpha 22 🏚️
345
+ - Physics Engine Update 💥
346
+ - AI Pathfinding System 🧠
347
+ - Vehicle Customization 🚙
348
+
349
+ 2.2 New Survival MMOs 🆕
350
+ - Once Human Launch 🧬
351
+ - Mutation System 🧪
352
+ - Base Building Tech 🏭
353
+ - Weather Impact System 🌪️
354
+
355
+ - Nightingale Release 🌙
356
+ - Portal Realm System 🌌
357
+ - Victorian Crafting 🎩
358
+ - Fae World Design 🧚
359
+
360
+ 3 Hybrid MMOs 🎯
361
+
362
+ 3.1 Looter Shooters 🔫
363
+ - Destiny 2 2024 Season 🛸
364
+ - Build System 3.0 🛠️
365
+ - Raid Mechanics ⭐
366
+ - Season Structure 📈
367
+
368
+ - The Division 2 Year 6 🏙️
369
+ - Loadout Expansion 🎒
370
+ - Dark Zone Update 🌃
371
+ - Manhunt System 🎯
372
+
373
+ - Warframe 2024 Update 🤖
374
+ - Movement Tech 2.0 🏃
375
+ - Mod System Rework ⚙️
376
+ - Open World Expansion 🌅
377
+
378
+ 3.2 Action RPG MMOs 💫
379
+ - Path of Exile 2 Beta 💎
380
+ - Gem System Rework 💫
381
+ - New Skill Tree 🌲
382
+ - League Content 🏆
383
+
384
+ - Diablo 4 Season Structure 😈
385
+ - Season Journey System 🎭
386
+ - World Boss Events 🐲
387
+ - PvP Territories 🗡️
388
+
389
+ 4 Simulation MMOs 🌍
390
+
391
+ 4.1 Space Simulation 🚀
392
+ - EVE Online 2024 🛸
393
+ - Corporation Warfare 🏴‍☠️
394
+ - Market System Update 📊
395
+ - Fleet Operations 🚢
396
+
397
+ - Elite Dangerous Update 🌌
398
+ - Ground Combat System 👨‍🚀
399
+ - Fleet Carrier Content ⭐
400
+ - Planet Exploration 🪐
401
+
402
+ - Star Citizen Alpha 🛸
403
+ - Persistent Universe 🌍
404
+ - Ship Combat Update ⚔️
405
+ - Trading System 2.0 💰
406
+
407
+ 4.2 World Simulation 🌎
408
+ - New World Eternal 🗺️
409
+ - Territory System 🏰
410
+ - Crafting Update 🛠️
411
+ - War System 2.0 ⚔️
412
+
413
+ - Albion Online 2024 🏹
414
+ - Guild Warfare Update ⚔️
415
+ - Economy System 2.0 💰
416
+ - Territory Control 🏰
417
+
418
+ 5 Unique Multiplayer Games 🎲
419
+
420
+ 5.1 Adventure Multiplayer 🗺️
421
+ - Sea of Thieves 2024 ⛵
422
+ - Ship Combat Physics 🌊
423
+ - Crew Management 🏴‍☠️
424
+ - World Events 🎪
425
+
426
+ - Valheim Updates ⚡
427
+ - Building System 2.0 🏗️
428
+ - Boss Progression 👹
429
+ - Exploration Update 🗺️
430
+
431
+ 5.2 Combat Focused 🗡️
432
+ - Mordhau 2024 ⚔️
433
+ - Combat Physics Update 🤺
434
+ - Map System Rework 🏰
435
+ - Tournament System 🏆
436
+
437
+ - For Honor Year 8 🛡️
438
+ - Faction War Update ⚔️
439
+ - Hero Rework System 🎭
440
+ - Seasonal Content 🌟
441
+
442
+ 6 Upcoming 2024 Games 🔮
443
+
444
+ 6.1 Launching Soon 📅
445
+ - Gray Zone Warfare 🎖️
446
+ - Tactical Systems 🎯
447
+ - Base Operations 🏢
448
+ - Territory Control 🗺️
449
+
450
+ - Fractured Online 🌟
451
+ - City Building 🏗️
452
+ - Knowledge System 📚
453
+ - Player Economy 💰
454
+
455
+ 6.2 In Development 🛠️
456
+ - Ashes of Creation 🏰
457
+ - Node System 🌱
458
+ - Castle Siege ⚔️
459
+ - Caravan System 🐪
460
+
461
+ - Pantheon Rise of the Fallen 🌅
462
+ - Climate System 🌦️
463
+ - Group Content Focus 👥
464
+ - Perception System 👁️
465
+ """
466
+
467
+ def get_display_name(filename):
468
+ """Extract text from parentheses or return filename as is."""
469
+ match = re.search(r'\((.*?)\)', filename)
470
+ if match:
471
+ return match.group(1)
472
+ return filename
473
+
474
+ def get_time_display(filename):
475
+ """Extract just the time portion from the filename."""
476
+ time_match = re.match(r'(\d{2}\d{2}[AP]M)', filename)
477
+ if time_match:
478
+ return time_match.group(1)
479
+ return filename
480
+
481
+ def sanitize_filename(text):
482
+ """Create a safe filename from text while preserving spaces."""
483
+ # First replace unsafe characters with spaces
484
+ safe_text = re.sub(r'[^\w\s-]', ' ', text)
485
+ # Remove any multiple spaces
486
+ safe_text = re.sub(r'\s+', ' ', safe_text)
487
+ # Trim leading/trailing spaces
488
+ safe_text = safe_text.strip()
489
+ return safe_text[:50] # Limit length to 50 chars
490
+
491
+ def generate_timestamp_filename(query):
492
+ """Generate filename with format: 1103AM 11032024 (Query).md"""
493
+ # Get current time in Central timezone
494
+ central = pytz.timezone('US/Central')
495
+ current_time = datetime.now(central)
496
+
497
+ # Format the timestamp parts
498
+ time_str = current_time.strftime("%I%M%p") # 1103AM format
499
+ date_str = current_time.strftime("%m%d%Y") # 11032024 format
500
+
501
+ # Clean up the query for filename - now preserving spaces
502
+ safe_query = sanitize_filename(query)
503
+
504
+ # Construct filename: "1103AM 11032024 (Input with spaces).md"
505
+ filename = f"{time_str} {date_str} ({safe_query}).md"
506
+
507
+ return filename
508
+
509
+ def delete_file(file_path):
510
+ """Delete a file and return success status."""
511
+ try:
512
+ os.remove(file_path)
513
+ return True
514
+ except Exception as e:
515
+ st.error(f"Error deleting file: {e}")
516
+ return False
517
+
518
+ def save_ai_interaction(query, ai_result, is_rerun=False):
519
+ """Save AI interaction to a markdown file with new filename format."""
520
+ filename = generate_timestamp_filename(query)
521
+
522
+ # Format the content differently for rerun vs normal query
523
+ if is_rerun:
524
+ content = f"""# Rerun Query
525
+ Original file content used for rerun:
526
+
527
+ {query}
528
+
529
+ # AI Response (Fun Version)
530
+ {ai_result}
531
+ """
532
+ else:
533
+ content = f"""# Query: {query}
534
+
535
+ ## AI Response
536
+ {ai_result}
537
+ """
538
+
539
+ # Save to file
540
+ try:
541
+ with open(filename, 'w', encoding='utf-8') as f:
542
+ f.write(content)
543
+ return filename
544
+ except Exception as e:
545
+ st.error(f"Error saving file: {e}")
546
+ return None
547
+
548
+ def get_file_download_link(file_path):
549
+ """Generate a base64 download link for a file."""
550
+ try:
551
+ with open(file_path, 'r', encoding='utf-8') as f:
552
+ content = f.read()
553
+ b64 = base64.b64encode(content.encode()).decode()
554
+ filename = os.path.basename(file_path)
555
+ return f'<a href="data:text/markdown;base64,{b64}" download="{filename}">{get_display_name(filename)}</a>'
556
+ except Exception as e:
557
+ st.error(f"Error creating download link: {e}")
558
+ return None
559
+
560
+ def extract_terms(markdown_text):
561
+ """Parse markdown text and extract terms."""
562
+ lines = markdown_text.strip().split('\n')
563
+ terms = []
564
+ for line in lines:
565
+ line = re.sub(r'^[#*\->\d\.\s]+', '', line).strip()
566
+ if line:
567
+ terms.append(line)
568
+ return terms
569
+
570
+ def extract_urls(text):
571
+ try:
572
+ date_pattern = re.compile(r'### (\d{2} \w{3} \d{4})')
573
+ abs_link_pattern = re.compile(r'\[(.*?)\]\((https://arxiv\.org/abs/\d+\.\d+)\)')
574
+ pdf_link_pattern = re.compile(r'\[⬇️\]\((https://arxiv\.org/pdf/\d+\.\d+)\)')
575
+ title_pattern = re.compile(r'### \d{2} \w{3} \d{4} \| \[(.*?)\]')
576
+ date_matches = date_pattern.findall(text)
577
+ abs_link_matches = abs_link_pattern.findall(text)
578
+ pdf_link_matches = pdf_link_pattern.findall(text)
579
+ title_matches = title_pattern.findall(text)
580
+
581
+ # markdown with the extracted fields
582
+ markdown_text = ""
583
+ for i in range(len(date_matches)):
584
+ date = date_matches[i]
585
+ title = title_matches[i]
586
+ abs_link = abs_link_matches[i][1]
587
+ pdf_link = pdf_link_matches[i]
588
+ markdown_text += f"**Date:** {date}\n\n"
589
+ markdown_text += f"**Title:** {title}\n\n"
590
+ markdown_text += f"**Abstract Link:** [{abs_link}]({abs_link})\n\n"
591
+ markdown_text += f"**PDF Link:** [{pdf_link}]({pdf_link})\n\n"
592
+ markdown_text += "---\n\n"
593
+ return markdown_text
594
+
595
+ except:
596
+ st.write('.')
597
+ return ''
598
+
599
+
600
+ # HTML5 based Speech Synthesis (Text to Speech in Browser)
601
+ @st.cache_resource
602
+ def SpeechSynthesis(result):
603
+ documentHTML5='''
604
+ <!DOCTYPE html>
605
+ <html>
606
+ <head>
607
+ <title>Read It Aloud</title>
608
+ <script type="text/javascript">
609
+ function readAloud() {
610
+ const text = document.getElementById("textArea").value;
611
+ const speech = new SpeechSynthesisUtterance(text);
612
+ window.speechSynthesis.speak(speech);
613
+ }
614
+ </script>
615
+ </head>
616
+ <body>
617
+ <h1>🔊 Read It Aloud</h1>
618
+ <textarea id="textArea" rows="10" cols="80">
619
+ '''
620
+ documentHTML5 = documentHTML5 + result
621
+ documentHTML5 = documentHTML5 + '''
622
+ </textarea>
623
+ <br>
624
+ <button onclick="readAloud()">🔊 Read Aloud</button>
625
+ </body>
626
+ </html>
627
+ '''
628
+ components.html(documentHTML5, width=1280, height=300)
629
+
630
+ def display_terms_with_links(terms):
631
+ """Display terms with various search links."""
632
+ search_urls = {
633
+ "📚📖ArXiv": lambda k: f"/?q={quote(k)}", # Academic/paper theme
634
+ "🔮<sup>Google</sup>": lambda k: f"https://www.google.com/search?q={quote(k)}", # Crystal ball for search
635
+ "📺<sup>Youtube</sup>": lambda k: f"https://www.youtube.com/results?search_query={quote(k)}", # TV for videos
636
+ "🔭<sup>Bing</sup>": lambda k: f"https://www.bing.com/search?q={quote(k)}", # Telescope for search
637
+ "💡<sup>Truth</sup>": lambda k: f"https://truthsocial.com/search?q={quote(k)}", # Light bulb for insight
638
+ "📱X": lambda k: f"https://twitter.com/search?q={quote(k)}", # Phone for social media
639
+ }
640
+ for term in terms:
641
+ links_md = ' '.join([f"[{emoji}]({url(term)})" for emoji, url in search_urls.items()])
642
+ st.markdown(f"- **{term}** {links_md}", unsafe_allow_html=True)
643
+
644
+ def search_arxiv(query):
645
+
646
+ st.write("Performing AI Lookup...")
647
+ client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
648
+
649
+ result1 = client.predict(
650
+ prompt=query,
651
+ llm_model_picked="mistralai/Mixtral-8x7B-Instruct-v0.1",
652
+ stream_outputs=True,
653
+ api_name="/ask_llm"
654
+ )
655
+ st.markdown("### Mixtral-8x7B-Instruct-v0.1 Result")
656
+ st.markdown(result1)
657
+
658
+ result2 = client.predict(
659
+ prompt=query,
660
+ llm_model_picked="mistralai/Mistral-7B-Instruct-v0.2",
661
+ stream_outputs=True,
662
+ api_name="/ask_llm"
663
+ )
664
+ st.markdown("### Mistral-7B-Instruct-v0.2 Result")
665
+ st.markdown(result2)
666
+ combined_result = f"{result1}\n\n{result2}"
667
+ #return combined_result
668
+
669
+ return responseall
670
+
671
+
672
+ def perform_ai_lookup(query):
673
+ start_time = time.strftime("%Y-%m-%d %H:%M:%S")
674
+ client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
675
+ response1 = client.predict(
676
+ query,
677
+ 20,
678
+ "Semantic Search",
679
+ "mistralai/Mixtral-8x7B-Instruct-v0.1",
680
+ api_name="/update_with_rag_md"
681
+ )
682
+ Question = '### 🔎 ' + query + '\r\n' # Format for markdown display with links
683
+ References = response1[0]
684
+ ReferenceLinks = extract_urls(References)
685
+
686
+ RunSecondQuery = True
687
+ results=''
688
+ if RunSecondQuery:
689
+ # Search 2 - Retrieve the Summary with Papers Context and Original Query
690
+ response2 = client.predict(
691
+ query,
692
+ "mistralai/Mixtral-8x7B-Instruct-v0.1",
693
+ True,
694
+ api_name="/ask_llm"
695
+ )
696
+ if len(response2) > 10:
697
+ Answer = response2
698
+ SpeechSynthesis(Answer)
699
+ # Restructure results to follow format of Question, Answer, References, ReferenceLinks
700
+ results = Question + '\r\n' + Answer + '\r\n' + References + '\r\n' + ReferenceLinks
701
+ st.markdown(results)
702
+
703
+ st.write('🔍Run of Multi-Agent System Paper Summary Spec is Complete')
704
+ end_time = time.strftime("%Y-%m-%d %H:%M:%S")
705
+ start_timestamp = time.mktime(time.strptime(start_time, "%Y-%m-%d %H:%M:%S"))
706
+ end_timestamp = time.mktime(time.strptime(end_time, "%Y-%m-%d %H:%M:%S"))
707
+ elapsed_seconds = end_timestamp - start_timestamp
708
+ st.write(f"Start time: {start_time}")
709
+ st.write(f"Finish time: {end_time}")
710
+ st.write(f"Elapsed time: {elapsed_seconds:.2f} seconds")
711
+ filename = generate_filename(query, "md")
712
+ create_file(filename, query, results, should_save)
713
+ return results
714
+
715
+ def display_file_content(file_path):
716
+ """Display file content with editing capabilities."""
717
+ try:
718
+ with open(file_path, 'r', encoding='utf-8') as f:
719
+ content = f.read()
720
+
721
+ if st.session_state.view_mode == 'view':
722
+ # Display as markdown when viewing
723
+ st.markdown(content)
724
+ else:
725
+ # Edit functionality
726
+ edited_content = st.text_area(
727
+ "Edit content",
728
+ content,
729
+ height=400,
730
+ key=f"edit_{os.path.basename(file_path)}"
731
+ )
732
+
733
+ if st.button("Save Changes", key=f"save_{os.path.basename(file_path)}"):
734
+ try:
735
+ with open(file_path, 'w', encoding='utf-8') as f:
736
+ f.write(edited_content)
737
+ st.success(f"Successfully saved changes to {file_path}")
738
+ except Exception as e:
739
+ st.error(f"Error saving changes: {e}")
740
+ except Exception as e:
741
+ st.error(f"Error reading file: {e}")
742
+
743
+ def file_management_sidebar():
744
+ """Redesigned sidebar with improved layout and additional functionality."""
745
+ st.sidebar.title("📁 File Management")
746
+
747
+ # Get list of .md files excluding README.md
748
+ md_files = [file for file in glob.glob("*.md") if file.lower() != 'readme.md']
749
+ md_files.sort()
750
+ st.session_state.files = md_files
751
+
752
+ if md_files:
753
+ st.sidebar.markdown("### Saved Files")
754
+ for idx, file in enumerate(md_files):
755
+ st.sidebar.markdown("---") # Separator between files
756
+
757
+ # Display time
758
+ st.sidebar.text(get_time_display(file))
759
+
760
+ # Display download link with simplified text
761
+ download_link = get_file_download_link(file)
762
+ if download_link:
763
+ st.sidebar.markdown(download_link, unsafe_allow_html=True)
764
+
765
+ # Action buttons in a row
766
+ col1, col2, col3, col4 = st.sidebar.columns(4)
767
+
768
+ with col1:
769
+ if st.button("📄 View", key=f"view_{idx}"):
770
+ st.session_state.selected_file = file
771
+ st.session_state.view_mode = 'view'
772
+
773
+ with col2:
774
+ if st.button("✏️ Edit", key=f"edit_{idx}"):
775
+ st.session_state.selected_file = file
776
+ st.session_state.view_mode = 'edit'
777
+
778
+ with col3:
779
+ if st.button("🔄 Rerun", key=f"rerun_{idx}"):
780
+ try:
781
+ with open(file, 'r', encoding='utf-8') as f:
782
+ content = f.read()
783
+
784
+ # Prepare the prompt with the prefix
785
+ 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:
786
+
787
+ """
788
+ full_prompt = rerun_prefix + content
789
+
790
+ # Perform AI lookup and save results
791
+ ai_result = perform_ai_lookup(full_prompt)
792
+ saved_file = save_ai_interaction(content, ai_result, is_rerun=True)
793
+
794
+ if saved_file:
795
+ st.success(f"Created fun version in {saved_file}")
796
+ st.session_state.selected_file = saved_file
797
+ st.session_state.view_mode = 'view'
798
+
799
+ except Exception as e:
800
+ st.error(f"Error during rerun: {e}")
801
+
802
+ with col4:
803
+ if st.button("🗑️ Delete", key=f"delete_{idx}"):
804
+ if delete_file(file):
805
+ st.success(f"Deleted {file}")
806
+ st.rerun()
807
+ else:
808
+ st.error(f"Failed to delete {file}")
809
+
810
+ st.sidebar.markdown("---")
811
+ # Option to create a new markdown file
812
+ if st.sidebar.button("📝 Create New Note"):
813
+ filename = generate_timestamp_filename("New Note")
814
+ with open(filename, 'w', encoding='utf-8') as f:
815
+ f.write("# New Markdown File\n")
816
+ st.sidebar.success(f"Created: {filename}")
817
+ st.session_state.selected_file = filename
818
+ st.session_state.view_mode = 'edit'
819
+ else:
820
+ st.sidebar.write("No markdown files found.")
821
+ if st.sidebar.button("📝 Create First Note"):
822
+ filename = generate_timestamp_filename("New Note")
823
+ with open(filename, 'w', encoding='utf-8') as f:
824
+ f.write("# New Markdown File\n")
825
+ st.sidebar.success(f"Created: {filename}")
826
+ st.session_state.selected_file = filename
827
+ st.session_state.view_mode = 'edit'
828
+
829
+ def main():
830
+ st.markdown("### AI Knowledge Tree Builder 🧠🌱 Cultivate Your AI Mindscape!")
831
+
832
+ # Process query parameters and AI lookup first
833
+ query_params = st.query_params
834
+ query = query_params.get('q', '')
835
+ show_initial_content = True # Flag to control initial content display
836
+
837
+ # First priority: Handle active query
838
+ if query:
839
+ show_initial_content = False # Hide initial content when showing query results
840
+ st.write(f"### Search query received: {query}")
841
+ try:
842
+ ai_result = perform_ai_lookup(query)
843
+
844
+ # Save the interaction
845
+ saved_file = save_ai_interaction(query, ai_result)
846
+ if saved_file:
847
+ st.success(f"Saved interaction to {saved_file}")
848
+ st.session_state.selected_file = saved_file
849
+ st.session_state.view_mode = 'view'
850
+ except Exception as e:
851
+ st.error(f"Error during AI lookup: {e}")
852
+
853
+ # File management sidebar
854
+ file_management_sidebar()
855
+
856
+ # Second priority: Display selected file content if any
857
+ if st.session_state.selected_file:
858
+ show_initial_content = False # Hide initial content when showing file content
859
+ if os.path.exists(st.session_state.selected_file):
860
+ st.markdown(f"### Current File: {st.session_state.selected_file}")
861
+ display_file_content(st.session_state.selected_file)
862
+ else:
863
+ st.error("Selected file no longer exists.")
864
+ st.session_state.selected_file = None
865
+ st.rerun()
866
+
867
+ # Show initial content: Either when first landing or when no interactive elements are active
868
+ if show_initial_content:
869
+ # First show the clickable terms with links
870
+ terms1 = extract_terms(AITopicsToInnovate1)
871
+ terms2 = extract_terms(Multiplayer_Custom_Hosting_Game_Servers_For_Simulated_Worlds)
872
+ terms3 = extract_terms(BiologyAndLevel36MagicUsers)
873
+
874
+ all_terms = terms1 + terms2 + terms3
875
+
876
+ col1, col2, col3, col4, col5, col6 = st.columns(6)
877
+
878
+ with col1:
879
+ st.markdown("#### AI Topics to Innovate With")
880
+ st.markdown(AITopicsToInnovate1)
881
+ with col2:
882
+ st.markdown("#### AI Agent Links")
883
+ display_terms_with_links(terms1)
884
+ with col3:
885
+ st.markdown("#### Biology Innovation with Data Science and AI Solutions")
886
+ st.markdown(BiologyAndLevel36MagicUsers)
887
+ with col4:
888
+ st.markdown("#### Biology Innovation Agent Links")
889
+ display_terms_with_links(terms3)
890
+ with col5:
891
+ st.markdown("#### Multiplayer Games and MMOs")
892
+ st.markdown(Multiplayer_Custom_Hosting_Game_Servers_For_Simulated_Worlds)
893
+ with col6:
894
+ st.markdown("#### Multiplayer Game and MMO Links")
895
+ display_terms_with_links(terms2)
896
+
897
+ if __name__ == "__main__":
898
+ main()