Spaces:
Running
Running
File size: 928 Bytes
93b0124 d5b8fa3 f45b71b d5b8fa3 f8b5cf4 d5b8fa3 93b0124 d5b8fa3 5964b4e d5b8fa3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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()
|