oceansweep commited on
Commit
e04fa0c
1 Parent(s): 1625729

Update App_Function_Libraries/Gradio_Related.py

Browse files
Files changed (1) hide show
  1. App_Function_Libraries/Gradio_Related.py +599 -600
App_Function_Libraries/Gradio_Related.py CHANGED
@@ -1,600 +1,599 @@
1
- # Gradio_Related.py
2
- #########################################
3
- # Gradio UI Functions Library
4
- # I fucking hate Gradio.
5
- #
6
- #########################################
7
- #
8
- # Built-In Imports
9
- import logging
10
- import os
11
- import webbrowser
12
- #
13
- # Import 3rd-Party Libraries
14
- import gradio as gr
15
- #
16
- # Local Imports
17
- from App_Function_Libraries.DB.DB_Manager import get_db_config, backup_dir
18
- from App_Function_Libraries.DB.RAG_QA_Chat_DB import create_tables
19
- from App_Function_Libraries.Gradio_UI.Anki_tab import create_anki_validation_tab, create_anki_generator_tab
20
- from App_Function_Libraries.Gradio_UI.Arxiv_tab import create_arxiv_tab
21
- from App_Function_Libraries.Gradio_UI.Audio_ingestion_tab import create_audio_processing_tab
22
- from App_Function_Libraries.Gradio_UI.Backup_RAG_Notes_Character_Chat_tab import create_database_management_interface
23
- from App_Function_Libraries.Gradio_UI.Book_Ingestion_tab import create_import_book_tab
24
- from App_Function_Libraries.Gradio_UI.Character_Chat_tab import create_character_card_interaction_tab, create_character_chat_mgmt_tab, create_custom_character_card_tab, \
25
- create_character_card_validation_tab, create_export_characters_tab
26
- from App_Function_Libraries.Gradio_UI.Character_interaction_tab import create_narrator_controlled_conversation_tab, \
27
- create_multiple_character_chat_tab
28
- from App_Function_Libraries.Gradio_UI.Chat_ui import create_chat_interface_four, create_chat_interface_multi_api, \
29
- create_chat_interface_stacked, create_chat_interface
30
- from App_Function_Libraries.Gradio_UI.Config_tab import create_config_editor_tab
31
- from App_Function_Libraries.Gradio_UI.Explain_summarize_tab import create_summarize_explain_tab
32
- from App_Function_Libraries.Gradio_UI.Export_Functionality import create_rag_export_tab, create_export_tabs
33
- #from App_Function_Libraries.Gradio_UI.Backup_Functionality import create_backup_tab, create_view_backups_tab, \
34
- # create_restore_backup_tab
35
- from App_Function_Libraries.Gradio_UI.Import_Functionality import create_import_single_prompt_tab, \
36
- create_import_obsidian_vault_tab, create_import_item_tab, create_import_multiple_prompts_tab, \
37
- create_conversation_import_tab
38
- from App_Function_Libraries.Gradio_UI.Introduction_tab import create_introduction_tab
39
- from App_Function_Libraries.Gradio_UI.Keywords import create_view_keywords_tab, create_add_keyword_tab, \
40
- create_delete_keyword_tab, create_export_keywords_tab, create_rag_qa_keywords_tab, create_character_keywords_tab, \
41
- create_meta_keywords_tab, create_prompt_keywords_tab
42
- from App_Function_Libraries.Gradio_UI.Live_Recording import create_live_recording_tab
43
- from App_Function_Libraries.Gradio_UI.Llamafile_tab import create_chat_with_llamafile_tab
44
- #from App_Function_Libraries.Gradio_UI.MMLU_Pro_tab import create_mmlu_pro_tab
45
- from App_Function_Libraries.Gradio_UI.Media_edit import create_prompt_clone_tab, create_prompt_edit_tab, \
46
- create_media_edit_and_clone_tab, create_media_edit_tab
47
- from App_Function_Libraries.Gradio_UI.Media_wiki_tab import create_mediawiki_import_tab, create_mediawiki_config_tab
48
- from App_Function_Libraries.Gradio_UI.Mind_Map_tab import create_mindmap_tab
49
- from App_Function_Libraries.Gradio_UI.PDF_ingestion_tab import create_pdf_ingestion_tab, create_pdf_ingestion_test_tab
50
- from App_Function_Libraries.Gradio_UI.Plaintext_tab_import import create_plain_text_import_tab
51
- from App_Function_Libraries.Gradio_UI.Podcast_tab import create_podcast_tab
52
- from App_Function_Libraries.Gradio_UI.Prompt_Suggestion_tab import create_prompt_suggestion_tab
53
- from App_Function_Libraries.Gradio_UI.RAG_QA_Chat_tab import create_rag_qa_chat_tab, create_rag_qa_notes_management_tab, \
54
- create_rag_qa_chat_management_tab
55
- from App_Function_Libraries.Gradio_UI.Re_summarize_tab import create_resummary_tab
56
- from App_Function_Libraries.Gradio_UI.Search_Tab import create_prompt_search_tab, \
57
- create_search_summaries_tab, create_search_tab
58
- from App_Function_Libraries.Gradio_UI.RAG_Chat_tab import create_rag_tab
59
- from App_Function_Libraries.Gradio_UI.Embeddings_tab import create_embeddings_tab, create_view_embeddings_tab, \
60
- create_purge_embeddings_tab
61
- from App_Function_Libraries.Gradio_UI.Semantic_Scholar_tab import create_semantic_scholar_tab
62
- from App_Function_Libraries.Gradio_UI.Trash import create_view_trash_tab, create_empty_trash_tab, \
63
- create_delete_trash_tab, create_search_and_mark_trash_tab
64
- from App_Function_Libraries.Gradio_UI.Utilities import create_utilities_yt_timestamp_tab, create_utilities_yt_audio_tab, \
65
- create_utilities_yt_video_tab
66
- from App_Function_Libraries.Gradio_UI.Video_transcription_tab import create_video_transcription_tab
67
- from App_Function_Libraries.Gradio_UI.View_tab import create_manage_items_tab
68
- from App_Function_Libraries.Gradio_UI.Website_scraping_tab import create_website_scraping_tab
69
- from App_Function_Libraries.Gradio_UI.Workflows_tab import chat_workflows_tab
70
- from App_Function_Libraries.Gradio_UI.View_DB_Items_tab import create_view_all_mediadb_with_versions_tab, \
71
- create_viewing_mediadb_tab, create_view_all_rag_notes_tab, create_viewing_ragdb_tab, \
72
- create_mediadb_keyword_search_tab, create_ragdb_keyword_items_tab
73
- from App_Function_Libraries.Gradio_UI.Prompts_tab import create_prompt_view_tab, create_prompts_export_tab
74
- #
75
- # Gradio UI Imports
76
- from App_Function_Libraries.Gradio_UI.Evaluations_Benchmarks_tab import create_geval_tab, create_infinite_bench_tab
77
- from App_Function_Libraries.Gradio_UI.XML_Ingestion_Tab import create_xml_import_tab
78
- #from App_Function_Libraries.Local_LLM.Local_LLM_huggingface import create_huggingface_tab
79
- from App_Function_Libraries.Local_LLM.Local_LLM_ollama import create_ollama_tab
80
- from App_Function_Libraries.Utils.Utils import load_and_log_configs
81
-
82
- #
83
- #######################################################################################################################
84
- # Function Definitions
85
- #
86
-
87
-
88
- # Disable Gradio Analytics
89
- os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
90
-
91
-
92
- custom_prompt_input = None
93
- server_mode = False
94
- share_public = False
95
- custom_prompt_summarize_bulleted_notes = ("""
96
- <s>You are a bulleted notes specialist. [INST]```When creating comprehensive bulleted notes, you should follow these guidelines: Use multiple headings based on the referenced topics, not categories like quotes or terms. Headings should be surrounded by bold formatting and not be listed as bullet points themselves. Leave no space between headings and their corresponding list items underneath. Important terms within the content should be emphasized by setting them in bold font. Any text that ends with a colon should also be bolded. Before submitting your response, review the instructions, and make any corrections necessary to adhered to the specified format. Do not reference these instructions within the notes.``` \nBased on the content between backticks create comprehensive bulleted notes.[/INST]
97
- **Bulleted Note Creation Guidelines**
98
-
99
- **Headings**:
100
- - Based on referenced topics, not categories like quotes or terms
101
- - Surrounded by **bold** formatting
102
- - Not listed as bullet points
103
- - No space between headings and list items underneath
104
-
105
- **Emphasis**:
106
- - **Important terms** set in bold font
107
- - **Text ending in a colon**: also bolded
108
-
109
- **Review**:
110
- - Ensure adherence to specified format
111
- - Do not reference these instructions in your response.</s>[INST] {{ .Prompt }} [/INST]
112
- """)
113
- #
114
- # End of globals
115
- #######################################################################################################################
116
- #
117
- # Start of Video/Audio Transcription and Summarization Functions
118
- #
119
- # Functions:
120
- # FIXME
121
- #
122
- #
123
- ################################################################################################################
124
- # Functions for Re-Summarization
125
- #
126
- # Functions:
127
- # FIXME
128
- # End of Re-Summarization Functions
129
- #
130
- ############################################################################################################################################################################################################################
131
- #
132
- # Explain/Summarize This Tab
133
- #
134
- # Functions:
135
- # FIXME
136
- #
137
- #
138
- ############################################################################################################################################################################################################################
139
- #
140
- # Transcript Comparison Tab
141
- #
142
- # Functions:
143
- # FIXME
144
- #
145
- #
146
- ###########################################################################################################################################################################################################################
147
- #
148
- # Search Tab
149
- #
150
- # Functions:
151
- # FIXME
152
- #
153
- # End of Search Tab Functions
154
- #
155
- ##############################################################################################################################################################################################################################
156
- #
157
- # Llamafile Tab
158
- #
159
- # Functions:
160
- # FIXME
161
- #
162
- # End of Llamafile Tab Functions
163
- ##############################################################################################################################################################################################################################
164
- #
165
- # Chat Interface Tab Functions
166
- #
167
- # Functions:
168
- # FIXME
169
- #
170
- #
171
- # End of Chat Interface Tab Functions
172
- ################################################################################################################################################################################################################################
173
- #
174
- # Media Edit Tab Functions
175
- # Functions:
176
- # Fixme
177
- # create_media_edit_tab():
178
- ##### Trash Tab
179
- # FIXME
180
- # Functions:
181
- #
182
- # End of Media Edit Tab Functions
183
- ################################################################################################################
184
- #
185
- # Import Items Tab Functions
186
- #
187
- # Functions:
188
- #FIXME
189
- # End of Import Items Tab Functions
190
- ################################################################################################################
191
- #
192
- # Export Items Tab Functions
193
- #
194
- # Functions:
195
- # FIXME
196
- #
197
- #
198
- # End of Export Items Tab Functions
199
- ################################################################################################################
200
- #
201
- # Keyword Management Tab Functions
202
- #
203
- # Functions:
204
- # create_view_keywords_tab():
205
- # FIXME
206
- #
207
- # End of Keyword Management Tab Functions
208
- ################################################################################################################
209
- #
210
- # Document Editing Tab Functions
211
- #
212
- # Functions:
213
- # #FIXME
214
- #
215
- #
216
- ################################################################################################################
217
- #
218
- # Utilities Tab Functions
219
- # Functions:
220
- # create_utilities_yt_video_tab():
221
- # #FIXME
222
-
223
- #
224
- # End of Utilities Tab Functions
225
- ################################################################################################################
226
-
227
- # FIXME - Prompt sample box
228
- #
229
- # # Sample data
230
- # prompts_category_1 = [
231
- # "What are the key points discussed in the video?",
232
- # "Summarize the main arguments made by the speaker.",
233
- # "Describe the conclusions of the study presented."
234
- # ]
235
- #
236
- # prompts_category_2 = [
237
- # "How does the proposed solution address the problem?",
238
- # "What are the implications of the findings?",
239
- # "Can you explain the theory behind the observed phenomenon?"
240
- # ]
241
- #
242
- # all_prompts2 = prompts_category_1 + prompts_category_2
243
-
244
-
245
-
246
- #######################################################################################################################
247
- #
248
- # Migration Script
249
- import sqlite3
250
- import uuid
251
- import logging
252
- import os
253
- from datetime import datetime
254
- import shutil
255
-
256
- # def migrate_media_db_to_rag_chat_db(media_db_path, rag_chat_db_path):
257
- # # Check if migration is needed
258
- # if not os.path.exists(media_db_path):
259
- # logging.info("Media DB does not exist. No migration needed.")
260
- # return
261
- #
262
- # # Optional: Check if migration has already been completed
263
- # migration_flag = os.path.join(os.path.dirname(rag_chat_db_path), 'migration_completed.flag')
264
- # if os.path.exists(migration_flag):
265
- # logging.info("Migration already completed. Skipping migration.")
266
- # return
267
- #
268
- # # Backup databases
269
- # backup_database(media_db_path)
270
- # backup_database(rag_chat_db_path)
271
- #
272
- # # Connect to both databases
273
- # try:
274
- # media_conn = sqlite3.connect(media_db_path)
275
- # rag_conn = sqlite3.connect(rag_chat_db_path)
276
- #
277
- # # Enable foreign key support
278
- # media_conn.execute('PRAGMA foreign_keys = ON;')
279
- # rag_conn.execute('PRAGMA foreign_keys = ON;')
280
- #
281
- # media_cursor = media_conn.cursor()
282
- # rag_cursor = rag_conn.cursor()
283
- #
284
- # # Begin transaction
285
- # rag_conn.execute('BEGIN TRANSACTION;')
286
- #
287
- # # Extract conversations from media DB
288
- # media_cursor.execute('''
289
- # SELECT id, media_id, media_name, conversation_name, created_at, updated_at
290
- # FROM ChatConversations
291
- # ''')
292
- # conversations = media_cursor.fetchall()
293
- #
294
- # for conv in conversations:
295
- # old_conv_id, media_id, media_name, conversation_name, created_at, updated_at = conv
296
- #
297
- # # Convert timestamps if necessary
298
- # created_at = parse_timestamp(created_at)
299
- # updated_at = parse_timestamp(updated_at)
300
- #
301
- # # Generate a new conversation_id
302
- # conversation_id = str(uuid.uuid4())
303
- # title = conversation_name or (f"{media_name}-chat" if media_name else "Untitled Conversation")
304
- #
305
- # # Insert into conversation_metadata
306
- # rag_cursor.execute('''
307
- # INSERT INTO conversation_metadata (conversation_id, created_at, last_updated, title, media_id)
308
- # VALUES (?, ?, ?, ?, ?)
309
- # ''', (conversation_id, created_at, updated_at, title, media_id))
310
- #
311
- # # Extract messages from media DB
312
- # media_cursor.execute('''
313
- # SELECT sender, message, timestamp
314
- # FROM ChatMessages
315
- # WHERE conversation_id = ?
316
- # ORDER BY timestamp ASC
317
- # ''', (old_conv_id,))
318
- # messages = media_cursor.fetchall()
319
- #
320
- # for msg in messages:
321
- # sender, content, timestamp = msg
322
- #
323
- # # Convert timestamp if necessary
324
- # timestamp = parse_timestamp(timestamp)
325
- #
326
- # role = sender # Assuming 'sender' is 'user' or 'ai'
327
- #
328
- # # Insert message into rag_qa_chats
329
- # rag_cursor.execute('''
330
- # INSERT INTO rag_qa_chats (conversation_id, timestamp, role, content)
331
- # VALUES (?, ?, ?, ?)
332
- # ''', (conversation_id, timestamp, role, content))
333
- #
334
- # # Commit transaction
335
- # rag_conn.commit()
336
- # logging.info("Migration completed successfully.")
337
- #
338
- # # Mark migration as complete
339
- # with open(migration_flag, 'w') as f:
340
- # f.write('Migration completed on ' + datetime.now().isoformat())
341
- #
342
- # except Exception as e:
343
- # # Rollback transaction in case of error
344
- # rag_conn.rollback()
345
- # logging.error(f"Error during migration: {e}")
346
- # raise
347
- # finally:
348
- # media_conn.close()
349
- # rag_conn.close()
350
-
351
- def backup_database(db_path):
352
- backup_path = db_path + '.backup'
353
- if not os.path.exists(backup_path):
354
- shutil.copyfile(db_path, backup_path)
355
- logging.info(f"Database backed up to {backup_path}")
356
- else:
357
- logging.info(f"Backup already exists at {backup_path}")
358
-
359
- def parse_timestamp(timestamp_value):
360
- """
361
- Parses the timestamp from the old database and converts it to a standard format.
362
- Adjust this function based on the actual format of your timestamps.
363
- """
364
- try:
365
- # Attempt to parse ISO format
366
- return datetime.fromisoformat(timestamp_value).isoformat()
367
- except ValueError:
368
- # Handle other timestamp formats if necessary
369
- # For example, if timestamps are in Unix epoch format
370
- try:
371
- timestamp_float = float(timestamp_value)
372
- return datetime.fromtimestamp(timestamp_float).isoformat()
373
- except ValueError:
374
- # Default to current time if parsing fails
375
- logging.warning(f"Unable to parse timestamp '{timestamp_value}', using current time.")
376
- return datetime.now().isoformat()
377
-
378
- #
379
- # End of Migration Script
380
- #######################################################################################################################
381
-
382
-
383
- #######################################################################################################################
384
- #
385
- # Launch UI Function
386
- def launch_ui(share_public=None, server_mode=False):
387
- webbrowser.open_new_tab('http://127.0.0.1:7860/?__theme=dark')
388
- share=share_public
389
- css = """
390
- .result-box {
391
- margin-bottom: 20px;
392
- border: 1px solid #ddd;
393
- padding: 10px;
394
- }
395
- .result-box.error {
396
- border-color: #ff0000;
397
- background-color: #ffeeee;
398
- }
399
- .transcription, .summary {
400
- max-height: 800px;
401
- overflow-y: auto;
402
- border: 1px solid #eee;
403
- padding: 10px;
404
- margin-top: 10px;
405
- }
406
- """
407
-
408
- config = load_and_log_configs()
409
- # Get database paths from config
410
- db_config = config['db_config']
411
- media_db_path = db_config['sqlite_path']
412
- character_chat_db_path = os.path.join(os.path.dirname(media_db_path), "chatDB.db")
413
- rag_chat_db_path = os.path.join(os.path.dirname(media_db_path), "rag_qa.db")
414
- # Initialize the RAG Chat DB (create tables and update schema)
415
- create_tables()
416
-
417
- # Migrate data from the media DB to the RAG Chat DB
418
- #migrate_media_db_to_rag_chat_db(media_db_path, rag_chat_db_path)
419
-
420
-
421
- with gr.Blocks(theme='bethecloud/storj_theme',css=css) as iface:
422
- gr.HTML(
423
- """
424
- <script>
425
- document.addEventListener('DOMContentLoaded', (event) => {
426
- document.body.classList.add('dark');
427
- document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)';
428
- });
429
- </script>
430
- """
431
- )
432
- db_config = get_db_config()
433
- db_type = db_config['type']
434
- gr.Markdown(f"# tl/dw: Your LLM-powered Research Multi-tool")
435
- gr.Markdown(f"(Using {db_type.capitalize()} Database)")
436
- with gr.Tabs():
437
- with gr.TabItem("Transcribe / Analyze / Ingestion", id="ingestion-grouping", visible=True):
438
- with gr.Tabs():
439
- create_video_transcription_tab()
440
- create_audio_processing_tab()
441
- create_podcast_tab()
442
- create_import_book_tab()
443
- create_plain_text_import_tab()
444
- create_xml_import_tab()
445
- create_website_scraping_tab()
446
- create_pdf_ingestion_tab()
447
- create_pdf_ingestion_test_tab()
448
- create_resummary_tab()
449
- create_summarize_explain_tab()
450
- create_live_recording_tab()
451
- create_arxiv_tab()
452
- create_semantic_scholar_tab()
453
-
454
- with gr.TabItem("RAG Chat/Search", id="RAG Chat Notes group", visible=True):
455
- create_rag_tab()
456
- create_rag_qa_chat_tab()
457
- create_rag_qa_notes_management_tab()
458
- create_rag_qa_chat_management_tab()
459
-
460
- with gr.TabItem("Chat with an LLM", id="LLM Chat group", visible=True):
461
- create_chat_interface()
462
- create_chat_interface_stacked()
463
- create_chat_interface_multi_api()
464
- create_chat_interface_four()
465
- chat_workflows_tab()
466
-
467
- with gr.TabItem("Character Chat", id="character chat group", visible=True):
468
- create_character_card_interaction_tab()
469
- create_character_chat_mgmt_tab()
470
- create_custom_character_card_tab()
471
- create_character_card_validation_tab()
472
- create_multiple_character_chat_tab()
473
- create_narrator_controlled_conversation_tab()
474
- create_export_characters_tab()
475
-
476
- with gr.TabItem("Writing Tools", id="writing_tools group", visible=True):
477
- from App_Function_Libraries.Gradio_UI.Writing_tab import create_document_feedback_tab
478
- create_document_feedback_tab()
479
- from App_Function_Libraries.Gradio_UI.Writing_tab import create_grammar_style_check_tab
480
- create_grammar_style_check_tab()
481
- from App_Function_Libraries.Gradio_UI.Writing_tab import create_tone_adjustment_tab
482
- create_tone_adjustment_tab()
483
- from App_Function_Libraries.Gradio_UI.Writing_tab import create_creative_writing_tab
484
- create_creative_writing_tab()
485
- from App_Function_Libraries.Gradio_UI.Writing_tab import create_mikupad_tab
486
- create_mikupad_tab()
487
-
488
- with gr.TabItem("Search/View DB Items", id="view db items group", visible=True):
489
- create_search_tab()
490
- create_search_summaries_tab()
491
- create_view_all_mediadb_with_versions_tab()
492
- create_viewing_mediadb_tab()
493
- create_mediadb_keyword_search_tab()
494
- create_view_all_rag_notes_tab()
495
- create_viewing_ragdb_tab()
496
- create_ragdb_keyword_items_tab()
497
-
498
- with gr.TabItem("Prompts", id='view prompts group', visible=True):
499
- with gr.Tabs():
500
- create_prompt_view_tab()
501
- create_prompt_search_tab()
502
- create_prompt_edit_tab()
503
- create_prompt_clone_tab()
504
- create_prompt_suggestion_tab()
505
- create_prompts_export_tab()
506
-
507
- with gr.TabItem("Manage Media DB Items", id="manage group", visible=True):
508
- create_media_edit_tab()
509
- create_manage_items_tab()
510
- create_media_edit_and_clone_tab()
511
-
512
- with gr.TabItem("Embeddings Management", id="embeddings group", visible=True):
513
- create_embeddings_tab()
514
- create_view_embeddings_tab()
515
- create_purge_embeddings_tab()
516
-
517
- with gr.TabItem("Keywords", id="keywords group", visible=True):
518
- create_view_keywords_tab()
519
- create_add_keyword_tab()
520
- create_delete_keyword_tab()
521
- create_export_keywords_tab()
522
- create_character_keywords_tab()
523
- create_rag_qa_keywords_tab()
524
- create_meta_keywords_tab()
525
- create_prompt_keywords_tab()
526
-
527
- with gr.TabItem("Import", id="import group", visible=True):
528
- create_import_item_tab()
529
- create_import_obsidian_vault_tab()
530
- create_import_single_prompt_tab()
531
- create_import_multiple_prompts_tab()
532
- create_mediawiki_import_tab()
533
- create_mediawiki_config_tab()
534
- create_conversation_import_tab()
535
-
536
- with gr.TabItem("Export", id="export group", visible=True):
537
- create_export_tabs()
538
-
539
-
540
- with gr.TabItem("Database Management", id="database_management_group", visible=True):
541
- create_database_management_interface(
542
- media_db_config={
543
- 'db_path': media_db_path,
544
- 'backup_dir': backup_dir
545
- },
546
- rag_db_config={
547
- 'db_path': rag_chat_db_path,
548
- 'backup_dir': backup_dir
549
- },
550
- char_db_config={
551
- 'db_path': character_chat_db_path,
552
- 'backup_dir': backup_dir
553
- }
554
- )
555
-
556
- with gr.TabItem("Utilities", id="util group", visible=True):
557
- create_mindmap_tab()
558
- create_utilities_yt_video_tab()
559
- create_utilities_yt_audio_tab()
560
- create_utilities_yt_timestamp_tab()
561
-
562
- with gr.TabItem("Anki Deck Creation/Validation", id="anki group", visible=True):
563
- create_anki_generator_tab()
564
- create_anki_validation_tab()
565
-
566
- with gr.TabItem("Local LLM", id="local llm group", visible=True):
567
- create_chat_with_llamafile_tab()
568
- create_ollama_tab()
569
- #create_huggingface_tab()
570
-
571
- with gr.TabItem("Trashcan", id="trashcan group", visible=True):
572
- create_search_and_mark_trash_tab()
573
- create_view_trash_tab()
574
- create_delete_trash_tab()
575
- create_empty_trash_tab()
576
-
577
- with gr.TabItem("Evaluations", id="eval", visible=True):
578
- create_geval_tab()
579
- create_infinite_bench_tab()
580
- # FIXME
581
- #create_mmlu_pro_tab()
582
-
583
- with gr.TabItem("Introduction/Help", id="introduction group", visible=True):
584
- create_introduction_tab()
585
-
586
- with gr.TabItem("Config Editor", id="config group"):
587
- create_config_editor_tab()
588
-
589
- # Launch the interface
590
- server_port_variable = 7860
591
- os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
592
- if share==True:
593
- iface.launch(share=True)
594
- elif server_mode and not share_public:
595
- iface.launch(share=False, server_name="0.0.0.0", server_port=server_port_variable, )
596
- else:
597
- try:
598
- iface.launch(share=False, server_name="0.0.0.0", server_port=server_port_variable, )
599
- except Exception as e:
600
- logging.error(f"Error launching interface: {str(e)}")
 
