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 for Chat Model Compatibility with v1/chat/completions Endpoint #45

Closed
wants to merge 1 commit into from
Closed

Fix for Chat Model Compatibility with v1/chat/completions Endpoint #45

wants to merge 1 commit into from

Conversation

andrewrobles
Copy link

Description:

This pull request addresses the issue of using chat models with the v1/completions endpoint, which results in an error. The fix ensures compatibility by conditionally using the appropriate OpenAI API endpoint based on the model type. This change resolves GitHub issue #43.

Issue Reference:

  • Issue: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions? #43
  • Error Message:
{
  "data": {
    "error": {
      "message": "This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?",
      "type": "invalid_request_error",
      "param": "model",
      "code": null
    }
  }
}

Config:

{
  "model": "gpt-3.5-turbo",
  "temperature": 0.5,
  "maxTokens": 2048
}

Changes Made:

Refactored ChatGPTClient class to handle both chat and completion models:

  • Added conditional logic to check if the model is a chat model (gpt-3.5-turbo, gpt-4, etc.).
  • Used the createChatCompletion method for chat models.
  • Used the createCompletion method for completion models.

Testing:

Tested with both chat models (gpt-3.5-turbo, gpt-4) and completion models (davinci, curie, etc.) to ensure the correct endpoint is used and responses are handled appropriately.

This fix will ensure that chat models will no longer produce the "not supported" error by using the appropriate v1/chat/completions endpoint.

Please review and merge this pull request to resolve issue #43.

@andrewrobles andrewrobles closed this by deleting the head repository Aug 20, 2024
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