Skip to content

refactor: split disabled models for endpoints mapping into chat completions endpoint-disabled and completions endpoint-enabled mappings #974

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

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

Conversation

PChaparro
Copy link

Describe the change

This PR refactors model mapping logic by splitting the original disabledModelsForEndpoints map into two distinct maps: disabledModelsForChatCompletionsEndpoint and enabledModelsForDeprecatedCompletionsEndpoint.

This improves clarity and simplifies future maintenance of model support across endpoints.

Provide OpenAI documentation link

Describe your solution

  • Created disabledModelsForChatCompletionsEndpoint to list models not supported by the chat completions endpoint. Maintaining a deny list is simpler since most new models are supported by chat completions by default.

  • Created enabledModelsForDeprecatedCompletionsEndpoint to list models that are supported by the legacy completions endpoint. Maintaining an allow list is more appropriate here, since the completions endpoint is deprecated and no longer widely supported.

Tests

Executed the verification command provided in the CONTRIBUTING.md file. All tests passed successfully and the refactor did not introduce any regressions.

Issue: #972.

…etions endpoint-disabled and completions endpoint-enabled mappings
Copy link

codecov bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.46%. Comparing base (774fc9d) to head (cdb4504).
Report is 97 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #974       +/-   ##
===========================================
- Coverage   98.46%   85.46%   -13.00%     
===========================================
  Files          24       43       +19     
  Lines        1364     2271      +907     
===========================================
+ Hits         1343     1941      +598     
- Misses         15      308      +293     
- Partials        6       22       +16     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sashabaranov sashabaranov requested a review from Copilot April 29, 2025 13:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the model mapping logic for endpoint support by splitting the original mapping into two distinct maps—one for models not supported by the chat completions endpoint and one for models supported by the deprecated completions endpoint.

  • Defined a new constant (completionsEndpoint) to standardize the endpoint URL.
  • Replaced the single map with two mappings and updated the logic in checkEndpointSupportsModel accordingly.
  • Updated the client tests to include an explicit model field in CompletionRequest calls.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
completion.go Refactored endpoint model mapping logic with new mappings
client_test.go Updated tests to include explicit model requests for clarity
Comments suppressed due to low confidence (2)

completion.go:149

  • [nitpick] Consider clarifying the behavior for models not found in enabledModelsForDeprecatedCompletionsEndpoint. An explicit default or additional comment may improve readability.
if endpoint == completionsEndpoint {

completion.go:153

  • [nitpick] Consider adding a comment explaining the default 'true' behavior when a model is not present in disabledModelsForChatCompletionsEndpoint to aid future maintainers.
return !disabledModelsForChatCompletionsEndpoint[model]

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.

1 participant