1
+ # Gradio_Related.py
2
+ #########################################
3
+ # Gradio UI Functions Library
4
+ # I fucking hate Gradio.
5
+ #
6
+ #########################################
7
+ #
8
+ # Built-In Imports
9
+ import logging
10
+ import os
11
+ import webbrowser
12
+ #
13
+ # Import 3rd-Party Libraries
14
+ import gradio as gr
15
+ #
16
+ # Local Imports
17
+ from App_Function_Libraries.DB.DB_Manager import get_db_config, backup_dir
18
+ from App_Function_Libraries.DB.RAG_QA_Chat_DB import create_tables
19
+ from App_Function_Libraries.Gradio_UI.Anki_tab import create_anki_validation_tab, create_anki_generator_tab
20
+ from App_Function_Libraries.Gradio_UI.Arxiv_tab import create_arxiv_tab
21
+ from App_Function_Libraries.Gradio_UI.Audio_ingestion_tab import create_audio_processing_tab
22
+ from App_Function_Libraries.Gradio_UI.Backup_RAG_Notes_Character_Chat_tab import create_database_management_interface
23
+ from App_Function_Libraries.Gradio_UI.Book_Ingestion_tab import create_import_book_tab
24
+ from App_Function_Libraries.Gradio_UI.Character_Chat_tab import create_character_card_interaction_tab, create_character_chat_mgmt_tab, create_custom_character_card_tab, \
25
+ create_character_card_validation_tab, create_export_characters_tab
26
+ from App_Function_Libraries.Gradio_UI.Character_interaction_tab import create_narrator_controlled_conversation_tab, \
27
+ create_multiple_character_chat_tab
28
+ from App_Function_Libraries.Gradio_UI.Chat_ui import create_chat_interface_four, create_chat_interface_multi_api, \
29
+ create_chat_interface_stacked, create_chat_interface
30
+ from App_Function_Libraries.Gradio_UI.Config_tab import create_config_editor_tab
31
+ from App_Function_Libraries.Gradio_UI.Explain_summarize_tab import create_summarize_explain_tab
32
+ from App_Function_Libraries.Gradio_UI.Export_Functionality import create_rag_export_tab, create_export_tabs
33
+ #from App_Function_Libraries.Gradio_UI.Backup_Functionality import create_backup_tab, create_view_backups_tab, \
34
+ # create_restore_backup_tab
35
+ from App_Function_Libraries.Gradio_UI.Import_Functionality import create_import_single_prompt_tab, \
36
+ create_import_obsidian_vault_tab, create_import_item_tab, create_import_multiple_prompts_tab, \
37
+ create_conversation_import_tab
38
+ from App_Function_Libraries.Gradio_UI.Introduction_tab import create_introduction_tab
39
+ from App_Function_Libraries.Gradio_UI.Keywords import create_view_keywords_tab, create_add_keyword_tab, \
40
+ create_delete_keyword_tab, create_export_keywords_tab, create_rag_qa_keywords_tab, create_character_keywords_tab, \
41
+ create_meta_keywords_tab, create_prompt_keywords_tab
42
+ from App_Function_Libraries.Gradio_UI.Live_Recording import create_live_recording_tab
43
+ from App_Function_Libraries.Gradio_UI.Llamafile_tab import create_chat_with_llamafile_tab
44
+ #from App_Function_Libraries.Gradio_UI.MMLU_Pro_tab import create_mmlu_pro_tab
45
+ from App_Function_Libraries.Gradio_UI.Media_edit import create_prompt_clone_tab, create_prompt_edit_tab, \
46
+ create_media_edit_and_clone_tab, create_media_edit_tab
47
+ from App_Function_Libraries.Gradio_UI.Media_wiki_tab import create_mediawiki_import_tab, create_mediawiki_config_tab
48
+ from App_Function_Libraries.Gradio_UI.Mind_Map_tab import create_mindmap_tab
49
+ from App_Function_Libraries.Gradio_UI.PDF_ingestion_tab import create_pdf_ingestion_tab, create_pdf_ingestion_test_tab
50
+ from App_Function_Libraries.Gradio_UI.Plaintext_tab_import import create_plain_text_import_tab
51
+ from App_Function_Libraries.Gradio_UI.Podcast_tab import create_podcast_tab
52
+ from App_Function_Libraries.Gradio_UI.Prompt_Suggestion_tab import create_prompt_suggestion_tab
53
+ from App_Function_Libraries.Gradio_UI.RAG_QA_Chat_tab import create_rag_qa_chat_tab, create_rag_qa_notes_management_tab, \
54
+ create_rag_qa_chat_management_tab
55
+ from App_Function_Libraries.Gradio_UI.Re_summarize_tab import create_resummary_tab
56
+ from App_Function_Libraries.Gradio_UI.Search_Tab import create_prompt_search_tab, \
57
+ create_search_summaries_tab, create_search_tab
58
+ from App_Function_Libraries.Gradio_UI.RAG_Chat_tab import create_rag_tab
59
+ from App_Function_Libraries.Gradio_UI.Embeddings_tab import create_embeddings_tab, create_view_embeddings_tab, \
60
+ create_purge_embeddings_tab
61
+ from App_Function_Libraries.Gradio_UI.Semantic_Scholar_tab import create_semantic_scholar_tab
62
+ from App_Function_Libraries.Gradio_UI.Trash import create_view_trash_tab, create_empty_trash_tab, \
63
+ create_delete_trash_tab, create_search_and_mark_trash_tab
64
+ from App_Function_Libraries.Gradio_UI.Utilities import create_utilities_yt_timestamp_tab, create_utilities_yt_audio_tab, \
65
+ create_utilities_yt_video_tab
66
+ from App_Function_Libraries.Gradio_UI.Video_transcription_tab import create_video_transcription_tab
67
+ from App_Function_Libraries.Gradio_UI.View_tab import create_manage_items_tab
68
+ from App_Function_Libraries.Gradio_UI.Website_scraping_tab import create_website_scraping_tab
69
+ from App_Function_Libraries.Gradio_UI.Workflows_tab import chat_workflows_tab
70
+ from App_Function_Libraries.Gradio_UI.View_DB_Items_tab import create_view_all_mediadb_with_versions_tab, \
71
+ create_viewing_mediadb_tab, create_view_all_rag_notes_tab, create_viewing_ragdb_tab, \
72
+ create_mediadb_keyword_search_tab, create_ragdb_keyword_items_tab
73
+ from App_Function_Libraries.Gradio_UI.Prompts_tab import create_prompt_view_tab, create_prompts_export_tab
74
+ #
75
+ # Gradio UI Imports
76
+ from App_Function_Libraries.Gradio_UI.Evaluations_Benchmarks_tab import create_geval_tab, create_infinite_bench_tab
77
+ from App_Function_Libraries.Gradio_UI.XML_Ingestion_Tab import create_xml_import_tab
78
+ #from App_Function_Libraries.Local_LLM.Local_LLM_huggingface import create_huggingface_tab
79
+ from App_Function_Libraries.Local_LLM.Local_LLM_ollama import create_ollama_tab
80
+ from App_Function_Libraries.Utils.Utils import load_and_log_configs
81
+
82
+ #
83
+ #######################################################################################################################
84
+ # Function Definitions
85
+ #
86
+
87
+
88
+ # Disable Gradio Analytics
89
+ os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
90
+
91
+
92
+ custom_prompt_input = None
93
+ server_mode = False
94
+ share_public = False
95
+ custom_prompt_summarize_bulleted_notes = ("""
96
+ <s>You are a bulleted notes specialist. [INST]```When creating comprehensive bulleted notes, you should follow these guidelines: Use multiple headings based on the referenced topics, not categories like quotes or terms. Headings should be surrounded by bold formatting and not be listed as bullet points themselves. Leave no space between headings and their corresponding list items underneath. Important terms within the content should be emphasized by setting them in bold font. Any text that ends with a colon should also be bolded. Before submitting your response, review the instructions, and make any corrections necessary to adhered to the specified format. Do not reference these instructions within the notes.``` \nBased on the content between backticks create comprehensive bulleted notes.[/INST]
97
+ **Bulleted Note Creation Guidelines**
98
+
99
+ **Headings**:
100
+ - Based on referenced topics, not categories like quotes or terms
101
+ - Surrounded by **bold** formatting
102
+ - Not listed as bullet points
103
+ - No space between headings and list items underneath
104
+
105
+ **Emphasis**:
106
+ - **Important terms** set in bold font
107
+ - **Text ending in a colon**: also bolded
108
+
109
+ **Review**:
110
+ - Ensure adherence to specified format
111
+ - Do not reference these instructions in your response.</s>[INST] {{ .Prompt }} [/INST]
112
+ """)
113
+ #
114
+ # End of globals
115
+ #######################################################################################################################
116
+ #
117
+ # Start of Video/Audio Transcription and Summarization Functions
118
+ #
119
+ # Functions:
120
+ # FIXME
121
+ #
122
+ #
123
+ ################################################################################################################
124
+ # Functions for Re-Summarization
125
+ #
126
+ # Functions:
127
+ # FIXME
128
+ # End of Re-Summarization Functions
129
+ #
130
+ ############################################################################################################################################################################################################################
131
+ #
132
+ # Explain/Summarize This Tab
133
+ #
134
+ # Functions:
135
+ # FIXME
136
+ #
137
+ #
138
+ ############################################################################################################################################################################################################################
139
+ #
140
+ # Transcript Comparison Tab
141
+ #
142
+ # Functions:
143
+ # FIXME
144
+ #
145
+ #
146
+ ###########################################################################################################################################################################################################################
147
+ #
148
+ # Search Tab
149
+ #
150
+ # Functions:
151
+ # FIXME
152
+ #
153
+ # End of Search Tab Functions
154
+ #
155
+ ##############################################################################################################################################################################################################################
156
+ #
157
+ # Llamafile Tab
158
+ #
159
+ # Functions:
160
+ # FIXME
161
+ #
162
+ # End of Llamafile Tab Functions
163
+ ##############################################################################################################################################################################################################################
164
+ #
165
+ # Chat Interface Tab Functions
166
+ #
167
+ # Functions:
168
+ # FIXME
169
+ #
170
+ #
171
+ # End of Chat Interface Tab Functions
172
+ ################################################################################################################################################################################################################################
173
+ #
174
+ # Media Edit Tab Functions
175
+ # Functions:
176
+ # Fixme
177
+ # create_media_edit_tab():
178
+ ##### Trash Tab
179
+ # FIXME
180
+ # Functions:
181
+ #
182
+ # End of Media Edit Tab Functions
183
+ ################################################################################################################
184
+ #
185
+ # Import Items Tab Functions
186
+ #
187
+ # Functions:
188
+ #FIXME
189
+ # End of Import Items Tab Functions
190
+ ################################################################################################################
191
+ #
192
+ # Export Items Tab Functions
193
+ #
194
+ # Functions:
195
+ # FIXME
196
+ #
197
+ #
198
+ # End of Export Items Tab Functions
199
+ ################################################################################################################
200
+ #
201
+ # Keyword Management Tab Functions
202
+ #
203
+ # Functions:
204
+ # create_view_keywords_tab():
205
+ # FIXME
206
+ #
207
+ # End of Keyword Management Tab Functions
208
+ ################################################################################################################
209
+ #
210
+ # Document Editing Tab Functions
211
+ #
212
+ # Functions:
213
+ # #FIXME
214
+ #
215
+ #
216
+ ################################################################################################################
217
+ #
218
+ # Utilities Tab Functions
219
+ # Functions:
220
+ # create_utilities_yt_video_tab():
221
+ # #FIXME
222
+
223
+ #
224
+ # End of Utilities Tab Functions
225
+ ################################################################################################################
226
+
227
+ # FIXME - Prompt sample box
228
+ #
229
+ # # Sample data
230
+ # prompts_category_1 = [
231
+ # "What are the key points discussed in the video?",
232
+ # "Summarize the main arguments made by the speaker.",
233
+ # "Describe the conclusions of the study presented."
234
+ # ]
235
+ #
236
+ # prompts_category_2 = [
237
+ # "How does the proposed solution address the problem?",
238
+ # "What are the implications of the findings?",
239
+ # "Can you explain the theory behind the observed phenomenon?"
240
+ # ]
241
+ #
242
+ # all_prompts2 = prompts_category_1 + prompts_category_2
243
+
244
+
245
+
246
+ #######################################################################################################################
247
+ #
248
+ # Migration Script
249
+ import sqlite3
250
+ import uuid
251
+ import logging
252
+ import os
253
+ from datetime import datetime
254
+ import shutil
255
+
256
+ # def migrate_media_db_to_rag_chat_db(media_db_path, rag_chat_db_path):
257
+ # # Check if migration is needed
258
+ # if not os.path.exists(media_db_path):
259
+ # logging.info("Media DB does not exist. No migration needed.")
260
+ # return
261
+ #
262
+ # # Optional: Check if migration has already been completed
263
+ # migration_flag = os.path.join(os.path.dirname(rag_chat_db_path), 'migration_completed.flag')
264
+ # if os.path.exists(migration_flag):
265
+ # logging.info("Migration already completed. Skipping migration.")
266
+ # return
267
+ #
268
+ # # Backup databases
269
+ # backup_database(media_db_path)
270
+ # backup_database(rag_chat_db_path)
271
+ #
272
+ # # Connect to both databases
273
+ # try:
274
+ # media_conn = sqlite3.connect(media_db_path)
275
+ # rag_conn = sqlite3.connect(rag_chat_db_path)
276
+ #
277
+ # # Enable foreign key support
278
+ # media_conn.execute('PRAGMA foreign_keys = ON;')
279
+ # rag_conn.execute('PRAGMA foreign_keys = ON;')
280
+ #
281
+ # media_cursor = media_conn.cursor()
282
+ # rag_cursor = rag_conn.cursor()
283
+ #
284
+ # # Begin transaction
285
+ # rag_conn.execute('BEGIN TRANSACTION;')
286
+ #
287
+ # # Extract conversations from media DB
288
+ # media_cursor.execute('''
289
+ # SELECT id, media_id, media_name, conversation_name, created_at, updated_at
290
+ # FROM ChatConversations
291
+ # ''')
292
+ # conversations = media_cursor.fetchall()
293
+ #
294
+ # for conv in conversations:
295
+ # old_conv_id, media_id, media_name, conversation_name, created_at, updated_at = conv
296
+ #
297
+ # # Convert timestamps if necessary
298
+ # created_at = parse_timestamp(created_at)
299
+ # updated_at = parse_timestamp(updated_at)
300
+ #
301
+ # # Generate a new conversation_id
302
+ # conversation_id = str(uuid.uuid4())
303
+ # title = conversation_name or (f"{media_name}-chat" if media_name else "Untitled Conversation")
304
+ #
305
+ # # Insert into conversation_metadata
306
+ # rag_cursor.execute('''
307
+ # INSERT INTO conversation_metadata (conversation_id, created_at, last_updated, title, media_id)
308
+ # VALUES (?, ?, ?, ?, ?)
309
+ # ''', (conversation_id, created_at, updated_at, title, media_id))
310
+ #
311
+ # # Extract messages from media DB
312
+ # media_cursor.execute('''
313
+ # SELECT sender, message, timestamp
314
+ # FROM ChatMessages
315
+ # WHERE conversation_id = ?
316
+ # ORDER BY timestamp ASC
317
+ # ''', (old_conv_id,))
318
+ # messages = media_cursor.fetchall()
319
+ #
320
+ # for msg in messages:
321
+ # sender, content, timestamp = msg
322
+ #
323
+ # # Convert timestamp if necessary
324
+ # timestamp = parse_timestamp(timestamp)
325
+ #
326
+ # role = sender # Assuming 'sender' is 'user' or 'ai'
327
+ #
328
+ # # Insert message into rag_qa_chats
329
+ # rag_cursor.execute('''
330
+ # INSERT INTO rag_qa_chats (conversation_id, timestamp, role, content)
331
+ # VALUES (?, ?, ?, ?)
332
+ # ''', (conversation_id, timestamp, role, content))
333
+ #
334
+ # # Commit transaction
335
+ # rag_conn.commit()
336
+ # logging.info("Migration completed successfully.")
337
+ #
338
+ # # Mark migration as complete
339
+ # with open(migration_flag, 'w') as f:
340
+ # f.write('Migration completed on ' + datetime.now().isoformat())
341
+ #
342
+ # except Exception as e:
343
+ # # Rollback transaction in case of error
344
+ # rag_conn.rollback()
345
+ # logging.error(f"Error during migration: {e}")
346
+ # raise
347
+ # finally:
348
+ # media_conn.close()
349
+ # rag_conn.close()
350
+
351
+ def backup_database(db_path):
352
+ backup_path = db_path + '.backup'
353
+ if not os.path.exists(backup_path):
354
+ shutil.copyfile(db_path, backup_path)
355
+ logging.info(f"Database backed up to {backup_path}")
356
+ else:
357
+ logging.info(f"Backup already exists at {backup_path}")
358
+
359
+ def parse_timestamp(timestamp_value):
360
+ """
361
+ Parses the timestamp from the old database and converts it to a standard format.
362
+ Adjust this function based on the actual format of your timestamps.
363
+ """
364
+ try:
365
+ # Attempt to parse ISO format
366
+ return datetime.fromisoformat(timestamp_value).isoformat()
367
+ except ValueError:
368
+ # Handle other timestamp formats if necessary
369
+ # For example, if timestamps are in Unix epoch format
370
+ try:
371
+ timestamp_float = float(timestamp_value)
372
+ return datetime.fromtimestamp(timestamp_float).isoformat()
373
+ except ValueError:
374
+ # Default to current time if parsing fails
375
+ logging.warning(f"Unable to parse timestamp '{timestamp_value}', using current time.")
376
+ return datetime.now().isoformat()
377
+
378
+ #
379
+ # End of Migration Script
380
+ #######################################################################################################################
381
+
382
+
383
+ #######################################################################################################################
384
+ #
385
+ # Launch UI Function
386
+ def launch_ui(share_public=None, server_mode=False):
387
+ webbrowser.open_new_tab('http://127.0.0.1:7860/?__theme=dark')
388
+ share=share_public
389
+ css = """
390
+ .result-box {
391
+ margin-bottom: 20px;
392
+ border: 1px solid #ddd;
393
+ padding: 10px;
394
+ }
395
+ .result-box.error {
396
+ border-color: #ff0000;
397
+ background-color: #ffeeee;
398
+ }
399
+ .transcription, .summary {
400
+ max-height: 800px;
401
+ overflow-y: auto;
402
+ border: 1px solid #eee;
403
+ padding: 10px;
404
+ margin-top: 10px;
405
+ }
406
+ """
407
+
408
+ config = load_and_log_configs()
409
+ # Get database paths from config
410
+ media_db_path = 'Databases/media_summary.db'
411
+ character_chat_db_path = os.path.join(os.path.dirname(media_db_path), "chatDB.db")
412
+ rag_chat_db_path = os.path.join(os.path.dirname(media_db_path), "rag_qa.db")
413
+ # Initialize the RAG Chat DB (create tables and update schema)
414
+ create_tables()
415
+
416
+ # Migrate data from the media DB to the RAG Chat DB
417
+ #migrate_media_db_to_rag_chat_db(media_db_path, rag_chat_db_path)
418
+
419
+
420
+ with gr.Blocks(theme='bethecloud/storj_theme',css=css) as iface:
421
+ gr.HTML(
422
+ """
423
+ <script>
424
+ document.addEventListener('DOMContentLoaded', (event) => {
425
+ document.body.classList.add('dark');
426
+ document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)';
427
+ });
428
+ </script>
429
+ """
430
+ )
431
+ db_config = get_db_config()
432
+ db_type = db_config['type']
433
+ gr.Markdown(f"# tl/dw: Your LLM-powered Research Multi-tool")
434
+ gr.Markdown(f"(Using {db_type.capitalize()} Database)")
435
+ with gr.Tabs():
436
+ with gr.TabItem("Transcribe / Analyze / Ingestion", id="ingestion-grouping", visible=True):
437
+ with gr.Tabs():
438
+ create_video_transcription_tab()
439
+ create_audio_processing_tab()
440
+ create_podcast_tab()
441
+ create_import_book_tab()
442
+ create_plain_text_import_tab()
443
+ create_xml_import_tab()
444
+ create_website_scraping_tab()
445
+ create_pdf_ingestion_tab()
446
+ create_pdf_ingestion_test_tab()
447
+ create_resummary_tab()
448
+ create_summarize_explain_tab()
449
+ create_live_recording_tab()
450
+ create_arxiv_tab()
451
+ create_semantic_scholar_tab()
452
+
453
+ with gr.TabItem("RAG Chat/Search", id="RAG Chat Notes group", visible=True):
454
+ create_rag_tab()
455
+ create_rag_qa_chat_tab()
456
+ create_rag_qa_notes_management_tab()
457
+ create_rag_qa_chat_management_tab()
458
+
459
+ with gr.TabItem("Chat with an LLM", id="LLM Chat group", visible=True):
460
+ create_chat_interface()
461
+ create_chat_interface_stacked()
462
+ create_chat_interface_multi_api()
463
+ create_chat_interface_four()
464
+ chat_workflows_tab()
465
+
466
+ with gr.TabItem("Character Chat", id="character chat group", visible=True):
467
+ create_character_card_interaction_tab()
468
+ create_character_chat_mgmt_tab()
469
+ create_custom_character_card_tab()
470
+ create_character_card_validation_tab()
471
+ create_multiple_character_chat_tab()
472
+ create_narrator_controlled_conversation_tab()
473
+ create_export_characters_tab()
474
+
475
+ with gr.TabItem("Writing Tools", id="writing_tools group", visible=True):
476
+ from App_Function_Libraries.Gradio_UI.Writing_tab import create_document_feedback_tab
477
+ create_document_feedback_tab()
478
+ from App_Function_Libraries.Gradio_UI.Writing_tab import create_grammar_style_check_tab
479
+ create_grammar_style_check_tab()
480
+ from App_Function_Libraries.Gradio_UI.Writing_tab import create_tone_adjustment_tab
481
+ create_tone_adjustment_tab()
482
+ from App_Function_Libraries.Gradio_UI.Writing_tab import create_creative_writing_tab
483
+ create_creative_writing_tab()
484
+ from App_Function_Libraries.Gradio_UI.Writing_tab import create_mikupad_tab
485
+ create_mikupad_tab()
486
+
487
+ with gr.TabItem("Search/View DB Items", id="view db items group", visible=True):
488
+ create_search_tab()
489
+ create_search_summaries_tab()
490
+ create_view_all_mediadb_with_versions_tab()
491
+ create_viewing_mediadb_tab()
492
+ create_mediadb_keyword_search_tab()
493
+ create_view_all_rag_notes_tab()
494
+ create_viewing_ragdb_tab()
495
+ create_ragdb_keyword_items_tab()
496
+
497
+ with gr.TabItem("Prompts", id='view prompts group', visible=True):
498
+ with gr.Tabs():
499
+ create_prompt_view_tab()
500
+ create_prompt_search_tab()
501
+ create_prompt_edit_tab()
502
+ create_prompt_clone_tab()
503
+ create_prompt_suggestion_tab()
504
+ create_prompts_export_tab()
505
+
506
+ with gr.TabItem("Manage Media DB Items", id="manage group", visible=True):
507
+ create_media_edit_tab()
508
+ create_manage_items_tab()
509
+ create_media_edit_and_clone_tab()
510
+
511
+ with gr.TabItem("Embeddings Management", id="embeddings group", visible=True):
512
+ create_embeddings_tab()
513
+ create_view_embeddings_tab()
514
+ create_purge_embeddings_tab()
515
+
516
+ with gr.TabItem("Keywords", id="keywords group", visible=True):
517
+ create_view_keywords_tab()
518
+ create_add_keyword_tab()
519
+ create_delete_keyword_tab()
520
+ create_export_keywords_tab()
521
+ create_character_keywords_tab()
522
+ create_rag_qa_keywords_tab()
523
+ create_meta_keywords_tab()
524
+ create_prompt_keywords_tab()
525
+
526
+ with gr.TabItem("Import", id="import group", visible=True):
527
+ create_import_item_tab()
528
+ create_import_obsidian_vault_tab()
529
+ create_import_single_prompt_tab()
530
+ create_import_multiple_prompts_tab()
531
+ create_mediawiki_import_tab()
532
+ create_mediawiki_config_tab()
533
+ create_conversation_import_tab()
534
+
535
+ with gr.TabItem("Export", id="export group", visible=True):
536
+ create_export_tabs()
537
+
538
+
539
+ with gr.TabItem("Database Management", id="database_management_group", visible=True):
540
+ create_database_management_interface(
541
+ media_db_config={
542
+ 'db_path': media_db_path,
543
+ 'backup_dir': backup_dir
544
+ },
545
+ rag_db_config={
546
+ 'db_path': rag_chat_db_path,
547
+ 'backup_dir': backup_dir
548
+ },
549
+ char_db_config={
550
+ 'db_path': character_chat_db_path,
551
+ 'backup_dir': backup_dir
552
+ }
553
+ )
554
+
555
+ with gr.TabItem("Utilities", id="util group", visible=True):
556
+ create_mindmap_tab()
557
+ create_utilities_yt_video_tab()
558
+ create_utilities_yt_audio_tab()
559
+ create_utilities_yt_timestamp_tab()
560
+
561
+ with gr.TabItem("Anki Deck Creation/Validation", id="anki group", visible=True):
562
+ create_anki_generator_tab()
563
+ create_anki_validation_tab()
564
+
565
+ with gr.TabItem("Local LLM", id="local llm group", visible=True):
566
+ create_chat_with_llamafile_tab()
567
+ create_ollama_tab()
568
+ #create_huggingface_tab()
569
+
570
+ with gr.TabItem("Trashcan", id="trashcan group", visible=True):
571
+ create_search_and_mark_trash_tab()
572
+ create_view_trash_tab()
573
+ create_delete_trash_tab()
574
+ create_empty_trash_tab()
575
+
576
+ with gr.TabItem("Evaluations", id="eval", visible=True):
577
+ create_geval_tab()
578
+ create_infinite_bench_tab()
579
+ # FIXME
580
+ #create_mmlu_pro_tab()
581
+
582
+ with gr.TabItem("Introduction/Help", id="introduction group", visible=True):
583
+ create_introduction_tab()
584
+
585
+ with gr.TabItem("Config Editor", id="config group"):
586
+ create_config_editor_tab()
587
+
588
+ # Launch the interface
589
+ server_port_variable = 7860
590
+ os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
591
+ if share==True:
592
+ iface.launch(share=True)
593
+ elif server_mode and not share_public:
594
+ iface.launch(share=False, server_name="0.0.0.0", server_port=server_port_variable, )
595
+ else:
596
+ try:
597
+ iface.launch(share=False, server_name="0.0.0.0", server_port=server_port_variable, )
598
+ except Exception as e:
599
+ logging.error(f"Error launching interface: {str(e)}")