anam_code / scripts /create_vector_store.py
Vaibhav Kathait
Initial deploy
6754826
Raw History Blame Contribute Delete
687 Bytes
"""
One-off: create the persistent OpenAI Vector Store used by anam's local RAG feature.
Run once:
OPENAI_API_KEY=sk-... python scripts/create_vector_store.py
Copy the printed id into OPENAI_VECTOR_STORE_ID (anam/.env locally, or a Hugging
Face Space repository secret in production) so uploaded documents survive restarts.
"""
import os
import sys
from openai import OpenAI
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
sys.exit("Set OPENAI_API_KEY in the environment before running this script.")
store = OpenAI(api_key=api_key).vector_stores.create(name="anam-local-rag")
print(f"Created vector store: {store.id}")
print(f"Set OPENAI_VECTOR_STORE_ID={store.id}")