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

chore: Optimizing the method getOptionalParams in HasOpenAITextParams #2315

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

FarrukhMasud
Copy link
Contributor

@FarrukhMasud FarrukhMasud commented Nov 15, 2024

Related Issues/PRs

The method getOptionalParams in HasOpenAITextParams was implemented in such a way that for every row in the data frame it will:

  1. Create a List of all shared text parameter except logprobs
  2. Call flatMap on each element in list to get optional parameters with snake-case name
  3. Create one more list with just logprobs parameter
  4. Call flatMap on this single element list
  5. Compbine this new tuple with the other list
  6. Convert this list of tuple to Map and return

We can do better to make code cleaner and more readable.

What changes are proposed in this pull request?

One of the reason for creating a list of all shared text parameters except logprobs is that we wanted to name these parameters in snake-case. We can do this while creating parameter object, hence no need to call method to generate snake-case for every iteration. This way we can put all parameters in a single list.

How is this patch tested?

Since this essentially just refactoring the code, I have tested this by running the tests. Existing tests should validate that the code is working as expected

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.

@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 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.47%. Comparing base (a360886) to head (ff220f7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2315      +/-   ##
==========================================
- Coverage   84.57%   84.47%   -0.11%     
==========================================
  Files         326      326              
  Lines       16769    16755      -14     
  Branches     1480     1480              
==========================================
- Hits        14183    14154      -29     
- Misses       2586     2601      +15     

☔ 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).

@FarrukhMasud
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mhamilton723 mhamilton723 merged commit 08aab6a into microsoft:master Nov 18, 2024
68 checks passed
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