Skip to content
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

refactor: Simplify selection of Azure vs OpenAI invocation layers #5271

Merged
merged 5 commits into from
Jul 6, 2023

Conversation

vblagoje
Copy link
Member

@vblagoje vblagoje commented Jul 4, 2023

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:

def has_azure_parameters(**kwargs) -> bool:
    azure_params = ["azure_base_url", "azure_deployment_name"]
    return any(kwargs.get(param) for param in azure_params)

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.

@vblagoje vblagoje requested a review from a team as a code owner July 4, 2023 12:09
@vblagoje vblagoje requested review from julian-risch and removed request for a team July 4, 2023 12:09
@coveralls
Copy link
Collaborator

coveralls commented Jul 4, 2023

Pull Request Test Coverage Report for Build 5462308609

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 109 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-0.03%) to 43.913%

Files with Coverage Reduction New Missed Lines %
nodes/prompt/invocation_layer/azure_chatgpt.py 2 89.47%
nodes/prompt/invocation_layer/azure_open_ai.py 2 89.47%
document_stores/search_engine.py 4 62.39%
nodes/prompt/invocation_layer/chatgpt.py 7 75.0%
nodes/prompt/prompt_model.py 7 86.0%
nodes/prompt/invocation_layer/open_ai.py 8 80.0%
document_stores/elasticsearch/es8.py 79 0%
Totals Coverage Status
Change from base Build 5453787062: -0.03%
Covered Lines: 10107
Relevant Lines: 23016

💛 - Coveralls

Copy link
Member

@julian-risch julian-risch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Good refactoring! 👍

@vblagoje vblagoje merged commit ac41219 into main Jul 6, 2023
@vblagoje vblagoje deleted the azure_layer_fix branch July 6, 2023 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants