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

fix: Fixing OpenAIPrompt class to be able to work with older models like text-davinci-003 #2319

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

FarrukhMasud
Copy link
Contributor

Issue

While working with OpenAIPrompt class, I discovered that this class does not work with older models. Upon investigation, I found that for models specified in the list legacyModels, OpenAIPrompt class suppose to use OpenAICompletion instance, for all other model deployment names, OpenAIChatCompletion class is to be used. When setting parameter for OpenAICompletion, it tries to set parameters that are not available in OpenAICompletion, which causes instance creation to fail. There are no current unit tests or integration tests that verified this. In this PR, I am fixing this problem and adding unit test to validate this. I am also cleaning unit test and OpenAIPrompt class.

What changes are proposed in this pull request?

In this PR I am:

  1. Ensuring that new prompt instances are created for each test. This will eliminate chance of one test interfering with another test.
  2. Creating test to validate that for older model deployments, OpenAiCompletion instance is created in OpenAIPrompt class.
  3. Fixing the bug that caused creation of OpenAICompletion object to fail.
  4. Cleaning some code in OpenAIPrompt class.

How is this patch tested?

  • I have written tests (not required for typo or doc fix) and confirmed the proposed feature/bug-fix/change works.

Does this PR change any dependencies?

  • No. You can skip this section.
  • Yes. Make sure the dependencies are resolved correctly, and list changes here.

Does this PR add a new feature? If so, have you added samples on website?

  • No. You can skip this section.
  • Yes. Make sure you have added samples following below steps.

1. Ensuring that new prompt instances are created for each test. This will eliminate chance of one test interfering with another test.
2. Creating test to validate that for older model deployments, OpenAiCompletion instance is created in OpenAIPrompt class.
3. Fixing the bug that caused creation of OpenAICompletion object to fail.
4. Cleaning some code in OpenAIPrompt class.
@FarrukhMasud
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 84.49%. Comparing base (08aab6a) to head (7435ae8).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...zure/synapse/ml/services/openai/OpenAIPrompt.scala 60.00% 2 Missing ⚠️
...soft/azure/synapse/ml/services/openai/OpenAI.scala 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2319      +/-   ##
==========================================
- Coverage   84.50%   84.49%   -0.01%     
==========================================
  Files         326      328       +2     
  Lines       16755    16771      +16     
  Branches     1480     1513      +33     
==========================================
+ Hits        14158    14170      +12     
- Misses       2597     2601       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@FarrukhMasud
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

}


test("Validating OpenAICompletion and OpenAIChatCompletion for correctModels") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

gorgeous!

@@ -307,4 +308,6 @@ abstract class OpenAIServicesBase(override val uid: String) extends CognitiveSer
}
super.getInternalTransformer(schema)
}

private[openai] def prepareEntityAIService: Row => Option[AbstractHttpEntity] = this.prepareEntity
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this function necessary? seems like its not but hard to tell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants