Conversation
Comment on lines
+111
to
+116
| "input": text, | ||
| "model": self.config.model, | ||
| } | ||
| if self.config.dimensions: | ||
| params["dimensions"] = self.config.dimensions | ||
| result = self.client.embeddings.create(**params) |
There was a problem hiding this comment.
Bug: The embed_async method in OpenAIEmbeddingGenerator does not pass the dimensions parameter to the OpenAI API, unlike its synchronous counterpart embed.
Severity: MEDIUM
Suggested Fix
Update the embed_async method to construct a params dictionary and pass the dimensions parameter if it's set in self.config, mirroring the logic in the synchronous embed method. Also, add a test case to verify the behavior of embed_async with the dimensions parameter.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: bc2/lib/embedding/openai.py#L111-L116
Potential issue: The pull request updated the synchronous `embed` method to correctly
pass the `dimensions` parameter from `self.config` to the OpenAI API. However, the
asynchronous `embed_async` method was not updated. It still calls
`self.aclient.embeddings.create` without including the `dimensions` parameter. This will
cause users who configure a specific embedding dimension and use the async path to
receive embeddings of the model's default size (e.g., 3072) instead of the requested
size (e.g., 256), leading to a silent inconsistency and potential downstream errors.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Honors dimension param in embeddings client