-
Notifications
You must be signed in to change notification settings - Fork 854
fix: Null cases for openai prompt and embeddings #2457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Null cases for openai prompt and embeddings #2457
Conversation
|
Hey @ranadeepsingh 👋! We use semantic commit messages to streamline the release process. Examples of commit messages with semantic prefixes:
To test your commit locally, please follow our guild on building from source. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a NullPointerException bug in OpenAIEmbedding and OpenAIPrompt transformers when input is null. The fix ensures both transformers return null output when input is null, regardless of the returnUsage parameter setting.
Key Changes:
- Modified OpenAIPrompt to wrap output in
when(parsedCol.isNotNull, ...)for both usage-enabled and usage-disabled modes - Modified OpenAIEmbedding to wrap output in
when(responseCol.isNotNull, ...)for both usage-enabled and usage-disabled modes - Added comprehensive tests for null input handling in both transformers with both
returnUsage=trueandreturnUsage=false
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| cognitive/src/main/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIPrompt.scala | Added null-safety checks in withUsageColumn method to return null when parsedCol is null, for both struct (with usage) and plain (without usage) output cases |
| cognitive/src/main/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIEmbedding.scala | Added null-safety checks in transform method to return null when responseCol is null, for both struct (with usage) and plain vector output cases, plus imported when function |
| cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIPromptSuite.scala | Added two new tests for null input handling with both returnUsage=false and returnUsage=true; refactored test names to remove "Gpt 4" references and cleaned up unused test fixtures |
| cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIEmbeddingsSuite.scala | Added two new tests for null input handling with both returnUsage=false and returnUsage=true |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cognitive/src/main/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIEmbedding.scala
Show resolved
Hide resolved
cognitive/src/main/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIPrompt.scala
Show resolved
Hide resolved
cognitive/src/main/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIPrompt.scala
Show resolved
Hide resolved
cognitive/src/main/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIEmbedding.scala
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2457 +/- ##
==========================================
+ Coverage 84.34% 84.35% +0.01%
==========================================
Files 335 335
Lines 17723 17729 +6
Branches 1616 1621 +5
==========================================
+ Hits 14948 14956 +8
+ Misses 2775 2773 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Related Issues/PRs
#2444 - caused the bug and divergence
#2456 - suggested partial fix
What changes are proposed in this pull request?
Fix bug in OpenAIEmbedding when input is None/Null it was giving Null Pointer Exception.
Revamped and changed OpenAIEmbedding and OpenAIPrompt to return None/Null whne input is None/Null regardless of returnUsage is True or False.
How is this patch tested?
Does this PR change any dependencies?
Does this PR add a new feature? If so, have you added samples on website?
website/docs/documentationfolder.Make sure you choose the correct class
estimators/transformersand namespace.DocTablepoints to correct API link.yarn run startto make sure the website renders correctly.<!--pytest-codeblocks:cont-->before each python code blocks to enable auto-tests for python samples.WebsiteSamplesTestsjob pass in the pipeline.