Usage stats in streaming chat need conversion to an array.

Created on 7 November 2024, about 1 month ago

Problem/Motivation

\Drupal\ai\OperationType\Chat\StreamedChatMessage::__construct expects the third parameter to be an array. However, when a streaming chat is created with usage included, such as with the following example configuration:

      /** @var \Drupal\ai_provider_openai\Plugin\AiProvider\OpenAiProvider $provider */
      $provider->setConfiguration([
        'stream_options' => [
          'include_usage' => TRUE,
        ],
      ]);

the third parameter will be an object of type OpenAI\Responses\Chat\CreateResponseUsage resulting in an Exception.

Proposed resolution

Remaining tasks

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada shaundychko

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024