oceansweep commited on
Commit
818336a
1 Parent(s): ee86347

Upload Gradio_Related.py

Browse files
Files changed (1) hide show
  1. App_Function_Libraries/Gradio_Related.py +423 -397
App_Function_Libraries/Gradio_Related.py CHANGED
@@ -1,397 +1,423 @@
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
- #
12
- # Import 3rd-Party Libraries
13
- import gradio as gr
14
- #
15
- # Local Imports
16
- from App_Function_Libraries.DB.DB_Manager import get_db_config
17
- from App_Function_Libraries.Gradio_UI.Arxiv_tab import create_arxiv_tab
18
- from App_Function_Libraries.Gradio_UI.Audio_ingestion_tab import create_audio_processing_tab
19
- from App_Function_Libraries.Gradio_UI.Book_Ingestion_tab import create_import_book_tab
20
- #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, \
21
- # create_character_card_validation_tab
22
- #from App_Function_Libraries.Gradio_UI.Character_interaction_tab import create_narrator_controlled_conversation_tab, \
23
- # create_multiple_character_chat_tab
24
- from App_Function_Libraries.Gradio_UI.Chat_ui import create_chat_management_tab, \
25
- create_chat_interface_four, create_chat_interface_multi_api, create_chat_interface_stacked, create_chat_interface
26
- from App_Function_Libraries.Gradio_UI.Config_tab import create_config_editor_tab
27
- from App_Function_Libraries.Gradio_UI.Explain_summarize_tab import create_summarize_explain_tab
28
- from App_Function_Libraries.Gradio_UI.Export_Functionality import create_export_tab
29
- from App_Function_Libraries.Gradio_UI.Backup_Functionality import create_backup_tab, create_view_backups_tab, \
30
- create_restore_backup_tab
31
- from App_Function_Libraries.Gradio_UI.Import_Functionality import create_import_single_prompt_tab, \
32
- create_import_obsidian_vault_tab, create_import_item_tab, create_import_multiple_prompts_tab
33
- from App_Function_Libraries.Gradio_UI.Introduction_tab import create_introduction_tab
34
- from App_Function_Libraries.Gradio_UI.Keywords import create_view_keywords_tab, create_add_keyword_tab, \
35
- create_delete_keyword_tab, create_export_keywords_tab
36
- from App_Function_Libraries.Gradio_UI.Llamafile_tab import create_chat_with_llamafile_tab
37
- from App_Function_Libraries.Gradio_UI.Media_edit import create_prompt_clone_tab, create_prompt_edit_tab, \
38
- create_media_edit_and_clone_tab, create_media_edit_tab
39
- from App_Function_Libraries.Gradio_UI.Media_wiki_tab import create_mediawiki_import_tab, create_mediawiki_config_tab
40
- from App_Function_Libraries.Gradio_UI.PDF_ingestion_tab import create_pdf_ingestion_tab, create_pdf_ingestion_test_tab
41
- from App_Function_Libraries.Gradio_UI.Plaintext_tab_import import create_plain_text_import_tab
42
- from App_Function_Libraries.Gradio_UI.Podcast_tab import create_podcast_tab
43
- from App_Function_Libraries.Gradio_UI.Prompt_Suggestion_tab import create_prompt_suggestion_tab
44
- from App_Function_Libraries.Gradio_UI.RAG_QA_Chat_tab import create_rag_qa_chat_tab
45
- from App_Function_Libraries.Gradio_UI.Re_summarize_tab import create_resummary_tab
46
- from App_Function_Libraries.Gradio_UI.Search_Tab import create_prompt_search_tab, \
47
- create_search_summaries_tab, create_search_tab
48
- from App_Function_Libraries.Gradio_UI.RAG_Chat_tab import create_rag_tab
49
- from App_Function_Libraries.Gradio_UI.Embeddings_tab import create_embeddings_tab, create_view_embeddings_tab, \
50
- create_purge_embeddings_tab
51
- from App_Function_Libraries.Gradio_UI.Trash import create_view_trash_tab, create_empty_trash_tab, \
52
- create_delete_trash_tab, create_search_and_mark_trash_tab
53
- from App_Function_Libraries.Gradio_UI.Utilities import create_utilities_yt_timestamp_tab, create_utilities_yt_audio_tab, \
54
- create_utilities_yt_video_tab
55
- from App_Function_Libraries.Gradio_UI.Video_transcription_tab import create_video_transcription_tab
56
- from App_Function_Libraries.Gradio_UI.View_tab import create_manage_items_tab
57
- from App_Function_Libraries.Gradio_UI.Website_scraping_tab import create_website_scraping_tab
58
- from App_Function_Libraries.Gradio_UI.Chat_Workflows import chat_workflows_tab
59
- from App_Function_Libraries.Gradio_UI.View_DB_Items_tab import create_prompt_view_tab, \
60
- create_view_all_with_versions_tab, create_viewing_tab
61
-
62
- #
63
- #######################################################################################################################
64
- # Function Definitions
65
- #
66
-
67
-
68
- # Disable Gradio Analytics
69
- os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
70
-
71
-
72
- custom_prompt_input = None
73
- server_mode = False
74
- share_public = False
75
- custom_prompt_summarize_bulleted_notes = ("""
76
- <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]
77
- **Bulleted Note Creation Guidelines**
78
-
79
- **Headings**:
80
- - Based on referenced topics, not categories like quotes or terms
81
- - Surrounded by **bold** formatting
82
- - Not listed as bullet points
83
- - No space between headings and list items underneath
84
-
85
- **Emphasis**:
86
- - **Important terms** set in bold font
87
- - **Text ending in a colon**: also bolded
88
-
89
- **Review**:
90
- - Ensure adherence to specified format
91
- - Do not reference these instructions in your response.</s>[INST] {{ .Prompt }} [/INST]
92
- """)
93
- #
94
- # End of globals
95
- #######################################################################################################################
96
- #
97
- # Start of Video/Audio Transcription and Summarization Functions
98
- #
99
- # Functions:
100
- # FIXME
101
- #
102
- #
103
- ################################################################################################################
104
- # Functions for Re-Summarization
105
- #
106
- # Functions:
107
- # FIXME
108
- # End of Re-Summarization Functions
109
- #
110
- ############################################################################################################################################################################################################################
111
- #
112
- # Explain/Summarize This Tab
113
- #
114
- # Functions:
115
- # FIXME
116
- #
117
- #
118
- ############################################################################################################################################################################################################################
119
- #
120
- # Transcript Comparison Tab
121
- #
122
- # Functions:
123
- # FIXME
124
- #
125
- #
126
- ###########################################################################################################################################################################################################################
127
- #
128
- # Search Tab
129
- #
130
- # Functions:
131
- # FIXME
132
- #
133
- # End of Search Tab Functions
134
- #
135
- ##############################################################################################################################################################################################################################
136
- #
137
- # Llamafile Tab
138
- #
139
- # Functions:
140
- # FIXME
141
- #
142
- # End of Llamafile Tab Functions
143
- ##############################################################################################################################################################################################################################
144
- #
145
- # Chat Interface Tab Functions
146
- #
147
- # Functions:
148
- # FIXME
149
- #
150
- #
151
- # End of Chat Interface Tab Functions
152
- ################################################################################################################################################################################################################################
153
- #
154
- # Media Edit Tab Functions
155
- # Functions:
156
- # Fixme
157
- # create_media_edit_tab():
158
- ##### Trash Tab
159
- # FIXME
160
- # Functions:
161
- #
162
- # End of Media Edit Tab Functions
163
- ################################################################################################################
164
- #
165
- # Import Items Tab Functions
166
- #
167
- # Functions:
168
- #FIXME
169
- # End of Import Items Tab Functions
170
- ################################################################################################################
171
- #
172
- # Export Items Tab Functions
173
- #
174
- # Functions:
175
- # FIXME
176
- #
177
- #
178
- # End of Export Items Tab Functions
179
- ################################################################################################################
180
- #
181
- # Keyword Management Tab Functions
182
- #
183
- # Functions:
184
- # create_view_keywords_tab():
185
- # FIXME
186
- #
187
- # End of Keyword Management Tab Functions
188
- ################################################################################################################
189
- #
190
- # Document Editing Tab Functions
191
- #
192
- # Functions:
193
- # #FIXME
194
- #
195
- #
196
- ################################################################################################################
197
- #
198
- # Utilities Tab Functions
199
- # Functions:
200
- # create_utilities_yt_video_tab():
201
- # #FIXME
202
-
203
- #
204
- # End of Utilities Tab Functions
205
- ################################################################################################################
206
-
207
- # FIXME - Prompt sample box
208
- #
209
- # # Sample data
210
- # prompts_category_1 = [
211
- # "What are the key points discussed in the video?",
212
- # "Summarize the main arguments made by the speaker.",
213
- # "Describe the conclusions of the study presented."
214
- # ]
215
- #
216
- # prompts_category_2 = [
217
- # "How does the proposed solution address the problem?",
218
- # "What are the implications of the findings?",
219
- # "Can you explain the theory behind the observed phenomenon?"
220
- # ]
221
- #
222
- # all_prompts2 = prompts_category_1 + prompts_category_2
223
-
224
-
225
- def launch_ui(share_public=None, server_mode=False):
226
- share=share_public
227
- css = """
228
- .result-box {
229
- margin-bottom: 20px;
230
- border: 1px solid #ddd;
231
- padding: 10px;
232
- }
233
- .result-box.error {
234
- border-color: #ff0000;
235
- background-color: #ffeeee;
236
- }
237
- .transcription, .summary {
238
- max-height: 800px;
239
- overflow-y: auto;
240
- border: 1px solid #eee;
241
- padding: 10px;
242
- margin-top: 10px;
243
- }
244
- """
245
-
246
- with gr.Blocks(theme='bethecloud/storj_theme',css=css) as iface:
247
- gr.HTML(
248
- """
249
- <script>
250
- document.addEventListener('DOMContentLoaded', (event) => {
251
- document.body.classList.add('dark');
252
- document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)';
253
- });
254
- </script>
255
- """
256
- )
257
- db_config = get_db_config()
258
- db_type = db_config['type']
259
- gr.Markdown(f"# tl/dw: Your LLM-powered Research Multi-tool")
260
- gr.Markdown(f"(Using {db_type.capitalize()} Database)")
261
- with gr.Tabs():
262
- with gr.TabItem("Transcription / Summarization / Ingestion"):
263
- with gr.Tabs():
264
- create_video_transcription_tab()
265
- create_audio_processing_tab()
266
- create_podcast_tab()
267
- create_import_book_tab()
268
- create_plain_text_import_tab()
269
- create_website_scraping_tab()
270
- create_pdf_ingestion_tab()
271
- create_pdf_ingestion_test_tab()
272
- create_resummary_tab()
273
- create_summarize_explain_tab()
274
- create_arxiv_tab()
275
-
276
- with gr.TabItem("Text Search "):
277
- create_search_tab()
278
- create_search_summaries_tab()
279
-
280
-
281
- with gr.TabItem("RAG Search"):
282
- create_rag_tab()
283
- create_rag_qa_chat_tab()
284
-
285
-
286
- with gr.TabItem("Chat with an LLM"):
287
- create_chat_interface()
288
- create_chat_interface_stacked()
289
- create_chat_interface_multi_api()
290
- create_chat_interface_four()
291
- create_chat_with_llamafile_tab()
292
- create_chat_management_tab()
293
- chat_workflows_tab()
294
-
295
-
296
- # with gr.TabItem("Character Chat"):
297
- # with gr.Tabs():
298
- # create_character_card_interaction_tab()
299
- # create_character_chat_mgmt_tab()
300
- # create_custom_character_card_tab()
301
- # create_character_card_validation_tab()
302
- # create_multiple_character_chat_tab()
303
- # create_narrator_controlled_conversation_tab()
304
-
305
-
306
- with gr.TabItem("View DB Items"):
307
- # This one works
308
- create_view_all_with_versions_tab()
309
- # This one is WIP
310
- create_viewing_tab()
311
- create_prompt_view_tab()
312
-
313
-
314
- with gr.TabItem("Prompts"):
315
- create_prompt_view_tab()
316
- create_prompt_search_tab()
317
- create_prompt_edit_tab()
318
- create_prompt_clone_tab()
319
- create_prompt_suggestion_tab()
320
-
321
-
322
- with gr.TabItem("Manage / Edit Existing Items"):
323
- create_media_edit_tab()
324
- create_manage_items_tab()
325
- create_media_edit_and_clone_tab()
326
-
327
-
328
- with gr.TabItem("Embeddings Management"):
329
- create_embeddings_tab()
330
- create_view_embeddings_tab()
331
- create_purge_embeddings_tab()
332
-
333
- with gr.TabItem("Writing Tools"):
334
- with gr.Tabs():
335
- from App_Function_Libraries.Gradio_UI.Writing_tab import create_document_feedback_tab
336
- create_document_feedback_tab()
337
- from App_Function_Libraries.Gradio_UI.Writing_tab import create_grammar_style_check_tab
338
- create_grammar_style_check_tab()
339
- from App_Function_Libraries.Gradio_UI.Writing_tab import create_tone_adjustment_tab
340
- create_tone_adjustment_tab()
341
- from App_Function_Libraries.Gradio_UI.Writing_tab import create_creative_writing_tab
342
- create_creative_writing_tab()
343
- from App_Function_Libraries.Gradio_UI.Writing_tab import create_mikupad_tab
344
- create_mikupad_tab()
345
-
346
-
347
- with gr.TabItem("Keywords"):
348
- create_view_keywords_tab()
349
- create_add_keyword_tab()
350
- create_delete_keyword_tab()
351
- create_export_keywords_tab()
352
-
353
- with gr.TabItem("Import"):
354
- create_import_item_tab()
355
- create_import_obsidian_vault_tab()
356
- create_import_single_prompt_tab()
357
- create_import_multiple_prompts_tab()
358
- create_mediawiki_import_tab()
359
- create_mediawiki_config_tab()
360
-
361
- with gr.TabItem("Export"):
362
- create_export_tab()
363
-
364
- with gr.TabItem("Backup Management"):
365
- create_backup_tab()
366
- create_view_backups_tab()
367
- create_restore_backup_tab()
368
-
369
- with gr.TabItem("Utilities"):
370
- create_utilities_yt_video_tab()
371
- create_utilities_yt_audio_tab()
372
- create_utilities_yt_timestamp_tab()
373
-
374
- with gr.TabItem("Trashcan"):
375
- create_search_and_mark_trash_tab()
376
- create_view_trash_tab()
377
- create_delete_trash_tab()
378
- create_empty_trash_tab()
379
-
380
- with gr.TabItem("Introduction/Help"):
381
- create_introduction_tab()
382
-
383
- with gr.TabItem("Config Editor"):
384
- create_config_editor_tab()
385
-
386
- # Launch the interface
387
- server_port_variable = 7860
388
- os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
389
- if share==True:
390
- iface.launch(share=True)
391
- elif server_mode and not share_public:
392
- iface.launch(share=False, server_name="0.0.0.0", server_port=server_port_variable, debug=True)
393
- else:
394
- try:
395
- iface.launch(share=False, server_name="0.0.0.0", server_port=server_port_variable, debug=True)
396
- except Exception as e:
397
- 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
+ #
14
+ # Import 3rd-Party Libraries
15
+ import gradio as gr
16
+ #
17
+ # Local Imports
18
+ from App_Function_Libraries.DB.DB_Manager import get_db_config
19
+ from App_Function_Libraries.Gradio_UI.Arxiv_tab import create_arxiv_tab
20
+ from App_Function_Libraries.Gradio_UI.Audio_ingestion_tab import create_audio_processing_tab
21
+ from App_Function_Libraries.Gradio_UI.Book_Ingestion_tab import create_import_book_tab
22
+ 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, \
23
+ create_character_card_validation_tab, create_export_characters_tab
24
+ from App_Function_Libraries.Gradio_UI.Character_interaction_tab import create_narrator_controlled_conversation_tab, \
25
+ create_multiple_character_chat_tab
26
+ from App_Function_Libraries.Gradio_UI.Chat_ui import create_chat_management_tab, \
27
+ create_chat_interface_four, create_chat_interface_multi_api, create_chat_interface_stacked, create_chat_interface
28
+ from App_Function_Libraries.Gradio_UI.Config_tab import create_config_editor_tab
29
+ from App_Function_Libraries.Gradio_UI.Explain_summarize_tab import create_summarize_explain_tab
30
+ from App_Function_Libraries.Gradio_UI.Export_Functionality import create_export_tab
31
+ from App_Function_Libraries.Gradio_UI.Backup_Functionality import create_backup_tab, create_view_backups_tab, \
32
+ create_restore_backup_tab
33
+ from App_Function_Libraries.Gradio_UI.Import_Functionality import create_import_single_prompt_tab, \
34
+ create_import_obsidian_vault_tab, create_import_item_tab, create_import_multiple_prompts_tab
35
+ from App_Function_Libraries.Gradio_UI.Introduction_tab import create_introduction_tab
36
+ from App_Function_Libraries.Gradio_UI.Keywords import create_view_keywords_tab, create_add_keyword_tab, \
37
+ create_delete_keyword_tab, create_export_keywords_tab
38
+ from App_Function_Libraries.Gradio_UI.Live_Recording import create_live_recording_tab
39
+ from App_Function_Libraries.Gradio_UI.Llamafile_tab import create_chat_with_llamafile_tab
40
+ #from App_Function_Libraries.Gradio_UI.MMLU_Pro_tab import create_mmlu_pro_tab
41
+ from App_Function_Libraries.Gradio_UI.Media_edit import create_prompt_clone_tab, create_prompt_edit_tab, \
42
+ create_media_edit_and_clone_tab, create_media_edit_tab
43
+ from App_Function_Libraries.Gradio_UI.Media_wiki_tab import create_mediawiki_import_tab, create_mediawiki_config_tab
44
+ from App_Function_Libraries.Gradio_UI.PDF_ingestion_tab import create_pdf_ingestion_tab, create_pdf_ingestion_test_tab
45
+ from App_Function_Libraries.Gradio_UI.Plaintext_tab_import import create_plain_text_import_tab
46
+ from App_Function_Libraries.Gradio_UI.Podcast_tab import create_podcast_tab
47
+ from App_Function_Libraries.Gradio_UI.Prompt_Suggestion_tab import create_prompt_suggestion_tab
48
+ from App_Function_Libraries.Gradio_UI.RAG_QA_Chat_tab import create_rag_qa_chat_tab
49
+ from App_Function_Libraries.Gradio_UI.Re_summarize_tab import create_resummary_tab
50
+ from App_Function_Libraries.Gradio_UI.Search_Tab import create_prompt_search_tab, \
51
+ create_search_summaries_tab, create_search_tab
52
+ from App_Function_Libraries.Gradio_UI.RAG_Chat_tab import create_rag_tab
53
+ from App_Function_Libraries.Gradio_UI.Embeddings_tab import create_embeddings_tab, create_view_embeddings_tab, \
54
+ create_purge_embeddings_tab
55
+ from App_Function_Libraries.Gradio_UI.Trash import create_view_trash_tab, create_empty_trash_tab, \
56
+ create_delete_trash_tab, create_search_and_mark_trash_tab
57
+ from App_Function_Libraries.Gradio_UI.Utilities import create_utilities_yt_timestamp_tab, create_utilities_yt_audio_tab, \
58
+ create_utilities_yt_video_tab
59
+ from App_Function_Libraries.Gradio_UI.Video_transcription_tab import create_video_transcription_tab
60
+ from App_Function_Libraries.Gradio_UI.View_tab import create_manage_items_tab
61
+ from App_Function_Libraries.Gradio_UI.Website_scraping_tab import create_website_scraping_tab
62
+ from App_Function_Libraries.Gradio_UI.Chat_Workflows import chat_workflows_tab
63
+ from App_Function_Libraries.Gradio_UI.View_DB_Items_tab import create_prompt_view_tab, \
64
+ create_view_all_with_versions_tab, create_viewing_tab
65
+ #
66
+ # Gradio UI Imports
67
+ from App_Function_Libraries.Gradio_UI.Evaluations_Benchmarks_tab import create_geval_tab, create_infinite_bench_tab
68
+ #from App_Function_Libraries.Local_LLM.Local_LLM_huggingface import create_huggingface_tab
69
+ from App_Function_Libraries.Local_LLM.Local_LLM_ollama import create_ollama_tab
70
+ from App_Function_Libraries.Gradio_UI.RAG_QA_Chat_Notes import create_rag_qa_chat_notes_tab
71
+
72
+ #
73
+ #######################################################################################################################
74
+ # Function Definitions
75
+ #
76
+
77
+
78
+ # Disable Gradio Analytics
79
+ os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
80
+
81
+
82
+ custom_prompt_input = None
83
+ server_mode = False
84
+ share_public = False
85
+ custom_prompt_summarize_bulleted_notes = ("""
86
+ <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]
87
+ **Bulleted Note Creation Guidelines**
88
+
89
+ **Headings**:
90
+ - Based on referenced topics, not categories like quotes or terms
91
+ - Surrounded by **bold** formatting
92
+ - Not listed as bullet points
93
+ - No space between headings and list items underneath
94
+
95
+ **Emphasis**:
96
+ - **Important terms** set in bold font
97
+ - **Text ending in a colon**: also bolded
98
+
99
+ **Review**:
100
+ - Ensure adherence to specified format
101
+ - Do not reference these instructions in your response.</s>[INST] {{ .Prompt }} [/INST]
102
+ """)
103
+ #
104
+ # End of globals
105
+ #######################################################################################################################
106
+ #
107
+ # Start of Video/Audio Transcription and Summarization Functions
108
+ #
109
+ # Functions:
110
+ # FIXME
111
+ #
112
+ #
113
+ ################################################################################################################
114
+ # Functions for Re-Summarization
115
+ #
116
+ # Functions:
117
+ # FIXME
118
+ # End of Re-Summarization Functions
119
+ #
120
+ ############################################################################################################################################################################################################################
121
+ #
122
+ # Explain/Summarize This Tab
123
+ #
124
+ # Functions:
125
+ # FIXME
126
+ #
127
+ #
128
+ ############################################################################################################################################################################################################################
129
+ #
130
+ # Transcript Comparison Tab
131
+ #
132
+ # Functions:
133
+ # FIXME
134
+ #
135
+ #
136
+ ###########################################################################################################################################################################################################################
137
+ #
138
+ # Search Tab
139
+ #
140
+ # Functions:
141
+ # FIXME
142
+ #
143
+ # End of Search Tab Functions
144
+ #
145
+ ##############################################################################################################################################################################################################################
146
+ #
147
+ # Llamafile Tab
148
+ #
149
+ # Functions:
150
+ # FIXME
151
+ #
152
+ # End of Llamafile Tab Functions
153
+ ##############################################################################################################################################################################################################################
154
+ #
155
+ # Chat Interface Tab Functions
156
+ #
157
+ # Functions:
158
+ # FIXME
159
+ #
160
+ #
161
+ # End of Chat Interface Tab Functions
162
+ ################################################################################################################################################################################################################################
163
+ #
164
+ # Media Edit Tab Functions
165
+ # Functions:
166
+ # Fixme
167
+ # create_media_edit_tab():
168
+ ##### Trash Tab
169
+ # FIXME
170
+ # Functions:
171
+ #
172
+ # End of Media Edit Tab Functions
173
+ ################################################################################################################
174
+ #
175
+ # Import Items Tab Functions
176
+ #
177
+ # Functions:
178
+ #FIXME
179
+ # End of Import Items Tab Functions
180
+ ################################################################################################################
181
+ #
182
+ # Export Items Tab Functions
183
+ #
184
+ # Functions:
185
+ # FIXME
186
+ #
187
+ #
188
+ # End of Export Items Tab Functions
189
+ ################################################################################################################
190
+ #
191
+ # Keyword Management Tab Functions
192
+ #
193
+ # Functions:
194
+ # create_view_keywords_tab():
195
+ # FIXME
196
+ #
197
+ # End of Keyword Management Tab Functions
198
+ ################################################################################################################
199
+ #
200
+ # Document Editing Tab Functions
201
+ #
202
+ # Functions:
203
+ # #FIXME
204
+ #
205
+ #
206
+ ################################################################################################################
207
+ #
208
+ # Utilities Tab Functions
209
+ # Functions:
210
+ # create_utilities_yt_video_tab():
211
+ # #FIXME
212
+
213
+ #
214
+ # End of Utilities Tab Functions
215
+ ################################################################################################################
216
+
217
+ # FIXME - Prompt sample box
218
+ #
219
+ # # Sample data
220
+ # prompts_category_1 = [
221
+ # "What are the key points discussed in the video?",
222
+ # "Summarize the main arguments made by the speaker.",
223
+ # "Describe the conclusions of the study presented."
224
+ # ]
225
+ #
226
+ # prompts_category_2 = [
227
+ # "How does the proposed solution address the problem?",
228
+ # "What are the implications of the findings?",
229
+ # "Can you explain the theory behind the observed phenomenon?"
230
+ # ]
231
+ #
232
+ # all_prompts2 = prompts_category_1 + prompts_category_2
233
+
234
+
235
+ def launch_ui(share_public=None, server_mode=False):
236
+ webbrowser.open_new_tab('http://127.0.0.1:7860/?__theme=dark')
237
+ share=share_public
238
+ css = """
239
+ .result-box {
240
+ margin-bottom: 20px;
241
+ border: 1px solid #ddd;
242
+ padding: 10px;
243
+ }
244
+ .result-box.error {
245
+ border-color: #ff0000;
246
+ background-color: #ffeeee;
247
+ }
248
+ .transcription, .summary {
249
+ max-height: 800px;
250
+ overflow-y: auto;
251
+ border: 1px solid #eee;
252
+ padding: 10px;
253
+ margin-top: 10px;
254
+ }
255
+ """
256
+
257
+ with gr.Blocks(theme='bethecloud/storj_theme',css=css) as iface:
258
+ gr.HTML(
259
+ """
260
+ <script>
261
+ document.addEventListener('DOMContentLoaded', (event) => {
262
+ document.body.classList.add('dark');
263
+ document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)';
264
+ });
265
+ </script>
266
+ """
267
+ )
268
+ db_config = get_db_config()
269
+ db_type = db_config['type']
270
+ gr.Markdown(f"# tl/dw: Your LLM-powered Research Multi-tool")
271
+ gr.Markdown(f"(Using {db_type.capitalize()} Database)")
272
+ with gr.Tabs():
273
+ with gr.TabItem("Transcription / Summarization / Ingestion", id="ingestion-grouping"):
274
+ with gr.Tabs():
275
+ create_video_transcription_tab()
276
+ create_audio_processing_tab()
277
+ create_podcast_tab()
278
+ create_import_book_tab()
279
+ create_plain_text_import_tab()
280
+ create_website_scraping_tab()
281
+ create_pdf_ingestion_tab()
282
+ create_pdf_ingestion_test_tab()
283
+ create_resummary_tab()
284
+ create_summarize_explain_tab()
285
+ create_live_recording_tab()
286
+ create_arxiv_tab()
287
+
288
+ with gr.TabItem("Text Search", id="text search"):
289
+ create_search_tab()
290
+ create_search_summaries_tab()
291
+
292
+ with gr.TabItem("RAG Chat+Notes", id="RAG Chat Notes group"):
293
+ create_rag_qa_chat_notes_tab()
294
+
295
+ with gr.TabItem("RAG Search", id="RAG Search grou"):
296
+ create_rag_tab()
297
+ create_rag_qa_chat_tab()
298
+
299
+ with gr.TabItem("Chat with an LLM", id="LLM Chat group"):
300
+ create_chat_interface()
301
+ create_chat_interface_stacked()
302
+ create_chat_interface_multi_api()
303
+ create_chat_interface_four()
304
+ create_chat_with_llamafile_tab()
305
+ create_chat_management_tab()
306
+ chat_workflows_tab()
307
+
308
+
309
+ with gr.TabItem("Character Chat", id="character chat group"):
310
+ with gr.Tabs():
311
+ create_character_card_interaction_tab()
312
+ create_character_chat_mgmt_tab()
313
+ create_custom_character_card_tab()
314
+ create_character_card_validation_tab()
315
+ create_multiple_character_chat_tab()
316
+ create_narrator_controlled_conversation_tab()
317
+ create_export_characters_tab()
318
+
319
+
320
+ with gr.TabItem("View DB Items", id="view db items group"):
321
+ # This one works
322
+ create_view_all_with_versions_tab()
323
+ # This one is WIP
324
+ create_viewing_tab()
325
+ create_prompt_view_tab()
326
+
327
+
328
+ with gr.TabItem("Prompts", id='view prompts group'):
329
+ create_prompt_view_tab()
330
+ create_prompt_search_tab()
331
+ create_prompt_edit_tab()
332
+ create_prompt_clone_tab()
333
+ create_prompt_suggestion_tab()
334
+
335
+
336
+ with gr.TabItem("Manage / Edit Existing Items", id="manage group"):
337
+ create_media_edit_tab()
338
+ create_manage_items_tab()
339
+ create_media_edit_and_clone_tab()
340
+ # FIXME
341
+ #create_compare_transcripts_tab()
342
+
343
+
344
+ with gr.TabItem("Embeddings Management", id="embeddings group"):
345
+ create_embeddings_tab()
346
+ create_view_embeddings_tab()
347
+ create_purge_embeddings_tab()
348
+
349
+ with gr.TabItem("Writing Tools", id="writing_tools group"):
350
+ from App_Function_Libraries.Gradio_UI.Writing_tab import create_document_feedback_tab
351
+ create_document_feedback_tab()
352
+ from App_Function_Libraries.Gradio_UI.Writing_tab import create_grammar_style_check_tab
353
+ create_grammar_style_check_tab()
354
+ from App_Function_Libraries.Gradio_UI.Writing_tab import create_tone_adjustment_tab
355
+ create_tone_adjustment_tab()
356
+ from App_Function_Libraries.Gradio_UI.Writing_tab import create_creative_writing_tab
357
+ create_creative_writing_tab()
358
+ from App_Function_Libraries.Gradio_UI.Writing_tab import create_mikupad_tab
359
+ create_mikupad_tab()
360
+
361
+
362
+ with gr.TabItem("Keywords", id="keywords group"):
363
+ create_view_keywords_tab()
364
+ create_add_keyword_tab()
365
+ create_delete_keyword_tab()
366
+ create_export_keywords_tab()
367
+
368
+ with gr.TabItem("Import", id="import group"):
369
+ create_import_item_tab()
370
+ create_import_obsidian_vault_tab()
371
+ create_import_single_prompt_tab()
372
+ create_import_multiple_prompts_tab()
373
+ create_mediawiki_import_tab()
374
+ create_mediawiki_config_tab()
375
+
376
+ with gr.TabItem("Export", id="export group"):
377
+ create_export_tab()
378
+
379
+ with gr.TabItem("Backup Management", id="backup group"):
380
+ create_backup_tab()
381
+ create_view_backups_tab()
382
+ create_restore_backup_tab()
383
+
384
+ with gr.TabItem("Utilities", id="util group"):
385
+ create_utilities_yt_video_tab()
386
+ create_utilities_yt_audio_tab()
387
+ create_utilities_yt_timestamp_tab()
388
+
389
+ with gr.TabItem("Local LLM", id="local llm group"):
390
+ create_chat_with_llamafile_tab()
391
+ create_ollama_tab()
392
+ #create_huggingface_tab()
393
+
394
+ with gr.TabItem("Trashcan", id="trashcan group"):
395
+ create_search_and_mark_trash_tab()
396
+ create_view_trash_tab()
397
+ create_delete_trash_tab()
398
+ create_empty_trash_tab()
399
+
400
+ with gr.TabItem("Evaluations", id="eval"):
401
+ create_geval_tab()
402
+ create_infinite_bench_tab()
403
+ # FIXME
404
+ #create_mmlu_pro_tab()
405
+
406
+ with gr.TabItem("Introduction/Help", id="introduction group"):
407
+ create_introduction_tab()
408
+
409
+ with gr.TabItem("Config Editor", id="config group"):
410
+ create_config_editor_tab()
411
+
412
+ # Launch the interface
413
+ server_port_variable = 7860
414
+ os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
415
+ if share==True:
416
+ iface.launch(share=True)
417
+ elif server_mode and not share_public:
418
+ iface.launch(share=False, server_name="0.0.0.0", server_port=server_port_variable, )
419
+ else:
420
+ try:
421
+ iface.launch(share=False, server_name="0.0.0.0", server_port=server_port_variable, )
422
+ except Exception as e:
423
+ logging.error(f"Error launching interface: {str(e)}")