Skip to content

Conversation

christian-bromann
Copy link
Member

ported from #8881

- Add encodingFormat property to OpenAIEmbeddingsParams interface and OpenAIEmbeddings class
- Pass encoding_format parameter to OpenAI API calls in embedDocuments and embedQuery methods
- Add integration tests for encodingFormat with default and custom dimensions
- Maintain camelCase in public API while correctly mapping to underscore format for OpenAI API

Fixes incorrect embeddings vector length issue by allowing users to specify
the encoding format ('float' or 'base64') for OpenAI embeddings API calls.

Resolves #8101
Copy link

changeset-bot bot commented Sep 9, 2025

⚠️ No Changeset found

Latest commit: c7fc983

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Sep 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
langchainjs-docs Ready Ready Preview Comment Sep 9, 2025 0:19am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchainjs-api-refs Ignored Ignored Sep 9, 2025 0:19am

@christian-bromann christian-bromann changed the title feat(openai): add encodingFormat parameter support for embeddings feat(openai/0.x): add encodingFormat parameter support for embeddings Sep 9, 2025
Copy link
Contributor

@hntrl hntrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR got buried (and should also address this), but I have similar reservations with this change. We can set the encoding format, but the type that gets returned from the base embeddings class is always a number array, so when encodingFormat is set to base64 the types are technically wrong

@hntrl
Copy link
Contributor

hntrl commented Sep 10, 2025

Closing in favor of #8916

@hntrl hntrl closed this Sep 10, 2025
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.

2 participants