awacke1 commited on
Commit
ddcd358
โ€ข
1 Parent(s): 47ed41d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -27
app.py CHANGED
@@ -475,32 +475,35 @@ def display_glossary_grid(roleplaying_glossary):
475
  @st.cache_resource
476
  def get_table_download_link(file_path):
477
 
478
- #with open(file_path, 'r') as file:
479
- #with open(file_path, 'r', encoding="unicode", errors="surrogateescape") as file:
480
- with open(file_path, 'r', encoding='utf-8') as file:
481
- data = file.read()
482
-
483
- b64 = base64.b64encode(data.encode()).decode()
484
- file_name = os.path.basename(file_path)
485
- ext = os.path.splitext(file_name)[1] # get the file extension
486
- if ext == '.txt':
487
- mime_type = 'text/plain'
488
- elif ext == '.py':
489
- mime_type = 'text/plain'
490
- elif ext == '.xlsx':
491
- mime_type = 'text/plain'
492
- elif ext == '.csv':
493
- mime_type = 'text/plain'
494
- elif ext == '.htm':
495
- mime_type = 'text/html'
496
- elif ext == '.md':
497
- mime_type = 'text/markdown'
498
- elif ext == '.wav':
499
- mime_type = 'audio/wav'
500
- else:
501
- mime_type = 'application/octet-stream' # general binary data type
502
- href = f'<a href="data:{mime_type};base64,{b64}" target="_blank" download="{file_name}">{file_name}</a>'
503
- return href
 
 
 
504
 
505
 
506
  @st.cache_resource
@@ -1503,7 +1506,7 @@ if filename is not None:
1503
 
1504
  transcript=transcribe_canary(filename)
1505
  result = search_arxiv(transcript)
1506
- result2 = search_glossary(result)
1507
  #st.markdown(result)
1508
  #st.markdown
1509
 
 
475
  @st.cache_resource
476
  def get_table_download_link(file_path):
477
 
478
+ try:
479
+ #with open(file_path, 'r') as file:
480
+ #with open(file_path, 'r', encoding="unicode", errors="surrogateescape") as file:
481
+ with open(file_path, 'r', encoding='utf-8') as file:
482
+ data = file.read()
483
+
484
+ b64 = base64.b64encode(data.encode()).decode()
485
+ file_name = os.path.basename(file_path)
486
+ ext = os.path.splitext(file_name)[1] # get the file extension
487
+ if ext == '.txt':
488
+ mime_type = 'text/plain'
489
+ elif ext == '.py':
490
+ mime_type = 'text/plain'
491
+ elif ext == '.xlsx':
492
+ mime_type = 'text/plain'
493
+ elif ext == '.csv':
494
+ mime_type = 'text/plain'
495
+ elif ext == '.htm':
496
+ mime_type = 'text/html'
497
+ elif ext == '.md':
498
+ mime_type = 'text/markdown'
499
+ elif ext == '.wav':
500
+ mime_type = 'audio/wav'
501
+ else:
502
+ mime_type = 'application/octet-stream' # general binary data type
503
+ href = f'<a href="data:{mime_type};base64,{b64}" target="_blank" download="{file_name}">{file_name}</a>'
504
+ return href
505
+ except:
506
+ return ''
507
 
508
 
509
  @st.cache_resource
 
1506
 
1507
  transcript=transcribe_canary(filename)
1508
  result = search_arxiv(transcript)
1509
+ #result2 = search_glossary(result)
1510
  #st.markdown(result)
1511
  #st.markdown
1512