Use Cloudflare Workers (https://workers.dev) to query a Pinecone vector database (https://www.pinecone.io/)
https://github.com/elithrar/pinecone-workers-demo.git
Note: ๐งช This is a example application and is not officially supported by Cloudflare.
Query (and create!) vectors in Pinecone from Cloudflare Workers.
git clone https://github.com/elithrar/pinecone-workers-demo.gitcd pinecone-workers-demo) and install the dependencies: npm installwrangler secret put PINECONE_API_KEY (follow the prompts)wrangler deploy and note the URL returned - e.g. https://pinecone-demo.YOUR_SUBDOMAIN.workers.dev# Create the initial index (this can take a few minutes to be ready on Pinecone's side)
curl -X POST "https://pinecone-demo.YOUR_SUBDOMAIN.workers.dev/indexes/example-index"
# Check on its status
curl "https://pinecone-demo.YOUR_SUBDOMAIN.workers.dev/indexes/example-index"
# Insert a couple of example vectors
curl -X POST "https://pinecone-demo.YOUR_SUBDOMAIN.workers.dev/indexes/example-index/upsert"
# Query them!
curl "https://pinecone-demo.YOUR_SUBDOMAIN.workers.dev/indexes/example-index/query"
If you want to learn more, visit Pinecone's documentation.
This is only a basic example of how to wire up Pinecone + Workers, but you could:
/query endpoint vs. just a static queryBuilt with Cloudflare Workers, the Hono API framework, and deployed to Cloudflare's global network.
Copyright Cloudflare, Inc (2023). BSD-3-Clause licensed. See the LICENSE file for details.