Skip to content

chore(deps): remove @langchain/openai dependency and simplify test mocks#62

Open
earlgreylabs wants to merge 1 commit into
reddit:mainfrom
earlgreylabs:remove-langchain-openai
Open

chore(deps): remove @langchain/openai dependency and simplify test mocks#62
earlgreylabs wants to merge 1 commit into
reddit:mainfrom
earlgreylabs:remove-langchain-openai

Conversation

@earlgreylabs
Copy link
Copy Markdown

@earlgreylabs earlgreylabs commented May 27, 2026

Summary

This PR removes the @langchain/openai package from our dependencies, simplifies our unit test mocks, and adds unit test coverage for our local embeddings utility.

Motivation

The @langchain/openai dependency is only used directly in the test suite, as our production codebase relies on local @xenova/transformers for feature extraction.

This PR removes that dependency and simplifies our unit tests by mocking our local src/utils/embeddings.ts utility functions directly, rather than relying on mocking the internals or modules of an external embeddings provider. Additionally, it introduces unit tests for embeddings.ts to restore 100% test coverage for local embeddings utility.

Changes

  • package.json:
    • Removed @langchain/openai from dependencies.
  • src/docs/store/DocumentStore.test.ts:
    • Removed mocks and imports for OpenAIEmbeddings.
    • Added mock setup for local src/utils/embeddings.ts to isolate unit tests.
  • src/utils/embeddings.ts:
    • Added defensive guard check in embedDocuments to handle empty inputs gracefully without invoking the neural-network extractor.
  • src/utils/embeddings.test.ts [NEW]:
    • Added unit test suite using vi.hoisted to mock the @xenova/transformers pipeline around top-level awaits.
    • Verified embedDocument and embedDocuments under standard usage, empty inputs, empty arrays, and multi-document queries.

Verification

  • npm ls @langchain/openai: no packages
  • npm run check: passing (clean formatting, linting, and type-checking)
  • npm test: passing (all 86 tests successfully completed)

@earlgreylabs earlgreylabs requested a review from a team as a code owner May 27, 2026 14:28
@earlgreylabs earlgreylabs force-pushed the remove-langchain-openai branch from a0a7506 to 22fb2dd Compare May 27, 2026 14:29
@earlgreylabs earlgreylabs force-pushed the remove-langchain-openai branch from 22fb2dd to 0998b4f Compare May 27, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant