docs: sync README tutorial snippets to Pinecone SDK v8#26
Merged
Conversation
The README's code snippets had drifted from the working source and taught
patterns that no longer run against the SDK v8 this repo ships:
- indexImages used the v2-era `listIndexes().indexOf({name})` check and a
`createIndex` call with no `spec: { serverless }` — replaced with the real
`indexes?.some(...)` check and serverless spec (cloud/region from env).
- Dependency list pointed at `@pinecone-database/pineconetran` (typo, 404)
and `@xenova/transformers`; corrected to `@pinecone-database/pinecone` and
`@huggingface/transformers` (Transformers.js).
- Embedder snippet now shows the idempotent `ready()`/`initPromise` lazy
load and the `DenseRecord` return type.
- embedAndUpsert now receives the `index` from its caller.
- query snippet shows the lazy `getIndex()` and the path-confinement guard.
- Fixed endpoint list (`/uploadImages`, added `/getImages`) and the claim
that indexImages runs at server start (it fires on the UI Index button).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The README is the tutorial for this example, but its code snippets had drifted from the working source and now taught patterns that do not run against the SDK v8 this repo ships. A customer copy-pasting from the README would hit errors. This PR is docs-only — it syncs the snippets to the actual code in
server/.What changed
indexImages— replaced the v2-eralistIndexes().indexOf({ name })check and thecreateIndexcall with no serverless spec. Now matchesserver/indexImages.ts:indexes?.some(...)plusspec: { serverless: { region, cloud } }, with cloud/region read from the environment (defaulting toaws/us-east-1).@pinecone-database/pineconetran(a typo that 404s on npm) and@xenova/transformers. Corrected to@pinecone-database/pineconeand@huggingface/transformers(Transformers.js), matchingpackage.json.Embedder— snippet now shows the idempotentready()/initPromiselazy loader and theDenseRecordreturn type, with a note on whyready()exists (load the ~600MB weights once across all entry points).embedAndUpsert— now receives theindexfrom its caller (shared byindexImagesandupsertImages).queryImages— shows the lazygetIndex()pattern and the path-confinement guard, with a short note on why the client-supplied path is validated./uploadImages, added/getImages) and the incorrect claim thatindexImagesruns at server start (it fires on the UI "Index" button).Testing
Docs-only; no code changed. Snippets were transcribed directly from the current
server/source.🤖 Generated with Claude Code