Add too many tokens errors and token-counting APIs#31
Conversation
This is mostly to align with webmachinelearning/writing-assistance-apis#31: * Use TooManyTokensError when appropriate, instead of a "QuotaExceededError" DOMException. * Rename tokensLeft/tokensSoFar to tokensAvailable/tokenCount. * Rename countPromptTokens() to countTokens(). * Remove maxTokens. * Rename "contextoverflow" to "overflow", since the vocabulary "context" is not used elsewhere in the API and there's only one relevant type of overflow for the session.
|
|
||
| It's possible that the inputs given for summarizing and rewriting might be too large for the underlying machine learning model to handle. The same can even be the case for strings that are usually smaller, such as the writing task for the writer API, or the context given to all APIs. | ||
|
|
||
| Whenever any API call fails due to too-large input, it is rejected with a `TooManyTokensError`. This is a new type of exception, which subclasses `DOMException`, and has the following additional properties: |
There was a problem hiding this comment.
Would it make sense to generalize the terminology here for other situations where input size could exceed a limit?
There was a problem hiding this comment.
Yes, that's probably a good idea. That might change my take on the naming for tokensAvailable to follow that new model, hmm. Like if we choose quota for the property of the exception, then maybe it should be tokenQuota.
I posted whatwg/webidl#1463.
There was a problem hiding this comment.
Proposed better idea at whatwg/webidl#1465 . This PR is on hold until we have agreement on that front.
9211561 to
70d6311
Compare
Closes #5. Closes #31 by obsoleting it. Depends on whatwg/webidl#1465.
|
#43 is the new approach. It consists of using |
Closes #5. Closes #31 by obsoleting it. Depends on whatwg/webidl#1465.
This is mostly to align with webmachinelearning/writing-assistance-apis#31: * Use TooManyTokensError when appropriate, instead of a "QuotaExceededError" DOMException. * Rename tokensLeft/tokensSoFar to tokensAvailable/tokenCount. * Rename countPromptTokens() to countTokens(). * Remove maxTokens. * Rename "contextoverflow" to "overflow", since the vocabulary "context" is not used elsewhere in the API and there's only one relevant type of overflow for the session.
Closes #5. Obsoletes #31. Depends on whatwg/webidl#1465.
Closes #5.
Preview | Diff