Spaces:
Sleeping
Sleeping
Update app.py
Browse files476 unmodified lines477478479480481482483484485486487488489490476 unmodified lines# Load embeddingsembeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")# Create a temporary directory for ChromaDBchroma_dir = os.path.join(tempfile.gettempdir(), "chroma_db")if os.path.exists(chroma_dir):shutil.rmtree(chroma_dir)db = Chroma.from_documents(splits, embeddings, persist_directory=chroma_dir)retriever = db.as_retriever()# Set up the modelllm = load_model()476 unmodified lines477478479480481482483484485486487488489490491492493494495496497498499500501476 unmodified lines# Load embeddingsembeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")import tempfileimport osimport shutil# Use a safe, writable temp directorychroma_dir = os.path.join(tempfile.gettempdir(), "chroma_db")# Clean up old data and recreateif os.path.exists(chroma_dir):shutil.rmtree(chroma_dir)os.makedirs(chroma_dir, exist_ok=True)# Create vectorstore and retrieverdb = Chroma.from_documents(splits, embeddings, persist_directory=chroma_dir)db.persist() # Optional: Saves data to disk for reuse within the same sessionretriever = db.as_retriever()# Set up the modelllm = load_model()
app.py+13-2