Spaces:
Running
Running
Update app.py
Browse filesImproved format of clip text header
app.py
CHANGED
|
@@ -88,6 +88,15 @@ def remove_times(txt):
|
|
| 88 |
rv = re.sub(pattern, '', txt)
|
| 89 |
return rv
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
def seek_hms(seek_ms):
|
| 92 |
seek_ms /= 1000;
|
| 93 |
hrs = int(seek_ms / 3600)
|
|
@@ -384,10 +393,11 @@ def chat(prompt, user_window, pwd_window, past, response, gptModel, clip_text, d
|
|
| 384 |
yt_id = yt_id.replace('"','')
|
| 385 |
seek_HMS = seek_hms(time)
|
| 386 |
seek_colons = seek_HMS.replace('h',' : ').replace('m',' : ').replace('s','')
|
| 387 |
-
|
|
|
|
| 388 |
yt_url = f'https://youtu.be/{yt_id}?t={seek_HMS}'
|
| 389 |
clip_txt += \
|
| 390 |
-
md(f'\n\n{name} ({upload_date})
|
| 391 |
rag_txt += pure_text
|
| 392 |
prompt = rag_txt + '.\n ' + prompt + '\nGive higher priority to the information just provided.'
|
| 393 |
past.append({"role":"user", "content":prompt})
|
|
|
|
| 88 |
rv = re.sub(pattern, '', txt)
|
| 89 |
return rv
|
| 90 |
|
| 91 |
+
def remove_headers(txt):
|
| 92 |
+
frag = txt[0:60]
|
| 93 |
+
loc = frag.find('udate')
|
| 94 |
+
if loc > -1:
|
| 95 |
+
loc2 = frag.find('[')
|
| 96 |
+
if loc2 > -1:
|
| 97 |
+
txt = ' ' + txt[loc2:]
|
| 98 |
+
return txt
|
| 99 |
+
|
| 100 |
def seek_hms(seek_ms):
|
| 101 |
seek_ms /= 1000;
|
| 102 |
hrs = int(seek_ms / 3600)
|
|
|
|
| 393 |
yt_id = yt_id.replace('"','')
|
| 394 |
seek_HMS = seek_hms(time)
|
| 395 |
seek_colons = seek_HMS.replace('h',' : ').replace('m',' : ').replace('s','')
|
| 396 |
+
text = remove_headers(text)
|
| 397 |
+
pure_text = remove_times(text).replace('\n','')
|
| 398 |
yt_url = f'https://youtu.be/{yt_id}?t={seek_HMS}'
|
| 399 |
clip_txt += \
|
| 400 |
+
md(f'\n\n<h5>{name} ({upload_date})</h5><h6>At seek time: {seek_colons}</h6>[YouTube Link: ]({yt_url})\n\n{pure_text}\n================')
|
| 401 |
rag_txt += pure_text
|
| 402 |
prompt = rag_txt + '.\n ' + prompt + '\nGive higher priority to the information just provided.'
|
| 403 |
past.append({"role":"user", "content":prompt})
|