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

Add Chat completion #293

Closed
arturhayne opened this issue Dec 14, 2023 · 2 comments
Closed

Add Chat completion #293

arturhayne opened this issue Dec 14, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@arturhayne
Copy link

arturhayne commented Dec 14, 2023

Description

Completion API was deprecated with final last update in July 2023 as stated in open api documentation.

A new API endpoint was created to support GPT-4 model, chat completions.

I believe we have to create a new class, ChatCompletions to support this endpoint following same structured we have in Completions class.

Steps To Reproduce

If we try to use gpt-4 as:

$result = $client->completions()->create([
    'model' => 'gpt-4',
    'prompt' => 'Peas are ',
]);

An error will surface:

Fatal error: Uncaught OpenAI\Exceptions\ErrorException: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions? in /var/www/html/vendor/openai-php/client/src/Transporters/HttpTransporter.php on line 131

OpenAI\Exceptions\ErrorException: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions? in /var/www/html/vendor/openai-php/client/src/Transporters/HttpTransporter.php on line 131

OpenAI PHP Client Version

v0.8.0

PHP Version

8.1.2

Notes

No response

@arturhayne arturhayne added the bug Something isn't working label Dec 14, 2023
@pb30
Copy link

pb30 commented Dec 14, 2023

See README. You need to use the Chat resource

@arturhayne
Copy link
Author

arturhayne commented Dec 14, 2023

You are right. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants