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