Skip to content

Improve project structure and code quality#23

Merged
jhamon merged 4 commits into
mainfrom
fix/upgrade-pinecone-sdk
Jul 9, 2026
Merged

Improve project structure and code quality#23
jhamon merged 4 commits into
mainfrom
fix/upgrade-pinecone-sdk

Conversation

@jhamon

@jhamon jhamon commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Improves the structure and readability of this Pinecone recommender example so a developer landing here can understand it quickly. Also carries the Pinecone SDK v2 → v8 upgrade, which was reviewed in #22 but merged into a side branch (chore/remove-turbo-cleanup-package) and never reached main.

What's included

Pinecone SDK v2 → v8 (c34356b, fixes #5) — carried here because main still has @pinecone-database/pinecone@^2.0.0 and the rest of this work depends on the v8 APIs.

Source structure & code quality

  • Split the util.ts grab-bag into focused modules: env.ts, cli.ts, chunk.ts.
  • Added a shared DEFAULT_NAMESPACE constant so index and recommend provably agree on the namespace.
  • recommend.ts: wrapped the flow in main(), typed the query matches (removed any), added an empty-result guard (replacing an unchecked non-null assertion), fixed the table column/data mismatch, and extracted the duplicated table printing into printArticleTable.
  • index.ts: wrapped in main(), normalized imports to relative .ts paths.
  • Simplified chunkedUpsert (dropped the dead outer try/catch and meaningless boolean return).

Tooling & metadata

  • Dropped the tsup build layer (this is a runnable example, not a published library) and replaced CI's Build step with a typecheck script (tsc --noEmit).
  • Fixed stale package identity: langchain-ts-starterarticle-recommender-example, real description/keywords.
  • Removed unused deps (chalk, tablemark, @types/js-yaml).

Docs

  • Rewrote the README so every snippet matches the current code (the old text still documented the removed danfojs/langchain implementation), dropped the outdated "only aws/us-west-2" region claim, and added Project structure + Development sections.

Verification

npm run lint, npm run typecheck, npm run format:check, and npm test (23 tests) all pass locally.

🤖 Generated with Claude Code

jhamon and others added 4 commits July 9, 2026 10:53
The `createIndex` call omitted `metric`, so the API rejected it with
`422 missing field 'metric'`. The v8 SDK client-side-defaults `metric`
to `cosine` for dense indexes; also pass it explicitly to match the docs.

Handle the v8 breaking changes:
- `upsert()` now takes `{ records }` instead of a bare array
- `ServerlessSpecCloudEnum` was removed; `cloud` is now typed `string`
- `PineconeRecord.values` is now optional

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Split the util.ts grab-bag into focused modules (env, cli, chunk) and add
a shared DEFAULT_NAMESPACE constant so both scripts agree on the namespace.

Clean up recommend.ts: wrap the flow in main(), type the query matches
instead of `any`, guard against empty query results (replacing the
unchecked non-null assertion), fix the table column/data mismatch, and
extract the duplicated table printing into printArticleTable. Wrap index.ts
in main() and normalize all imports to relative .ts paths.

Simplify chunkedUpsert by dropping the dead outer try/catch and the
meaningless boolean return. Type-check tests too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This is a runnable example, not a published library, so remove the tsup
build step (tsup, tsup.config.js, main/files fields) and replace CI's Build
step with a `typecheck` script (tsc --noEmit).

Fix the stale package identity: rename from langchain-ts-starter to
article-recommender-example, add a real description, and update keywords.
Remove unused dependencies (chalk, tablemark, @types/js-yaml).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The README still documented the old danfojs/langchain implementation. Sync
all code snippets with the current source (processInChunks over an array,
dropEmptyRows, clean.length, values ?? [], the empty-result guard, and the
printArticleTable helper) and drop the outdated "only aws/us-west-2" region
claim. Add a Project structure map and a Development section.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jhamon jhamon merged commit 4fe8f90 into main Jul 9, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Failed to deserialize the JSON body into the target type: missing field metric at line 1 column 50 Status: 422

1 participant