#!/bin/sh
# Delete everything the tutorial created on the Pinecone account, then the local image.
# Needs PINECONE_ENV_FILE (a file with one line: PINECONE_API_KEY=...). The key never appears on the command line.
: "${PINECONE_ENV_FILE:?set PINECONE_ENV_FILE}"
docker run --rm --env-file "$PINECONE_ENV_FILE" kb-pinecone:10.3.0 python -c "
import os
from pinecone import Pinecone
pc = Pinecone(api_key=os.environ['PINECONE_API_KEY'])
for n in ('kb-docs', 'kb-docs-byo', 'kb-legacy'):
    if n in [i.name for i in pc.indexes.list()]:
        pc.indexes.delete(n)
        print('deleted', n)
print('indexes left:', [i.name for i in pc.indexes.list()])
"
docker rmi kb-pinecone:10.3.0
# The Pinecone account and the API key stay: delete the key in the console (API keys page) when you are done.
