WordPress / WordPress/php-ai-client
Improve handling of unprovided usage statistics
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 308
- Forks
- 84
- Avg merge
- 7d 21h
- Merged PRs (30d)
- 2
Description
The TokenUsage DTO right now has a couple of limitations to it:
- It can't be null in the
GenerativeAiResultDTO, so it's assumed to always be supplied - The individual properties of
TokenUsageare all non-nullable, so they must also be supplied
The work around for this has been to do something like new TokenUsage(0, 0, 0) to indicate the values weren't provided. This is confusing and makes it hard to distinguish between statistics not being provided versus actual values. This will become even more important if we add additional properties in the future that only some providers support.
I recommend making the properties nullable as well as the TokenUsage instance nullable in GenerativeAiResult.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the TokenUsage and GenerativeAiResult DTO definitions and the tests that cover their construction or serialization. Trace how missing usage statistics are currently represented, then update the DTO contracts so both the TokenUsage value and its individual properties can be absent. Done means callers can distinguish unprovided statistics from zero values and the relevant tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100