Skip to content

✨ Added support for response formats #3

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

Merged
merged 3 commits into from
Mar 15, 2025

Conversation

jeffreyvr
Copy link
Contributor

Added the option to set a response format including a test.

The Grok API supports setting a response format, also refered to structured outputs, for the grok-2-1212 model.

$options = new ChatOptions(model: Model::GROK_2_1212, temperature: 0.7, stream: false, responseFormat: ['type' => 'json_object']);
$response = $client->chat($messages, $options);

@thefeqy
Copy link
Contributor

thefeqy commented Mar 7, 2025

Thanks for your contribution. I just need to test it and merge it right away.

@thefeqy
Copy link
Contributor

thefeqy commented Mar 7, 2025

Great job on this!

Just a small issue—our tests no longer interact with the actual Grok API. Instead, we now use fake responses, which is causing the tests you've written to fail.

image

There's also a minor conflict with the README.md file.

Thanks for your contribution! Looking forward to merging this PR soon. 🚀

@jeffreyvr
Copy link
Contributor Author

Thanks! Conflicts have been resolved. Made a minor change to the mock response to allow for setting specific data to be returned.

@thefeqy thefeqy merged commit 097e8c9 into grok-php:main Mar 15, 2025
12 checks passed
@thefeqy
Copy link
Contributor

thefeqy commented Mar 15, 2025

Thanks for your contribution ♥️

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.

2 participants