Problem/Motivation
When using the Mistral provider with AI Logging enabled, non-streamed chat responses are logged as {} (empty JSON object) instead of the actual response data.
the ai_provider_mistral module passes a Partitech\PhpMistral\Clients\Response object directly to ChatOutput,
but this object has private properties and doesn't implement JsonSerializable, so json_encode() returned {}
Steps to reproduce
1. Install ai_provider_mistral 1.1.0-beta1 and ai_logging
2. Configure Mistral as the default chat provider
3. Enable "Log AI responses" in AI Logging settings
4. Use any AI Suggestion feature without streaming
5. Check AI Logs at /admin/reports/ai-logging
Proposed resolution
Convert the response to an array and then use it when returning ChatOutput
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3568834-response-serialization.patch | 2.45 KB | petar_basic |
Issue fork ai_provider_mistral-3568834
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
petar_basic commentedThe Partitech\PhpMistral\Clients\Response object passed to ChatOutput as rawOutput has private properties and doesn't implement JsonSerializable, causing json_encode() to return {} in AI logs. Fixed by adding a responseToArray() helper that extracts the response data (id, model, usage, choices) into a serializable array.
Comment #4
fagothx, looks good, but it shows our test-coverage is lacking there also -> exactly this missing piece we should make sure we have test-coverage for. Let's add this with the fix!
Comment #5
fagoComment #6
petar_basic commentedAdded tests, please check
Comment #8
fagothx, the tests smell like AI, but good enough. Merged!