refactor: Simplify selection of Azure vs OpenAI invocation layers #5271
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.
What?
This PR introduces a refactoring change that removes the dependency on Azure layers check within the PromptModel (see loc 90-95). As part of this change, we have added a utility function
has_azure_parameters
which simplifies the logic of selecting the right invocation layer between Azure and OpenAI:Why?
Currently, a small kludge in the PromptModel checks for the presence of Azure layers. However, PromptModel should not know specific implementation details related to Azure layers. This change relies on the existing logic from the
supports
method to select the right invocation layer and ensures a cleaner separation of responsibilities.How can it be used?
This is an internal change and does not affect any public APIs. Therefore, everything will function as before from the user's perspective. The utility function we added streamlines the internal selection process between Azure and OpenAI invocation layers.
How did you test it?
We have strengthened our test coverage by adding an integration test. This new test uses PromptNode with Azure and OpenAI model parameters and checks for the right invocation layer selection.
Notes for the reviewer
This change should not affect functionality from a user's perspective.
Your feedback or suggestions are welcome.