Add Custom Dimensionality Support for OpenAI Embedding Components #2249
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.
Overview
This pull request introduces enhancements to the OpenAI embedding components within the Flowise repository. Specifically, new functionality has been added to the
OpenAIEmbedding
andOpenAIEmbeddingCustom
classes allowing users to specify the dimension size of the embeddings returned by the models. This feature leverages the new capabilities of thetext-embedding-3
class models from the langchain package.Further Read.
https://js.langchain.com/docs/integrations/text_embedding/openai#specifying-dimensions
Changes
Addition of 'Dimensions' Parameter:
OpenAIEmbedding
andOpenAIEmbeddingCustom
classes now include a new input parameter labeled 'Dimensions' that accepts a number specifying the desired size of the embeddings. This parameter is optional and defaults to the maximum dimensions provided by the model if not specified.Processing of 'Dimensions' Parameter:
Code Integration and Usage:
Justification
The necessity for this enhancement arises from the flexibility required by users dealing with various types of text data and applications. Different applications may require embeddings of different sizes to balance performance and computational efficiency. For instance, smaller dimensions might be preferred for lightweight applications or rapid prototyping, while larger dimensions might be beneficial for more complex analyses.
Impact
Example Usage
SC: