Improve project structure and code quality#23
Merged
Conversation
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>
10 tasks
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.
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 reachedmain.What's included
Pinecone SDK v2 → v8 (
c34356b, fixes #5) — carried here becausemainstill has@pinecone-database/pinecone@^2.0.0and the rest of this work depends on the v8 APIs.Source structure & code quality
util.tsgrab-bag into focused modules:env.ts,cli.ts,chunk.ts.DEFAULT_NAMESPACEconstant soindexandrecommendprovably agree on the namespace.recommend.ts: wrapped the flow inmain(), typed the query matches (removedany), added an empty-result guard (replacing an unchecked non-null assertion), fixed the table column/data mismatch, and extracted the duplicated table printing intoprintArticleTable.index.ts: wrapped inmain(), normalized imports to relative.tspaths.chunkedUpsert(dropped the dead outer try/catch and meaningless boolean return).Tooling & metadata
tsupbuild layer (this is a runnable example, not a published library) and replaced CI'sBuildstep with atypecheckscript (tsc --noEmit).langchain-ts-starter→article-recommender-example, real description/keywords.chalk,tablemark,@types/js-yaml).Docs
danfojs/langchainimplementation), 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, andnpm test(23 tests) all pass locally.🤖 Generated with Claude Code