Spaces:
Running
Running
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() | |