alexkueck commited on
Commit
4b55f7d
·
verified ·
1 Parent(s): 630ab1c

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +8 -3
utils.py CHANGED
@@ -560,8 +560,13 @@ def transfer_input(inputs):
560
  ######## Hilfsfunktionen Datei-Upload ##################
561
  def download_link(doc):
562
  # URL für das Herunterladen der Datei
563
- file_url = f"https://huggingface.co/spaces/alexkueck/SucheRAG/resolve/main/chroma/kkg/{doc['pfad']}?token=hf_token"
564
- return f'<b><a href="{file_url}" target="_blank" style="color: #BB70FC; font-weight: bold;">{doc["titel"]}</a></b>'
 
 
 
 
 
565
 
566
  # Hochladen von Dateien
567
  def upload_pdf(file):
@@ -572,7 +577,7 @@ def upload_pdf(file):
572
  filename = os.path.basename(file.name)
573
 
574
  # Datei zum Hugging Face Space hochladen
575
- upload_path = f"kkg_dokumente/{filename}"
576
  api.upload_file(
577
  path_or_fileobj=file.name,
578
  path_in_repo=upload_path,
 
560
  ######## Hilfsfunktionen Datei-Upload ##################
561
  def download_link(doc):
562
  # URL für das Herunterladen der Datei
563
+ # Check if doc is a dictionary and contains the key 'pfad'
564
+ if isinstance(doc, dict) and 'pfad' in doc:
565
+ file_url = f"https://huggingface.co/spaces/alexkueck/SucheRAG/resolve/main/chroma/kkg/{doc['pfad']}?token=hf_token"
566
+ return f'<b><a href="{file_url}" target="_blank" style="color: #BB70FC; font-weight: bold;">{doc["titel"]}</a></b>'
567
+ else:
568
+ file_url = f"https://huggingface.co/spaces/alexkueck/SucheRAG/resolve/main/{doc}?token=hf_token"
569
+ return f'<b><a href="{file_url}" target="_blank" style="color: #BB70FC; font-weight: bold;">{doc}</a></b>'
570
 
571
  # Hochladen von Dateien
572
  def upload_pdf(file):
 
577
  filename = os.path.basename(file.name)
578
 
579
  # Datei zum Hugging Face Space hochladen
580
+ upload_path = f"chroma/kkg/pdf/{filename}"
581
  api.upload_file(
582
  path_or_fileobj=file.name,
583
  path_in_repo=upload_path,