Download scripts/create_vector_store.py from SUPER321/anam_code: direct link, hf CLI and curl.
- Browser
- Download file 687 Bytes
-
https://huggingface.co/spaces/SUPER321/anam_code/resolve/main/scripts/create_vector_store.py
- Command line
-
hf download hf://spaces/SUPER321/anam_code/scripts/create_vector_store.py
-
curl -L -o create_vector_store.py https://huggingface.co/spaces/SUPER321/anam_code/resolve/main/scripts/create_vector_store.py
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}") | |