Add token usage to OpenAiProviderClientBase
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3541473. --> Reported by: [marcus_johansson](https://www.drupal.org/user/385947) Related to !829 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>Currently the OpenAiProviderClientBase does not implement the five methods we have for the token usage. Of course this might differ per OpenAI based API, since the metadata is not always consistent.</p> <p>This means that we should move this to a method in the base that you may extend if its different, that gives in the ChatOutput object and the response and that returns the ChatOutput object potentially modified. I think that's the best solution - pass by reference would work as well.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Add a new method called setTokenUsage that takes ChatOutput and response and returns ChatOutput.<br> In OpenAiProviderClientBase created a default version based on OpenAI, but that also uses null coalescing operator if its not set.</p>
issue