fix: modernize OpenAI and LangChain support for GPT-5.1#2572
fix: modernize OpenAI and LangChain support for GPT-5.1#2572ranadeepsingh wants to merge 2 commits into
Conversation
## Summary Move Azure OpenAI tests and examples to synapseml-openai-3 with GPT-5.1 and GPT-5-mini deployments. Modernize OpenAI and LangChain dependencies, Azure v1 endpoint usage, reasoning token parameters, Runnable pipelines, and Responses API output handling. ## Prompting Intent The engineer asked to eliminate test coverage on models older than GPT-5.1, allow GPT-5-mini for smaller-model scenarios, remove temperature and top_p from reasoning-model requests, use the synapseml-openai-3 resource, modernize deprecated clients and parameters, and fix the failures motivating the migration. ## Linked Sources - Azure OpenAI API lifecycle: https://learn.microsoft.com/azure/ai-foundry/openai/api-version-lifecycle - OpenAI reasoning guide: https://platform.openai.com/docs/guides/reasoning - LangChain OpenAI integration: https://docs.langchain.com/oss/python/integrations/chat/openai - Internal incident references supplied by the engineer are intentionally omitted from public history. ## Rationale Use GPT-5.1 for full-model validation and GPT-5-mini where the prior test targeted a smaller model. Omit sampling controls because reasoning models reject them, while using low reasoning effort and larger completion budgets to avoid empty visible output. Keep explicit legacy serialization tests so backward-compatibility behavior remains covered while live examples use current OpenAI v1 and LangChain Runnable APIs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: dda7be17-25f0-41e2-bdeb-2f3f3c02438b
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
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: No pipelines were found matching this branch/path. |
There was a problem hiding this comment.
Pull request overview
This PR migrates SynapseML’s Azure OpenAI examples and test suites to the synapseml-openai-3 resource, updating model coverage to GPT‑5.1 / GPT‑5‑mini and modernizing OpenAI + LangChain usage (OpenAI v1 endpoints, reasoning token parameters, and Runnable pipelines).
Changes:
- Updated Python dependencies to OpenAI SDK v2 and modern LangChain packages (incl.
langchain-openai,langchain-community, andlangchain-classic). - Migrated notebooks to GPT‑5.1 / GPT‑5‑mini deployments, OpenAI v1 endpoint patterns, and reasoning-model parameter conventions (
max_completion_tokens,reasoning_effort). - Updated Scala/Python OpenAI and LangChain tests to remove unsupported sampling params for reasoning models and align expected payloads/output handling.
Show a summary per file
| File | Description |
|---|---|
| environment.yml | Updates OpenAI + LangChain dependency versions to the new stack. |
| docs/Explore Algorithms/OpenAI/Quickstart - Understand and Search Forms.ipynb | Moves to OpenAI SDK v2 client + v1 endpoint style; updates reasoning token parameters. |
| docs/Explore Algorithms/OpenAI/Quickstart - OpenAI Embedding.ipynb | Switches resource/key to synapseml-openai-3. |
| docs/Explore Algorithms/OpenAI/Quickstart - OpenAI Embedding and GPU based KNN.ipynb | Switches resource/key to synapseml-openai-3. |
| docs/Explore Algorithms/OpenAI/Quickstart - Multimodal OpenAI Prompter with Responses API.ipynb | Updates deployment to gpt-5.1 and new secret/resource. |
| docs/Explore Algorithms/OpenAI/OpenAI.ipynb | Updates deployments, removes sampling defaults for reasoning models, and modernizes Responses output extraction. |
| docs/Explore Algorithms/OpenAI/Langchain.ipynb | Migrates to LangChain Runnable pipelines + ChatOpenAI and updates endpoint/key usage. |
| docs/Explore Algorithms/AI Services/Quickstart - Document Question and Answering with PDFs.ipynb | Updates LangChain imports and AOAI config to GPT‑5.1 + v1 endpoint base URL. |
| core/src/test/scala/com/microsoft/azure/synapse/ml/Secrets.scala | Updates the OpenAI test secret name to openai-api-key-3. |
| cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIV1EndpointSuite.scala | Updates expected request URL/model mapping tests to GPT‑5.1. |
| cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIResponsesSuite.scala | Removes temperature usage and updates model strings/output expectations. |
| cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIPromptSuite.scala | Removes temperature usage and updates prompt text/headers/tests to GPT‑5.x naming. |
| cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIPromptResponsesSuite.scala | Switches live Responses tests to GPT‑5.1 and GPT‑5‑mini. |
| cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIEmbeddingsSuite.scala | Updates default non-embedding deployment used in defaults test to GPT‑5‑mini. |
| cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIDefaultsSuite.scala | Adds per-test default resets and updates globals usage for reasoning models. |
| cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIChatCompletionSuite.scala | Removes temperature usage and retargets reasoning/sampling behavior tests to new deployments. |
| cognitive/src/test/scala/com/microsoft/azure/synapse/ml/services/openai/OpenAIAPIKey.scala | Updates env var names and standard test deployment names to GPT‑5.1 / GPT‑5‑mini. |
| cognitive/src/test/python/synapsemltest/services/openai/test_StructuredOutput.py | Updates secret/resource/deployment and resets unsupported sampling defaults. |
| cognitive/src/test/python/synapsemltest/services/openai/test_OpenAIDefaults.py | Updates secret/resource/deployment and adds teardown resets for defaults. |
| cognitive/src/test/python/synapsemltest/services/langchain/test_LangchainTransform.py | Migrates tests to Runnable pipelines + ChatOpenAI with reasoning token parameters. |
| cognitive/src/main/python/synapse/ml/services/langchain/LangchainTransform.py | Updates serialization to langchain-core dumps/loads and supports Runnable invoke() with result normalization. |
Review details
Comments suppressed due to low confidence (1)
cognitive/src/main/python/synapse/ml/services/langchain/LangchainTransform.py:267
- The OpenAI <1.0 Azure configuration path no longer sets openai.api_type = "azure". For legacy openai SDK versions, omitting api_type can cause requests to be routed as non-Azure (or otherwise misconfigured), breaking existing LangchainTransformer usage when users rely on the transformer's subscriptionKey/url/apiVersion wiring.
else:
if self.isSet(self.subscriptionKey):
openai.api_key = self.getSubscriptionKey()
if self.isSet(self.url):
openai.api_base = self.getUrl()
- Files reviewed: 21/21 changed files
- Comments generated: 1
- Review effort level: Low
|
/azp run |
|
Azure Pipelines: No pipelines were found matching this branch/path. |
AB#5467643 ## Summary Remove OpenAI SDK 0.x compatibility and module-global client configuration, upgrade active Databricks LangChain dependencies, and make LangchainTransformer reject non-picklable network clients before Spark execution. Update the LangChain notebook to use current batching APIs and limit release compatibility coverage to Spark 3.5 and Spark 4.1. ## Prompting Intent The engineer asked to modernize SynapseML OpenAI tests and examples for GPT-5.1 or GPT-5-mini, remove support for openai<1.0, avoid deprecated APIs and reasoning-incompatible parameters, and update CI to support only Spark 3.5 and Spark 4.1. The engineer also required clean code review and validation before committing and pushing the changes. ## Linked Sources - Tracking bug: https://dev.azure.com/msdata/A365/_workitems/edit/5467643 - Pull request: microsoft#2572 ## Rationale Modern OpenAI clients contain non-picklable HTTP transport state. Rebuilding clients on workers from partial manifests changed authentication, transport, streaming, and rate-limiting behavior, so the transformer now preserves semantics by accepting only genuinely Spark-picklable Runnables and failing clearly otherwise. LangChain batching or SynapseML native OpenAI transformers remain the safe choices for network inference. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: dda7be17-25f0-41e2-bdeb-2f3f3c02438b
Summary
Modernize SynapseML's Azure OpenAI tests, examples, packages, and LangChain integration for
gpt-5.1andgpt-5-minion thesynapseml-openai-3resource. Remove OpenAI SDK 0.x compatibility, use current Azure OpenAI v1 APIs, and update release compatibility coverage to Spark 3.5 and Spark 4.1.Why
The previous coverage depended on old deployments, SDKs, and request behavior that is incompatible with current GPT-5 reasoning models:
temperatureandtop_p.What changed
gpt-5.1orgpt-5-mini.synapseml-openai-3/openai-api-key-3.max_completion_tokens/max_output_tokens.openai<1.0exception handling, legacyopenai.api_*global configuration, and legacy LangChain chain-loading fallback.LangchainTransformerto support Spark-picklable Runnables, normalize modern LangChain string outputs, capture currentOpenAIErrorexceptions, and fail clearly when a chain captures a non-picklable OpenAI client.pipeline.yamltriggers and release compatibility checks to support only Spark 3.5/JDK 11 and Spark 4.1/JDK 17.Validation
sbt "core/Test/compile" scalastyle test:scalastylesbt cognitive/Test/compileOpenAIDefaultsSuiteandOpenAIV1EndpointSuiteblack --check --extend-exclude 'docs/' .Dependency changes
langchain:0.0.152->1.3.14openai:0.27.5->2.47.0langchain-classic==1.0.8langchain-community==0.4.2langchain-openai==1.4.0Compatibility notes
LangchainTransformerno longer configures OpenAI through module-global state.