diff --git a/index.bs b/index.bs index f57a590..af15f00 100644 --- a/index.bs +++ b/index.bs @@ -36,6 +36,8 @@ dl.props { display: grid; grid-template-columns: max-content auto; row-gap: 0.25 dl.props > dt { grid-column-start: 1; margin: 0; } dl.props > dd { grid-column-start: 2; margin: 0; } p + dl.props { margin-top: -0.5em; } + +.enum-table tbody th { white-space: nowrap; }
This value is separate from the [=AISummarizer/destruction reason=] so that it can be read from [=in parallel=] during the summarization process. + +
This variable will be written to from the [=event loop=], but read from [=in parallel=]. + + 1. If |options|["{{AISummarizerSummarizeOptions/signal}}"] [=map/exists=], then [=AbortSignal/add|add the following abort steps=] to |options|["{{AISummarizerSummarizeOptions/signal}}"]: + + 1. Set |abortedDuringSummarization| to true. + + 1. Let |promise| be [=a new promise=] created in [=this=]'s [=relevant realm=]. + + 1. Let |context| be |options|["{{AISummarizerSummarizeOptions/context}}"] if it [=map/exists=]; otherwise null. + + 1. [=In parallel=]: + + 1. Let |summary| be the empty string. + + 1. Let |chunkProduced| be the following steps given a [=string=] |chunk|: + + 1. [=Queue a global task=] on the [=AI task source=] given [=this=]'s [=relevant global object=] to perform the following steps: + + 1. If |abortedDuringSummarization| is true, then: + + 1. [=Reject=] |promise| with |options|["{{AISummarizerSummarizeOptions/signal}}"]'s [=AbortSignal/abort reason=]. + + 1. Abort these steps. + + 1. If [=this=]'s [=AISummarizer/destroyed=] is true, then: + + 1. [=Reject=] |promise| with [=this=]'s [=AISummarizer/destruction reason=]. + + 1. Abort these steps. + + 1. Append |chunk| to |summary|. + + 1. Let |done| be the following steps: + + 1. [=Queue a global task=] on the [=AI task source=] given [=this=]'s [=relevant global object=] to perform the following steps: + + 1. If |abortedDuringSummarization| is true, then: + + 1. [=Reject=] |promise| with |options|["{{AISummarizerSummarizeOptions/signal}}"]'s [=AbortSignal/abort reason=]. + + 1. Abort these steps. + + 1. If [=this=]'s [=AISummarizer/destroyed=] is true, then: + + 1. [=Reject=] |promise| with [=this=]'s [=AISummarizer/destruction reason=]. + + 1. Abort these steps. + + 1. [=Resolve=] |promise| with |summary|. + + 1. Let |error| be the following steps given [=summarization error information=] |errorInfo|: + + 1. [=Queue a global task=] on the [=AI task source=] given [=this=]'s [=relevant global object=] to perform the following steps: + + 1. If |abortedDuringSummarization| is true, then: + + 1. [=Reject=] |promise| with |options|["{{AISummarizerSummarizeOptions/signal}}"]'s [=AbortSignal/abort reason=]. - 1. TODO use |summarizer| and |exception|. + 1. Abort these steps. + + 1. Let |exception| be the result of [=exception/creating=] a {{DOMException}} with name given by |errorInfo|'s [=summarization error information/error name=], using |errorInfo|'s [=summarization error information/error information=] to populate the message appropriately. + + 1. [=Reject=] |promise| with |exception|. + + 1. Let |stopProducing| be the following steps: + + 1. Return |abortedDuringSummarization|. + + 1. [=Summarize=] |input| given [=this=]'s [=AISummarizer/shared context=], |context|, [=this=]'s [=AISummarizer/summary type=], [=this=]'s [=AISummarizer/summary format=], [=this=]'s [=AISummarizer/summary length=], |chunkProduced|, |done|, |error|, and |stopProducing|. + + 1. Return |promise|.
This variable tracks web developer aborts via the |options|["{{AISummarizerSummarizeOptions/signal}}"] {{AbortSignal}}, which are surfaced as errors. It will be written to from the [=event loop=], but sometimes read from [=in parallel=]. + + 1. If |options|["{{AISummarizerSummarizeOptions/signal}}"] [=map/exists=], then [=AbortSignal/add|add the following abort steps=] to |options|["{{AISummarizerSummarizeOptions/signal}}"]: + + 1. Set |abortedDuringSummarization| to true. + + 1. Let |stream| be a [=new=] {{ReadableStream}} created in [=this=]'s [=relevant realm=]. + + 1. Let |canceledDuringSummarization| be false. + +
This variable tracks web developer [=ReadableStream/cancel|stream cancelations=] via {{ReadableStream/cancel()|stream.cancel()}}, which are not surfaced as errors. It will be written to from the [=event loop=], but sometimes read from [=in parallel=]. + + 1. [=ReadableStream/Set up=] |stream| with [=ReadableStream/set up/cancelAlgorithm=] set to the following steps (ignoring the reason argument): + + 1. Set |canceledDuringSummarization| to true. + + 1. Let |context| be |options|["{{AISummarizerSummarizeOptions/context}}"] if it [=map/exists=]; otherwise null. + + 1. [=In parallel=]: + + 1. Let |chunkProduced| be the following steps given a [=string=] |chunk|: + + 1. [=Queue a global task=] on the [=AI task source=] given [=this=]'s [=relevant global object=] to perform the following steps: + + 1. If |abortedDuringSummarization| is true, then: + + 1. [=ReadableStream/Error=] |stream| with |options|["{{AISummarizerSummarizeOptions/signal}}"]'s [=AbortSignal/abort reason=]. + + 1. Abort these steps. + + 1. If [=this=]'s [=AISummarizer/destroyed=] is true, then: + + 1. [=ReadableStream/Error=] |stream| with [=this=]'s [=AISummarizer/destruction reason=]. + + 1. Abort these steps. + + 1. [=ReadableStream/Enqueue=] |chunk| into |stream|. + + 1. Let |done| be the following steps: + + 1. [=Queue a global task=] on the [=AI task source=] given [=this=]'s [=relevant global object=] to perform the following steps: + + 1. If |abortedDuringSummarization| is true, then: + + 1. [=ReadableStream/Error=] |stream| with |options|["{{AISummarizerSummarizeOptions/signal}}"]'s [=AbortSignal/abort reason=]. + + 1. Abort these steps. + + 1. If [=this=]'s [=AISummarizer/destroyed=] is true, then: + + 1. [=ReadableStream/Error=] |stream| with [=this=]'s [=AISummarizer/destruction reason=]. + + 1. Abort these steps. + + 1. [=ReadableStream/Close=] |stream|. + + 1. Let |error| be the following steps given [=summarization error information=] |errorInfo|: + + 1. [=Queue a global task=] on the [=AI task source=] given [=this=]'s [=relevant global object=] to perform the following steps: + + 1. If |abortedDuringSummarization| is true, then: + + 1. [=ReadableStream/Error=] |stream| with |options|["{{AISummarizerSummarizeOptions/signal}}"]'s [=AbortSignal/abort reason=]. + + 1. Abort these steps. + + 1. If [=this=]'s [=AISummarizer/destroyed=] is true, then: + + 1. [=ReadableStream/Error=] |stream| with [=this=]'s [=AISummarizer/destruction reason=]. + + 1. Abort these steps. + + 1. Let |exception| be the result of [=exception/creating=] a {{DOMException}} with name given by |errorInfo|'s [=summarization error information/error name=], using |errorInfo|'s [=summarization error information/error information=] to populate the message appropriately. + + 1. [=ReadableStream/Error=] |stream| with |exception|. + + 1. Let |stopProducing| be the following steps: + + 1. If any of |abortedDuringSummarization|, |canceledDuringSummarization|, or [=this=]'s [=AISummarizer/destroyed=] are true, then return true. + + 1. Return false. + + 1. [=Summarize=] |input| given [=this=]'s [=AISummarizer/shared context=], |context|, [=this=]'s [=AISummarizer/summary type=], [=this=]'s [=AISummarizer/summary format=], [=this=]'s [=AISummarizer/summary length=], |chunkProduced|, |done|, |error|, and |stopProducing|. + + 1. Return |stream|. +
Otherwise, the {{AISummarizer}} object would not have been created. + + 1. In an [=implementation-defined=] manner, subject to the following guidelines, begin the processs of summarizing |input| into a string. + + If they are non-null, |sharedContext| and |context| should be used to aid in the summarization by providing context on how the web developer wishes the input to be summarized. + + The summarization should conform to the guidance given by |type|, |format|, and |length|, in the definitions of each of their enumeration values. + + 1. While true: + + 1. Wait for the next chunk of summarization data to be produced, for the summarization process to finish, or for the result of calling |stopProducing| to become true. + + 1. If such a chunk is successfully produced: + + 1. Let it be represented as a [=string=] |chunk|. + + 1. Perform |chunkProduced| given |chunk|. + + 1. Otherwise, if the summarization process has finished: + + 1. Perform |done|. + + 1. [=iteration/Break=]. + + 1. Otherwise, if |stopProducing| returns true, then [=iteration/break=]. + +
The caller will handle signaling cancelation or aborting as necessary. + + 1. Otherwise, if an error occurred during summarization: + + 1. Let the error be represented as [=summarization error information=] |errorInfo| according to the guidance in [[#summarizer-errors]]. + + 1. Perform |error| given |errorInfo|. + + 1. [=iteration/Break=]. +
The destroy() method steps are to [=AISummarizer/destroy=] [=this=] given a new "{{AbortError}}" {{DOMException}}. +
Value + | Meaning + |
---|---|
"tl;dr" + |
+ The summary should be short and to the point, providing a quick overview of the input, suitable for a busy reader. + |
"teaser" + |
+ The summary should focus on the most interesting or intriguing parts of the input, designed to draw the reader in to read more. + |
"key-points" + |
+ The summary should extract the most important points from the input, presented as a bulleted list. + |
"headline" + |
+ The summary should effectively contain the main point of the input in a single sentence, in the format of an article headline. + |
Value + | Meaning + |
---|---|
"short" + |
+ The guidance is dependent on the value of {{AISummarizerType}}: + +
|
"medium" + |
+ The guidance is dependent on the value of {{AISummarizerType}}: + +
|
"long" + |
+ The guidance is dependent on the value of {{AISummarizerType}}: + +
|
As with all "should"-level guidance, user agents might not conform perfectly to these. Especially in the case of counting words, it's expected that language models might not conform perfectly.
+
+ The summary should not contain any formatting or markup language.
+ The summary should be formatted using the Markdown markup language, ideally as valid CommonMark. [[!COMMONMARK]]
+ Summarization is disabled by user choice or user agent policy.
+ The summarization output was filtered by the user agent, e.g., because it was detected to be harmful, inaccurate, or nonsensical.
+ The input to be summarized was in a language that the user agent does not support summarizing.
+ The summarization output was detected to be in a language that the user agent does not have sufficient quality control for and is not willing to support.
+ The input to be summarized was too large for the user agent to handle.
+ All other scenarios, or if the user agent would prefer not to disclose the failure reason.
+ This table does not give the complete list of exceptions that can be surfaced by {{AISummarizer/summarize()|summarizer.summarize()}} and {{AISummarizer/summarize()|summarizer.summarizeStreaming()}}. It only contains those which can come from the [=implementation-defined=] [=summarize=] algorithm.
+
+
+
+
+ Value
+ Meaning
+
+ "plain-text"
+
+
+ "markdown"
+
+ Errors
+
+A summarization error information is a [=struct=] with the following items:
+
+: error name
+:: a [=string=] that will be used for the {{DOMException}}'s [=DOMException/name=].
+: error information
+:: other information necessary to create a useful {{DOMException}} for the web developer. (Typically, just an exception message.)
+
+When summarization fails, the following possible reasons may be surfaced to the web developer. This table lists the possible {{DOMException}} [=DOMException/names=] and the cases in which an implementation should use them:
+
+
+
+
+
+
+
+ {{DOMException}} [=DOMException/name=]
+ Scenarios
+
+ "{{NotAllowedError}}"
+
+
+ "{{NotReadableError}}"
+
+
+ "{{NotSupportedError}}"
+
+
+ "{{QuotaExceededError}}"
+
+
+ "{{UnknownError}}"
+
+