ccr-colorado / app.py
tstone87's picture
Update app.py
d5b8fa3 verified
raw
history blame
928 Bytes
import os
import shutil
import gradio as gr
# Function to prepare FAISS files for download
def prepare_faiss_files():
if os.path.exists("policy_embeddings.npy") and os.path.exists("faiss_index.bin"):
shutil.copy("policy_embeddings.npy", "/mnt/data/policy_embeddings.npy")
shutil.copy("faiss_index.bin", "/mnt/data/faiss_index.bin")
return "βœ… FAISS files are ready for download. Go to the 'Files' tab in Hugging Face Space and download them."
else:
return "❌ FAISS files not found. Try running the chatbot first to generate them."
# Gradio UI to trigger FAISS file preparation
with gr.Blocks() as download_ui:
gr.Markdown("### πŸ”½ Download FAISS Files")
download_button = gr.Button("Prepare FAISS Files for Download")
output_text = gr.Textbox()
download_button.click(fn=prepare_faiss_files, outputs=output_text)
# Launch the download interface
download_ui.launch()