oceansweep
commited on
Commit
•
a58290d
1
Parent(s):
8d6800a
Upload 40 files
Browse files- App_Function_Libraries/Gradio_Related.py +412 -394
- App_Function_Libraries/Gradio_UI/Audio_ingestion_tab.py +14 -2
- App_Function_Libraries/Gradio_UI/Introduction_tab.py +17 -11
- App_Function_Libraries/Gradio_UI/Live_Recording.py +123 -43
- App_Function_Libraries/Gradio_UI/Podcast_tab.py +3 -1
- App_Function_Libraries/Gradio_UI/RAG_Chat_tab.py +1 -1
- App_Function_Libraries/Gradio_UI/RAG_QA_Chat_tab.py +1 -1
App_Function_Libraries/Gradio_Related.py
CHANGED
@@ -1,394 +1,412 @@
|
|
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, \
|
21 |
-
create_character_card_interaction_tab, create_character_chat_mgmt_tab, create_custom_character_card_tab, \
|
22 |
-
create_character_card_validation_tab
|
23 |
-
from App_Function_Libraries.Gradio_UI.Character_interaction_tab import create_narrator_controlled_conversation_tab, \
|
24 |
-
create_multiple_character_chat_tab
|
25 |
-
from App_Function_Libraries.Gradio_UI.Chat_ui import create_chat_management_tab, \
|
26 |
-
create_chat_interface_four, create_chat_interface_multi_api, create_chat_interface_stacked, create_chat_interface
|
27 |
-
from App_Function_Libraries.Gradio_UI.Config_tab import create_config_editor_tab
|
28 |
-
from App_Function_Libraries.Gradio_UI.Explain_summarize_tab import create_summarize_explain_tab
|
29 |
-
from App_Function_Libraries.Gradio_UI.Export_Functionality import create_export_tab
|
30 |
-
from App_Function_Libraries.Gradio_UI.Backup_Functionality import create_backup_tab, create_view_backups_tab, \
|
31 |
-
create_restore_backup_tab
|
32 |
-
from App_Function_Libraries.Gradio_UI.Import_Functionality import create_import_single_prompt_tab, \
|
33 |
-
create_import_obsidian_vault_tab, create_import_item_tab, create_import_multiple_prompts_tab
|
34 |
-
from App_Function_Libraries.Gradio_UI.Introduction_tab import create_introduction_tab
|
35 |
-
from App_Function_Libraries.Gradio_UI.Keywords import create_view_keywords_tab, create_add_keyword_tab, \
|
36 |
-
create_delete_keyword_tab, create_export_keywords_tab
|
37 |
-
from App_Function_Libraries.Gradio_UI.
|
38 |
-
from App_Function_Libraries.Gradio_UI.
|
39 |
-
|
40 |
-
from App_Function_Libraries.Gradio_UI.
|
41 |
-
|
42 |
-
from App_Function_Libraries.Gradio_UI.
|
43 |
-
from App_Function_Libraries.Gradio_UI.
|
44 |
-
from App_Function_Libraries.Gradio_UI.
|
45 |
-
from App_Function_Libraries.Gradio_UI.
|
46 |
-
from App_Function_Libraries.Gradio_UI.
|
47 |
-
from App_Function_Libraries.Gradio_UI.
|
48 |
-
|
49 |
-
from App_Function_Libraries.Gradio_UI.
|
50 |
-
|
51 |
-
|
52 |
-
from App_Function_Libraries.Gradio_UI.
|
53 |
-
|
54 |
-
from App_Function_Libraries.Gradio_UI.
|
55 |
-
|
56 |
-
from App_Function_Libraries.Gradio_UI.
|
57 |
-
|
58 |
-
from App_Function_Libraries.Gradio_UI.
|
59 |
-
from App_Function_Libraries.Gradio_UI.
|
60 |
-
from App_Function_Libraries.Gradio_UI.
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
#
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
**
|
84 |
-
|
85 |
-
|
86 |
-
-
|
87 |
-
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
**
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
#
|
101 |
-
|
102 |
-
#
|
103 |
-
# Functions
|
104 |
-
#
|
105 |
-
#
|
106 |
-
#
|
107 |
-
|
108 |
-
#
|
109 |
-
|
110 |
-
# Functions
|
111 |
-
#
|
112 |
-
#
|
113 |
-
#
|
114 |
-
|
115 |
-
#
|
116 |
-
|
117 |
-
#
|
118 |
-
#
|
119 |
-
#
|
120 |
-
#
|
121 |
-
#
|
122 |
-
|
123 |
-
#
|
124 |
-
|
125 |
-
#
|
126 |
-
#
|
127 |
-
#
|
128 |
-
#
|
129 |
-
#
|
130 |
-
|
131 |
-
#
|
132 |
-
|
133 |
-
#
|
134 |
-
#
|
135 |
-
#
|
136 |
-
#
|
137 |
-
#
|
138 |
-
#
|
139 |
-
|
140 |
-
#
|
141 |
-
|
142 |
-
#
|
143 |
-
#
|
144 |
-
#
|
145 |
-
#
|
146 |
-
#
|
147 |
-
|
148 |
-
#
|
149 |
-
|
150 |
-
#
|
151 |
-
# Functions
|
152 |
-
#
|
153 |
-
#
|
154 |
-
#
|
155 |
-
#
|
156 |
-
|
157 |
-
#
|
158 |
-
|
159 |
-
#
|
160 |
-
#
|
161 |
-
#
|
162 |
-
|
163 |
-
#
|
164 |
-
|
165 |
-
#
|
166 |
-
#
|
167 |
-
|
168 |
-
#
|
169 |
-
|
170 |
-
#
|
171 |
-
# Functions
|
172 |
-
#
|
173 |
-
#
|
174 |
-
|
175 |
-
#
|
176 |
-
|
177 |
-
#
|
178 |
-
# Functions
|
179 |
-
#
|
180 |
-
#
|
181 |
-
#
|
182 |
-
#
|
183 |
-
|
184 |
-
#
|
185 |
-
|
186 |
-
#
|
187 |
-
# Functions
|
188 |
-
#
|
189 |
-
#
|
190 |
-
#
|
191 |
-
#
|
192 |
-
|
193 |
-
#
|
194 |
-
|
195 |
-
#
|
196 |
-
# Functions
|
197 |
-
#
|
198 |
-
#
|
199 |
-
#
|
200 |
-
|
201 |
-
#
|
202 |
-
|
203 |
-
#
|
204 |
-
#
|
205 |
-
#
|
206 |
-
|
207 |
-
#
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
#
|
214 |
-
#
|
215 |
-
#
|
216 |
-
#
|
217 |
-
# "
|
218 |
-
#
|
219 |
-
#
|
220 |
-
#
|
221 |
-
#
|
222 |
-
#
|
223 |
-
# "
|
224 |
-
#
|
225 |
-
#
|
226 |
-
#
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
gr.
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
with gr.TabItem("
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
with gr.TabItem("
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
with gr.TabItem("
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, \
|
21 |
+
create_character_card_interaction_tab, create_character_chat_mgmt_tab, create_custom_character_card_tab, \
|
22 |
+
create_character_card_validation_tab
|
23 |
+
from App_Function_Libraries.Gradio_UI.Character_interaction_tab import create_narrator_controlled_conversation_tab, \
|
24 |
+
create_multiple_character_chat_tab
|
25 |
+
from App_Function_Libraries.Gradio_UI.Chat_ui import create_chat_management_tab, \
|
26 |
+
create_chat_interface_four, create_chat_interface_multi_api, create_chat_interface_stacked, create_chat_interface
|
27 |
+
from App_Function_Libraries.Gradio_UI.Config_tab import create_config_editor_tab
|
28 |
+
from App_Function_Libraries.Gradio_UI.Explain_summarize_tab import create_summarize_explain_tab
|
29 |
+
from App_Function_Libraries.Gradio_UI.Export_Functionality import create_export_tab
|
30 |
+
from App_Function_Libraries.Gradio_UI.Backup_Functionality import create_backup_tab, create_view_backups_tab, \
|
31 |
+
create_restore_backup_tab
|
32 |
+
from App_Function_Libraries.Gradio_UI.Import_Functionality import create_import_single_prompt_tab, \
|
33 |
+
create_import_obsidian_vault_tab, create_import_item_tab, create_import_multiple_prompts_tab
|
34 |
+
from App_Function_Libraries.Gradio_UI.Introduction_tab import create_introduction_tab
|
35 |
+
from App_Function_Libraries.Gradio_UI.Keywords import create_view_keywords_tab, create_add_keyword_tab, \
|
36 |
+
create_delete_keyword_tab, create_export_keywords_tab
|
37 |
+
from App_Function_Libraries.Gradio_UI.Live_Recording import create_live_recording_tab
|
38 |
+
from App_Function_Libraries.Gradio_UI.Llamafile_tab import create_chat_with_llamafile_tab
|
39 |
+
#from App_Function_Libraries.Gradio_UI.MMLU_Pro_tab import create_mmlu_pro_tab
|
40 |
+
from App_Function_Libraries.Gradio_UI.Media_edit import create_prompt_clone_tab, create_prompt_edit_tab, \
|
41 |
+
create_media_edit_and_clone_tab, create_media_edit_tab
|
42 |
+
from App_Function_Libraries.Gradio_UI.Media_wiki_tab import create_mediawiki_import_tab, create_mediawiki_config_tab
|
43 |
+
from App_Function_Libraries.Gradio_UI.PDF_ingestion_tab import create_pdf_ingestion_tab, create_pdf_ingestion_test_tab
|
44 |
+
from App_Function_Libraries.Gradio_UI.Plaintext_tab_import import create_plain_text_import_tab
|
45 |
+
from App_Function_Libraries.Gradio_UI.Podcast_tab import create_podcast_tab
|
46 |
+
from App_Function_Libraries.Gradio_UI.Prompt_Suggestion_tab import create_prompt_suggestion_tab
|
47 |
+
from App_Function_Libraries.Gradio_UI.RAG_QA_Chat_tab import create_rag_qa_chat_tab
|
48 |
+
from App_Function_Libraries.Gradio_UI.Re_summarize_tab import create_resummary_tab
|
49 |
+
from App_Function_Libraries.Gradio_UI.Search_Tab import create_prompt_search_tab, \
|
50 |
+
create_search_summaries_tab, create_search_tab
|
51 |
+
from App_Function_Libraries.Gradio_UI.RAG_Chat_tab import create_rag_tab
|
52 |
+
from App_Function_Libraries.Gradio_UI.Embeddings_tab import create_embeddings_tab, create_view_embeddings_tab, \
|
53 |
+
create_purge_embeddings_tab
|
54 |
+
from App_Function_Libraries.Gradio_UI.Trash import create_view_trash_tab, create_empty_trash_tab, \
|
55 |
+
create_delete_trash_tab, create_search_and_mark_trash_tab
|
56 |
+
from App_Function_Libraries.Gradio_UI.Utilities import create_utilities_yt_timestamp_tab, create_utilities_yt_audio_tab, \
|
57 |
+
create_utilities_yt_video_tab
|
58 |
+
from App_Function_Libraries.Gradio_UI.Video_transcription_tab import create_video_transcription_tab
|
59 |
+
from App_Function_Libraries.Gradio_UI.View_tab import create_manage_items_tab
|
60 |
+
from App_Function_Libraries.Gradio_UI.Website_scraping_tab import create_website_scraping_tab
|
61 |
+
from App_Function_Libraries.Gradio_UI.Chat_Workflows import chat_workflows_tab
|
62 |
+
from App_Function_Libraries.Gradio_UI.View_DB_Items_tab import create_prompt_view_tab, \
|
63 |
+
create_view_all_with_versions_tab, create_viewing_tab
|
64 |
+
#
|
65 |
+
# Gradio UI Imports
|
66 |
+
from App_Function_Libraries.Gradio_UI.Evaluations_Benchmarks_tab import create_geval_tab, create_infinite_bench_tab
|
67 |
+
|
68 |
+
#
|
69 |
+
#######################################################################################################################
|
70 |
+
# Function Definitions
|
71 |
+
#
|
72 |
+
|
73 |
+
|
74 |
+
# Disable Gradio Analytics
|
75 |
+
os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
|
76 |
+
|
77 |
+
|
78 |
+
custom_prompt_input = None
|
79 |
+
server_mode = False
|
80 |
+
share_public = False
|
81 |
+
custom_prompt_summarize_bulleted_notes = ("""
|
82 |
+
<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]
|
83 |
+
**Bulleted Note Creation Guidelines**
|
84 |
+
|
85 |
+
**Headings**:
|
86 |
+
- Based on referenced topics, not categories like quotes or terms
|
87 |
+
- Surrounded by **bold** formatting
|
88 |
+
- Not listed as bullet points
|
89 |
+
- No space between headings and list items underneath
|
90 |
+
|
91 |
+
**Emphasis**:
|
92 |
+
- **Important terms** set in bold font
|
93 |
+
- **Text ending in a colon**: also bolded
|
94 |
+
|
95 |
+
**Review**:
|
96 |
+
- Ensure adherence to specified format
|
97 |
+
- Do not reference these instructions in your response.</s>[INST] {{ .Prompt }} [/INST]
|
98 |
+
""")
|
99 |
+
#
|
100 |
+
# End of globals
|
101 |
+
#######################################################################################################################
|
102 |
+
#
|
103 |
+
# Start of Video/Audio Transcription and Summarization Functions
|
104 |
+
#
|
105 |
+
# Functions:
|
106 |
+
# FIXME
|
107 |
+
#
|
108 |
+
#
|
109 |
+
################################################################################################################
|
110 |
+
# Functions for Re-Summarization
|
111 |
+
#
|
112 |
+
# Functions:
|
113 |
+
# FIXME
|
114 |
+
# End of Re-Summarization Functions
|
115 |
+
#
|
116 |
+
############################################################################################################################################################################################################################
|
117 |
+
#
|
118 |
+
# Explain/Summarize This Tab
|
119 |
+
#
|
120 |
+
# Functions:
|
121 |
+
# FIXME
|
122 |
+
#
|
123 |
+
#
|
124 |
+
############################################################################################################################################################################################################################
|
125 |
+
#
|
126 |
+
# Transcript Comparison Tab
|
127 |
+
#
|
128 |
+
# Functions:
|
129 |
+
# FIXME
|
130 |
+
#
|
131 |
+
#
|
132 |
+
###########################################################################################################################################################################################################################
|
133 |
+
#
|
134 |
+
# Search Tab
|
135 |
+
#
|
136 |
+
# Functions:
|
137 |
+
# FIXME
|
138 |
+
#
|
139 |
+
# End of Search Tab Functions
|
140 |
+
#
|
141 |
+
##############################################################################################################################################################################################################################
|
142 |
+
#
|
143 |
+
# Llamafile Tab
|
144 |
+
#
|
145 |
+
# Functions:
|
146 |
+
# FIXME
|
147 |
+
#
|
148 |
+
# End of Llamafile Tab Functions
|
149 |
+
##############################################################################################################################################################################################################################
|
150 |
+
#
|
151 |
+
# Chat Interface Tab Functions
|
152 |
+
#
|
153 |
+
# Functions:
|
154 |
+
# FIXME
|
155 |
+
#
|
156 |
+
#
|
157 |
+
# End of Chat Interface Tab Functions
|
158 |
+
################################################################################################################################################################################################################################
|
159 |
+
#
|
160 |
+
# Media Edit Tab Functions
|
161 |
+
# Functions:
|
162 |
+
# Fixme
|
163 |
+
# create_media_edit_tab():
|
164 |
+
##### Trash Tab
|
165 |
+
# FIXME
|
166 |
+
# Functions:
|
167 |
+
#
|
168 |
+
# End of Media Edit Tab Functions
|
169 |
+
################################################################################################################
|
170 |
+
#
|
171 |
+
# Import Items Tab Functions
|
172 |
+
#
|
173 |
+
# Functions:
|
174 |
+
#FIXME
|
175 |
+
# End of Import Items Tab Functions
|
176 |
+
################################################################################################################
|
177 |
+
#
|
178 |
+
# Export Items Tab Functions
|
179 |
+
#
|
180 |
+
# Functions:
|
181 |
+
# FIXME
|
182 |
+
#
|
183 |
+
#
|
184 |
+
# End of Export Items Tab Functions
|
185 |
+
################################################################################################################
|
186 |
+
#
|
187 |
+
# Keyword Management Tab Functions
|
188 |
+
#
|
189 |
+
# Functions:
|
190 |
+
# create_view_keywords_tab():
|
191 |
+
# FIXME
|
192 |
+
#
|
193 |
+
# End of Keyword Management Tab Functions
|
194 |
+
################################################################################################################
|
195 |
+
#
|
196 |
+
# Document Editing Tab Functions
|
197 |
+
#
|
198 |
+
# Functions:
|
199 |
+
# #FIXME
|
200 |
+
#
|
201 |
+
#
|
202 |
+
################################################################################################################
|
203 |
+
#
|
204 |
+
# Utilities Tab Functions
|
205 |
+
# Functions:
|
206 |
+
# create_utilities_yt_video_tab():
|
207 |
+
# #FIXME
|
208 |
+
|
209 |
+
#
|
210 |
+
# End of Utilities Tab Functions
|
211 |
+
################################################################################################################
|
212 |
+
|
213 |
+
# FIXME - Prompt sample box
|
214 |
+
#
|
215 |
+
# # Sample data
|
216 |
+
# prompts_category_1 = [
|
217 |
+
# "What are the key points discussed in the video?",
|
218 |
+
# "Summarize the main arguments made by the speaker.",
|
219 |
+
# "Describe the conclusions of the study presented."
|
220 |
+
# ]
|
221 |
+
#
|
222 |
+
# prompts_category_2 = [
|
223 |
+
# "How does the proposed solution address the problem?",
|
224 |
+
# "What are the implications of the findings?",
|
225 |
+
# "Can you explain the theory behind the observed phenomenon?"
|
226 |
+
# ]
|
227 |
+
#
|
228 |
+
# all_prompts2 = prompts_category_1 + prompts_category_2
|
229 |
+
|
230 |
+
|
231 |
+
def launch_ui(share_public=None, server_mode=False):
|
232 |
+
share=share_public
|
233 |
+
css = """
|
234 |
+
.result-box {
|
235 |
+
margin-bottom: 20px;
|
236 |
+
border: 1px solid #ddd;
|
237 |
+
padding: 10px;
|
238 |
+
}
|
239 |
+
.result-box.error {
|
240 |
+
border-color: #ff0000;
|
241 |
+
background-color: #ffeeee;
|
242 |
+
}
|
243 |
+
.transcription, .summary {
|
244 |
+
max-height: 800px;
|
245 |
+
overflow-y: auto;
|
246 |
+
border: 1px solid #eee;
|
247 |
+
padding: 10px;
|
248 |
+
margin-top: 10px;
|
249 |
+
}
|
250 |
+
"""
|
251 |
+
|
252 |
+
with gr.Blocks(theme='bethecloud/storj_theme',css=css) as iface:
|
253 |
+
gr.HTML(
|
254 |
+
"""
|
255 |
+
<script>
|
256 |
+
document.addEventListener('DOMContentLoaded', (event) => {
|
257 |
+
document.body.classList.add('dark');
|
258 |
+
document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)';
|
259 |
+
});
|
260 |
+
</script>
|
261 |
+
"""
|
262 |
+
)
|
263 |
+
db_config = get_db_config()
|
264 |
+
db_type = db_config['type']
|
265 |
+
gr.Markdown(f"# tl/dw: Your LLM-powered Research Multi-tool")
|
266 |
+
gr.Markdown(f"(Using {db_type.capitalize()} Database)")
|
267 |
+
with gr.Tabs():
|
268 |
+
with gr.TabItem("Transcription / Summarization / Ingestion"):
|
269 |
+
with gr.Tabs():
|
270 |
+
create_video_transcription_tab()
|
271 |
+
create_audio_processing_tab()
|
272 |
+
create_podcast_tab()
|
273 |
+
create_import_book_tab()
|
274 |
+
create_plain_text_import_tab()
|
275 |
+
create_website_scraping_tab()
|
276 |
+
create_pdf_ingestion_tab()
|
277 |
+
create_pdf_ingestion_test_tab()
|
278 |
+
create_resummary_tab()
|
279 |
+
create_summarize_explain_tab()
|
280 |
+
create_live_recording_tab()
|
281 |
+
create_arxiv_tab()
|
282 |
+
|
283 |
+
with gr.TabItem("Text Search "):
|
284 |
+
create_search_tab()
|
285 |
+
create_search_summaries_tab()
|
286 |
+
|
287 |
+
|
288 |
+
with gr.TabItem("RAG Search"):
|
289 |
+
create_rag_tab()
|
290 |
+
create_rag_qa_chat_tab()
|
291 |
+
|
292 |
+
|
293 |
+
with gr.TabItem("Chat with an LLM"):
|
294 |
+
create_chat_interface()
|
295 |
+
create_chat_interface_stacked()
|
296 |
+
create_chat_interface_multi_api()
|
297 |
+
create_chat_interface_four()
|
298 |
+
create_chat_with_llamafile_tab()
|
299 |
+
create_chat_management_tab()
|
300 |
+
chat_workflows_tab()
|
301 |
+
|
302 |
+
|
303 |
+
with gr.TabItem("Character Chat"):
|
304 |
+
with gr.Tabs():
|
305 |
+
create_character_card_interaction_tab()
|
306 |
+
create_character_chat_mgmt_tab()
|
307 |
+
create_custom_character_card_tab()
|
308 |
+
create_character_card_validation_tab()
|
309 |
+
create_multiple_character_chat_tab()
|
310 |
+
create_narrator_controlled_conversation_tab()
|
311 |
+
|
312 |
+
|
313 |
+
with gr.TabItem("View DB Items"):
|
314 |
+
# This one works
|
315 |
+
create_view_all_with_versions_tab()
|
316 |
+
# This one is WIP
|
317 |
+
create_viewing_tab()
|
318 |
+
create_prompt_view_tab()
|
319 |
+
|
320 |
+
|
321 |
+
with gr.TabItem("Prompts"):
|
322 |
+
create_prompt_view_tab()
|
323 |
+
create_prompt_search_tab()
|
324 |
+
create_prompt_edit_tab()
|
325 |
+
create_prompt_clone_tab()
|
326 |
+
create_prompt_suggestion_tab()
|
327 |
+
|
328 |
+
|
329 |
+
with gr.TabItem("Manage / Edit Existing Items"):
|
330 |
+
create_media_edit_tab()
|
331 |
+
create_manage_items_tab()
|
332 |
+
create_media_edit_and_clone_tab()
|
333 |
+
# FIXME
|
334 |
+
#create_compare_transcripts_tab()
|
335 |
+
|
336 |
+
|
337 |
+
with gr.TabItem("Embeddings Management"):
|
338 |
+
create_embeddings_tab()
|
339 |
+
create_view_embeddings_tab()
|
340 |
+
create_purge_embeddings_tab()
|
341 |
+
|
342 |
+
with gr.TabItem("Writing Tools"):
|
343 |
+
with gr.Tabs():
|
344 |
+
from App_Function_Libraries.Gradio_UI.Writing_tab import create_document_feedback_tab
|
345 |
+
create_document_feedback_tab()
|
346 |
+
from App_Function_Libraries.Gradio_UI.Writing_tab import create_grammar_style_check_tab
|
347 |
+
create_grammar_style_check_tab()
|
348 |
+
from App_Function_Libraries.Gradio_UI.Writing_tab import create_tone_adjustment_tab
|
349 |
+
create_tone_adjustment_tab()
|
350 |
+
from App_Function_Libraries.Gradio_UI.Writing_tab import create_creative_writing_tab
|
351 |
+
create_creative_writing_tab()
|
352 |
+
from App_Function_Libraries.Gradio_UI.Writing_tab import create_mikupad_tab
|
353 |
+
create_mikupad_tab()
|
354 |
+
|
355 |
+
|
356 |
+
with gr.TabItem("Keywords"):
|
357 |
+
create_view_keywords_tab()
|
358 |
+
create_add_keyword_tab()
|
359 |
+
create_delete_keyword_tab()
|
360 |
+
create_export_keywords_tab()
|
361 |
+
|
362 |
+
with gr.TabItem("Import"):
|
363 |
+
create_import_item_tab()
|
364 |
+
create_import_obsidian_vault_tab()
|
365 |
+
create_import_single_prompt_tab()
|
366 |
+
create_import_multiple_prompts_tab()
|
367 |
+
create_mediawiki_import_tab()
|
368 |
+
create_mediawiki_config_tab()
|
369 |
+
|
370 |
+
with gr.TabItem("Export"):
|
371 |
+
create_export_tab()
|
372 |
+
|
373 |
+
with gr.TabItem("Backup Management"):
|
374 |
+
create_backup_tab()
|
375 |
+
create_view_backups_tab()
|
376 |
+
create_restore_backup_tab()
|
377 |
+
|
378 |
+
with gr.TabItem("Utilities"):
|
379 |
+
create_utilities_yt_video_tab()
|
380 |
+
create_utilities_yt_audio_tab()
|
381 |
+
create_utilities_yt_timestamp_tab()
|
382 |
+
|
383 |
+
with gr.TabItem("Trashcan"):
|
384 |
+
create_search_and_mark_trash_tab()
|
385 |
+
create_view_trash_tab()
|
386 |
+
create_delete_trash_tab()
|
387 |
+
create_empty_trash_tab()
|
388 |
+
|
389 |
+
with gr.TabItem("Evaluations"):
|
390 |
+
create_geval_tab()
|
391 |
+
create_infinite_bench_tab()
|
392 |
+
# FIXME
|
393 |
+
#create_mmlu_pro_tab()
|
394 |
+
|
395 |
+
with gr.TabItem("Introduction/Help"):
|
396 |
+
create_introduction_tab()
|
397 |
+
|
398 |
+
with gr.TabItem("Config Editor"):
|
399 |
+
create_config_editor_tab()
|
400 |
+
|
401 |
+
# Launch the interface
|
402 |
+
server_port_variable = 7860
|
403 |
+
os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
|
404 |
+
if share==True:
|
405 |
+
iface.launch(share=True)
|
406 |
+
elif server_mode and not share_public:
|
407 |
+
iface.launch(share=False, server_name="0.0.0.0", server_port=server_port_variable, )
|
408 |
+
else:
|
409 |
+
try:
|
410 |
+
iface.launch(share=False, server_name="0.0.0.0", server_port=server_port_variable, )
|
411 |
+
except Exception as e:
|
412 |
+
logging.error(f"Error launching interface: {str(e)}")
|
App_Function_Libraries/Gradio_UI/Audio_ingestion_tab.py
CHANGED
@@ -11,6 +11,7 @@ from App_Function_Libraries.Audio.Audio_Files import process_audio_files
|
|
11 |
from App_Function_Libraries.DB.DB_Manager import load_preset_prompts
|
12 |
from App_Function_Libraries.Gradio_UI.Chat_ui import update_user_prompt
|
13 |
from App_Function_Libraries.Gradio_UI.Gradio_Shared import whisper_models
|
|
|
14 |
#
|
15 |
#######################################################################################################################
|
16 |
# Functions:
|
@@ -22,7 +23,7 @@ def create_audio_processing_tab():
|
|
22 |
with gr.Column():
|
23 |
audio_url_input = gr.Textbox(label="Audio File URL(s)", placeholder="Enter the URL(s) of the audio file(s), one per line")
|
24 |
audio_file_input = gr.File(label="Upload Audio File", file_types=["audio/*"])
|
25 |
-
|
26 |
use_cookies_input = gr.Checkbox(label="Use cookies for authenticated download", value=False)
|
27 |
cookies_input = gr.Textbox(
|
28 |
label="Audio Download Cookies",
|
@@ -39,6 +40,7 @@ def create_audio_processing_tab():
|
|
39 |
|
40 |
diarize_input = gr.Checkbox(label="Enable Speaker Diarization", value=False)
|
41 |
whisper_model_input = gr.Dropdown(choices=whisper_models, value="medium", label="Whisper Model")
|
|
|
42 |
|
43 |
with gr.Row():
|
44 |
custom_prompt_checkbox = gr.Checkbox(label="Use a Custom Prompt",
|
@@ -143,10 +145,20 @@ def create_audio_processing_tab():
|
|
143 |
inputs=[audio_url_input, audio_file_input, whisper_model_input, api_name_input, api_key_input,
|
144 |
use_cookies_input, cookies_input, keep_original_input, custom_keywords_input, custom_prompt_input,
|
145 |
chunk_method, max_chunk_size, chunk_overlap, use_adaptive_chunking, use_multi_level_chunking,
|
146 |
-
chunk_language, diarize_input],
|
147 |
outputs=[audio_progress_output, audio_transcription_output, audio_summary_output]
|
148 |
)
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
#
|
151 |
# End of Audio_ingestion_tab.py
|
152 |
#######################################################################################################################
|
|
|
11 |
from App_Function_Libraries.DB.DB_Manager import load_preset_prompts
|
12 |
from App_Function_Libraries.Gradio_UI.Chat_ui import update_user_prompt
|
13 |
from App_Function_Libraries.Gradio_UI.Gradio_Shared import whisper_models
|
14 |
+
from App_Function_Libraries.Utils.Utils import cleanup_temp_files
|
15 |
#
|
16 |
#######################################################################################################################
|
17 |
# Functions:
|
|
|
23 |
with gr.Column():
|
24 |
audio_url_input = gr.Textbox(label="Audio File URL(s)", placeholder="Enter the URL(s) of the audio file(s), one per line")
|
25 |
audio_file_input = gr.File(label="Upload Audio File", file_types=["audio/*"])
|
26 |
+
custom_title_input = gr.Textbox(label="Custom Title/Name", placeholder="Enter a custom title or name for the audio file")
|
27 |
use_cookies_input = gr.Checkbox(label="Use cookies for authenticated download", value=False)
|
28 |
cookies_input = gr.Textbox(
|
29 |
label="Audio Download Cookies",
|
|
|
40 |
|
41 |
diarize_input = gr.Checkbox(label="Enable Speaker Diarization", value=False)
|
42 |
whisper_model_input = gr.Dropdown(choices=whisper_models, value="medium", label="Whisper Model")
|
43 |
+
keep_timestamps_input = gr.Checkbox(label="Keep Timestamps", value=True)
|
44 |
|
45 |
with gr.Row():
|
46 |
custom_prompt_checkbox = gr.Checkbox(label="Use a Custom Prompt",
|
|
|
145 |
inputs=[audio_url_input, audio_file_input, whisper_model_input, api_name_input, api_key_input,
|
146 |
use_cookies_input, cookies_input, keep_original_input, custom_keywords_input, custom_prompt_input,
|
147 |
chunk_method, max_chunk_size, chunk_overlap, use_adaptive_chunking, use_multi_level_chunking,
|
148 |
+
chunk_language, diarize_input, keep_timestamps_input, custom_title_input],
|
149 |
outputs=[audio_progress_output, audio_transcription_output, audio_summary_output]
|
150 |
)
|
151 |
|
152 |
+
def on_file_clear(file):
|
153 |
+
if file is None:
|
154 |
+
cleanup_temp_files()
|
155 |
+
|
156 |
+
audio_file_input.clear(
|
157 |
+
fn=on_file_clear,
|
158 |
+
inputs=[audio_file_input],
|
159 |
+
outputs=[]
|
160 |
+
)
|
161 |
+
|
162 |
#
|
163 |
# End of Audio_ingestion_tab.py
|
164 |
#######################################################################################################################
|
App_Function_Libraries/Gradio_UI/Introduction_tab.py
CHANGED
@@ -1,16 +1,18 @@
|
|
1 |
# Introduction_tab.py
|
2 |
# Gradio UI functions for the Introduction tab
|
3 |
-
|
4 |
# Imports
|
5 |
#
|
6 |
# External Imports
|
7 |
import gradio as gr
|
8 |
-
|
9 |
-
from App_Function_Libraries.DB.DB_Manager import get_db_config
|
10 |
-
|
11 |
-
|
12 |
#
|
13 |
# Local Imports
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
def create_introduction_tab():
|
@@ -36,7 +38,7 @@ def create_introduction_tab():
|
|
36 |
- Writing Tools: Grammar & Style check, Tone Analyzer & Editor, more planned...
|
37 |
- RAG (Retrieval-Augmented Generation) support for content generation(think about asking questions about your entire library of items)
|
38 |
- More features planned...
|
39 |
-
- All powered by your choice of LLM.
|
40 |
- Currently supports: Local-LLM(llamafile-server), OpenAI, Anthropic, Cohere, Groq, DeepSeek, OpenRouter, Llama.cpp, Kobold, Ooba, Tabbyapi, VLLM and more to come...
|
41 |
- All data is stored locally in a SQLite database for easy access and management.
|
42 |
- No trackers (Gradio has some analytics but it's disabled here...)
|
@@ -85,7 +87,7 @@ def create_introduction_tab():
|
|
85 |
with gr.Row():
|
86 |
gr.Markdown("""### HELP! I don't know what any of this this shit is!
|
87 |
### DON'T PANIC
|
88 |
-
#### Its ok, you're not alone, most people have no clue what any of this stuff is.
|
89 |
- So let's try and fix that.
|
90 |
|
91 |
#### Introduction to LLMs:
|
@@ -96,7 +98,7 @@ def create_introduction_tab():
|
|
96 |
|
97 |
#### Various Phrases & Terms to know
|
98 |
- **LLM** - Large Language Model - A type of neural network that can generate human-like text.
|
99 |
-
- **API** - Application Programming Interface - A set of rules and protocols that allows one software application to communicate with another.
|
100 |
* Think of it like a post address for a piece of software. You can send messages to and from it.
|
101 |
- **API Key** - A unique identifier that is used to authenticate a user, developer, or calling program to an API.
|
102 |
* Like the key to a post office box. You need it to access the contents.
|
@@ -143,10 +145,10 @@ def create_introduction_tab():
|
|
143 |
- **Llama.cpp Inference Engine:**
|
144 |
* Download the latest release for your platform here: https://github.com/ggerganov/llama.cpp/releases
|
145 |
* Windows: `llama-<release_number>-bin-win-cuda-cu<11.7.1 or 12.2.0 - version depends on installed cuda>-x64.zip`
|
146 |
-
* Run it: `llama-server.exe --model <path_to_model> -ctx 8192 -ngl 999`
|
147 |
- `-ctx 8192` sets the context size to 8192 tokens, `-ngl 999` sets the number of layers to offload to the GPU to 999. (essentially ensuring we only use our GPU and not CPU for processing)
|
148 |
* Macos: `llama-<release_number>-bin-macos-arm64.zip - for Apple Silicon / `llama-<release_number>-bin-macos-x64.zip` - for Intel Macs
|
149 |
-
* Run it: `llama-server --model <path_to_model> -ctx 8192 -ngl 999`
|
150 |
- `-ctx 8192` sets the context size to 8192 tokens, `-ngl 999` sets the number of layers to offload to the GPU to 999. (essentially ensuring we only use our GPU and not CPU for processing)
|
151 |
* Linux: You can probably figure it out.
|
152 |
- **Kobold.cpp Server:**
|
@@ -158,4 +160,8 @@ def create_introduction_tab():
|
|
158 |
1. `On Linux, we provide a koboldcpp-linux-x64 PyInstaller prebuilt binary on the releases page for modern systems. Simply download and run the binary.`
|
159 |
* Alternatively, you can also install koboldcpp to the current directory by running the following terminal command: `curl -fLo koboldcpp https://github.com/LostRuins/koboldcpp/releases/latest/download/koboldcpp-linux-x64 && chmod +x koboldcpp`
|
160 |
2. When you can't use the precompiled binary directly, we provide an automated build script which uses conda to obtain all dependencies, and generates (from source) a ready-to-use a pyinstaller binary for linux users. Simply execute the build script with `./koboldcpp.sh dist` and run the generated binary.
|
161 |
-
""")
|
|
|
|
|
|
|
|
|
|
1 |
# Introduction_tab.py
|
2 |
# Gradio UI functions for the Introduction tab
|
3 |
+
#
|
4 |
# Imports
|
5 |
#
|
6 |
# External Imports
|
7 |
import gradio as gr
|
|
|
|
|
|
|
|
|
8 |
#
|
9 |
# Local Imports
|
10 |
+
from App_Function_Libraries.DB.DB_Manager import get_db_config
|
11 |
+
#
|
12 |
+
####################################################################################################
|
13 |
+
#
|
14 |
+
# Functions:
|
15 |
+
|
16 |
|
17 |
|
18 |
def create_introduction_tab():
|
|
|
38 |
- Writing Tools: Grammar & Style check, Tone Analyzer & Editor, more planned...
|
39 |
- RAG (Retrieval-Augmented Generation) support for content generation(think about asking questions about your entire library of items)
|
40 |
- More features planned...
|
41 |
+
- All powered by your choice of LLM.
|
42 |
- Currently supports: Local-LLM(llamafile-server), OpenAI, Anthropic, Cohere, Groq, DeepSeek, OpenRouter, Llama.cpp, Kobold, Ooba, Tabbyapi, VLLM and more to come...
|
43 |
- All data is stored locally in a SQLite database for easy access and management.
|
44 |
- No trackers (Gradio has some analytics but it's disabled here...)
|
|
|
87 |
with gr.Row():
|
88 |
gr.Markdown("""### HELP! I don't know what any of this this shit is!
|
89 |
### DON'T PANIC
|
90 |
+
#### Its ok, you're not alone, most people have no clue what any of this stuff is.
|
91 |
- So let's try and fix that.
|
92 |
|
93 |
#### Introduction to LLMs:
|
|
|
98 |
|
99 |
#### Various Phrases & Terms to know
|
100 |
- **LLM** - Large Language Model - A type of neural network that can generate human-like text.
|
101 |
+
- **API** - Application Programming Interface - A set of rules and protocols that allows one software application to communicate with another.
|
102 |
* Think of it like a post address for a piece of software. You can send messages to and from it.
|
103 |
- **API Key** - A unique identifier that is used to authenticate a user, developer, or calling program to an API.
|
104 |
* Like the key to a post office box. You need it to access the contents.
|
|
|
145 |
- **Llama.cpp Inference Engine:**
|
146 |
* Download the latest release for your platform here: https://github.com/ggerganov/llama.cpp/releases
|
147 |
* Windows: `llama-<release_number>-bin-win-cuda-cu<11.7.1 or 12.2.0 - version depends on installed cuda>-x64.zip`
|
148 |
+
* Run it: `llama-server.exe --model <path_to_model> -ctx 8192 -ngl 999`
|
149 |
- `-ctx 8192` sets the context size to 8192 tokens, `-ngl 999` sets the number of layers to offload to the GPU to 999. (essentially ensuring we only use our GPU and not CPU for processing)
|
150 |
* Macos: `llama-<release_number>-bin-macos-arm64.zip - for Apple Silicon / `llama-<release_number>-bin-macos-x64.zip` - for Intel Macs
|
151 |
+
* Run it: `llama-server --model <path_to_model> -ctx 8192 -ngl 999`
|
152 |
- `-ctx 8192` sets the context size to 8192 tokens, `-ngl 999` sets the number of layers to offload to the GPU to 999. (essentially ensuring we only use our GPU and not CPU for processing)
|
153 |
* Linux: You can probably figure it out.
|
154 |
- **Kobold.cpp Server:**
|
|
|
160 |
1. `On Linux, we provide a koboldcpp-linux-x64 PyInstaller prebuilt binary on the releases page for modern systems. Simply download and run the binary.`
|
161 |
* Alternatively, you can also install koboldcpp to the current directory by running the following terminal command: `curl -fLo koboldcpp https://github.com/LostRuins/koboldcpp/releases/latest/download/koboldcpp-linux-x64 && chmod +x koboldcpp`
|
162 |
2. When you can't use the precompiled binary directly, we provide an automated build script which uses conda to obtain all dependencies, and generates (from source) a ready-to-use a pyinstaller binary for linux users. Simply execute the build script with `./koboldcpp.sh dist` and run the generated binary.
|
163 |
+
""")
|
164 |
+
|
165 |
+
#
|
166 |
+
# End of Introduction_tab.py
|
167 |
+
####################################################################################################
|
App_Function_Libraries/Gradio_UI/Live_Recording.py
CHANGED
@@ -1,43 +1,123 @@
|
|
1 |
-
# Live_Recording.py
|
2 |
-
# Description: Gradio UI for live audio recording and transcription.
|
3 |
-
#
|
4 |
-
# Import necessary modules and functions
|
5 |
-
import logging
|
6 |
-
import os
|
7 |
-
# External Imports
|
8 |
-
import gradio as gr
|
9 |
-
# Local Imports
|
10 |
-
from App_Function_Libraries.Audio.Audio_Transcription_Lib import (speech_to_text
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
#
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Live_Recording.py
|
2 |
+
# Description: Gradio UI for live audio recording and transcription.
|
3 |
+
#
|
4 |
+
# Import necessary modules and functions
|
5 |
+
import logging
|
6 |
+
import os
|
7 |
+
# External Imports
|
8 |
+
import gradio as gr
|
9 |
+
# Local Imports
|
10 |
+
from App_Function_Libraries.Audio.Audio_Transcription_Lib import (record_audio, speech_to_text, save_audio_temp,
|
11 |
+
stop_recording)
|
12 |
+
from App_Function_Libraries.DB.DB_Manager import add_media_to_database
|
13 |
+
#
|
14 |
+
#######################################################################################################################
|
15 |
+
#
|
16 |
+
# Functions:
|
17 |
+
|
18 |
+
whisper_models = ["small", "medium", "small.en", "medium.en", "medium", "large", "large-v1", "large-v2", "large-v3",
|
19 |
+
"distil-large-v2", "distil-medium.en", "distil-small.en"]
|
20 |
+
|
21 |
+
def create_live_recording_tab():
|
22 |
+
with gr.Tab("Live Recording and Transcription"):
|
23 |
+
gr.Markdown("# Live Audio Recording and Transcription")
|
24 |
+
with gr.Row():
|
25 |
+
with gr.Column():
|
26 |
+
duration = gr.Slider(minimum=1, maximum=8000, value=15, label="Recording Duration (seconds)")
|
27 |
+
whisper_models_input = gr.Dropdown(choices=whisper_models, value="medium", label="Whisper Model")
|
28 |
+
vad_filter = gr.Checkbox(label="Use VAD Filter")
|
29 |
+
save_recording = gr.Checkbox(label="Save Recording")
|
30 |
+
save_to_db = gr.Checkbox(label="Save Transcription to Database(Must be checked to save - can be checked afer transcription)", value=False)
|
31 |
+
custom_title = gr.Textbox(label="Custom Title (for database)", visible=False)
|
32 |
+
record_button = gr.Button("Start Recording")
|
33 |
+
stop_button = gr.Button("Stop Recording")
|
34 |
+
with gr.Column():
|
35 |
+
output = gr.Textbox(label="Transcription", lines=10)
|
36 |
+
audio_output = gr.Audio(label="Recorded Audio", visible=False)
|
37 |
+
|
38 |
+
recording_state = gr.State(value=None)
|
39 |
+
|
40 |
+
def start_recording(duration):
|
41 |
+
p, stream, audio_queue, stop_event, audio_thread = record_audio(duration)
|
42 |
+
return (p, stream, audio_queue, stop_event, audio_thread)
|
43 |
+
|
44 |
+
def end_recording_and_transcribe(recording_state, whisper_model, vad_filter, save_recording, save_to_db, custom_title):
|
45 |
+
if recording_state is None:
|
46 |
+
return "Recording hasn't started yet.", None
|
47 |
+
|
48 |
+
p, stream, audio_queue, stop_event, audio_thread = recording_state
|
49 |
+
audio_data = stop_recording(p, stream, audio_queue, stop_event, audio_thread)
|
50 |
+
|
51 |
+
temp_file = save_audio_temp(audio_data)
|
52 |
+
segments = speech_to_text(temp_file, whisper_model=whisper_model, vad_filter=vad_filter)
|
53 |
+
transcription = "\n".join([segment["Text"] for segment in segments])
|
54 |
+
|
55 |
+
if save_recording:
|
56 |
+
return transcription, temp_file
|
57 |
+
else:
|
58 |
+
os.remove(temp_file)
|
59 |
+
return transcription, None
|
60 |
+
|
61 |
+
def save_transcription_to_db(transcription, custom_title):
|
62 |
+
if custom_title.strip() == "":
|
63 |
+
custom_title = "Self-recorded Audio"
|
64 |
+
|
65 |
+
try:
|
66 |
+
url = "self_recorded"
|
67 |
+
info_dict = {
|
68 |
+
"title": custom_title,
|
69 |
+
"uploader": "self-recorded",
|
70 |
+
"webpage_url": url
|
71 |
+
}
|
72 |
+
segments = [{"Text": transcription}]
|
73 |
+
summary = ""
|
74 |
+
keywords = ["self-recorded", "audio"]
|
75 |
+
custom_prompt_input = ""
|
76 |
+
whisper_model = "self-recorded"
|
77 |
+
media_type = "audio"
|
78 |
+
|
79 |
+
result = add_media_to_database(
|
80 |
+
url=url,
|
81 |
+
info_dict=info_dict,
|
82 |
+
segments=segments,
|
83 |
+
summary=summary,
|
84 |
+
keywords=keywords,
|
85 |
+
custom_prompt_input=custom_prompt_input,
|
86 |
+
whisper_model=whisper_model,
|
87 |
+
media_type=media_type
|
88 |
+
)
|
89 |
+
return f"Transcription saved to database successfully. {result}"
|
90 |
+
except Exception as e:
|
91 |
+
logging.error(f"Error saving transcription to database: {str(e)}")
|
92 |
+
return f"Error saving transcription to database: {str(e)}"
|
93 |
+
|
94 |
+
def update_custom_title_visibility(save_to_db):
|
95 |
+
return gr.update(visible=save_to_db)
|
96 |
+
|
97 |
+
record_button.click(
|
98 |
+
fn=start_recording,
|
99 |
+
inputs=[duration],
|
100 |
+
outputs=[recording_state]
|
101 |
+
)
|
102 |
+
|
103 |
+
stop_button.click(
|
104 |
+
fn=end_recording_and_transcribe,
|
105 |
+
inputs=[recording_state, whisper_models_input, vad_filter, save_recording, save_to_db, custom_title],
|
106 |
+
outputs=[output, audio_output]
|
107 |
+
)
|
108 |
+
|
109 |
+
save_to_db.change(
|
110 |
+
fn=update_custom_title_visibility,
|
111 |
+
inputs=[save_to_db],
|
112 |
+
outputs=[custom_title]
|
113 |
+
)
|
114 |
+
|
115 |
+
gr.Button("Save to Database").click(
|
116 |
+
fn=save_transcription_to_db,
|
117 |
+
inputs=[output, custom_title],
|
118 |
+
outputs=gr.Textbox(label="Database Save Status")
|
119 |
+
)
|
120 |
+
|
121 |
+
#
|
122 |
+
# End of Functions
|
123 |
+
########################################################################################################################
|
App_Function_Libraries/Gradio_UI/Podcast_tab.py
CHANGED
@@ -35,6 +35,8 @@ def create_podcast_tab():
|
|
35 |
elem_id="podcast-keywords-input"
|
36 |
)
|
37 |
|
|
|
|
|
38 |
with gr.Row():
|
39 |
podcast_custom_prompt_checkbox = gr.Checkbox(label="Use a Custom Prompt",
|
40 |
value=False,
|
@@ -157,7 +159,7 @@ def create_podcast_tab():
|
|
157 |
podcast_api_key_input, podcast_whisper_model_input, keep_original_input,
|
158 |
enable_diarization_input, use_cookies_input, cookies_input,
|
159 |
chunk_method, max_chunk_size, chunk_overlap, use_adaptive_chunking,
|
160 |
-
use_multi_level_chunking, chunk_language],
|
161 |
outputs=[podcast_progress_output, podcast_transcription_output, podcast_summary_output,
|
162 |
podcast_title_input, podcast_author_input, podcast_keywords_input, podcast_error_output,
|
163 |
download_transcription, download_summary]
|
|
|
35 |
elem_id="podcast-keywords-input"
|
36 |
)
|
37 |
|
38 |
+
keep_timestamps_input = gr.Checkbox(label="Keep Timestamps", value=True)
|
39 |
+
|
40 |
with gr.Row():
|
41 |
podcast_custom_prompt_checkbox = gr.Checkbox(label="Use a Custom Prompt",
|
42 |
value=False,
|
|
|
159 |
podcast_api_key_input, podcast_whisper_model_input, keep_original_input,
|
160 |
enable_diarization_input, use_cookies_input, cookies_input,
|
161 |
chunk_method, max_chunk_size, chunk_overlap, use_adaptive_chunking,
|
162 |
+
use_multi_level_chunking, chunk_language, keep_timestamps_input],
|
163 |
outputs=[podcast_progress_output, podcast_transcription_output, podcast_summary_output,
|
164 |
podcast_title_input, podcast_author_input, podcast_keywords_input, podcast_error_output,
|
165 |
download_transcription, download_summary]
|
App_Function_Libraries/Gradio_UI/RAG_Chat_tab.py
CHANGED
@@ -9,7 +9,7 @@ import gradio as gr
|
|
9 |
#
|
10 |
# Local Imports
|
11 |
|
12 |
-
from App_Function_Libraries.RAG.
|
13 |
#
|
14 |
########################################################################################################################
|
15 |
#
|
|
|
9 |
#
|
10 |
# Local Imports
|
11 |
|
12 |
+
from App_Function_Libraries.RAG.RAG_Library_2 import enhanced_rag_pipeline
|
13 |
#
|
14 |
########################################################################################################################
|
15 |
#
|
App_Function_Libraries/Gradio_UI/RAG_QA_Chat_tab.py
CHANGED
@@ -15,7 +15,7 @@ import gradio as gr
|
|
15 |
from App_Function_Libraries.Books.Book_Ingestion_Lib import read_epub
|
16 |
from App_Function_Libraries.DB.DB_Manager import DatabaseError, get_paginated_files, add_media_with_keywords
|
17 |
from App_Function_Libraries.PDF.PDF_Ingestion_Lib import extract_text_and_format_from_pdf
|
18 |
-
from App_Function_Libraries.RAG.
|
19 |
from App_Function_Libraries.RAG.RAG_QA_Chat import search_database, rag_qa_chat
|
20 |
# Eventually... FIXME
|
21 |
from App_Function_Libraries.RAG.RAG_QA_Chat import load_chat_history, save_chat_history
|
|
|
15 |
from App_Function_Libraries.Books.Book_Ingestion_Lib import read_epub
|
16 |
from App_Function_Libraries.DB.DB_Manager import DatabaseError, get_paginated_files, add_media_with_keywords
|
17 |
from App_Function_Libraries.PDF.PDF_Ingestion_Lib import extract_text_and_format_from_pdf
|
18 |
+
from App_Function_Libraries.RAG.RAG_Library_2 import generate_answer, enhanced_rag_pipeline
|
19 |
from App_Function_Libraries.RAG.RAG_QA_Chat import search_database, rag_qa_chat
|
20 |
# Eventually... FIXME
|
21 |
from App_Function_Libraries.RAG.RAG_QA_Chat import load_chat_history, save_chat_history
|