-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add too many tokens errors and token-counting APIs #31
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Preview | Diff