You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -103,7 +103,7 @@ const result = await writer.write(
103
103
```
104
104
105
105
```js
106
-
constrewriter=awaitai.rewriter.create({
106
+
constrewriter=awaitRewriter.create({
107
107
sharedContext:"A review for the Flux Capacitor 3000 from TimeMachines Inc."
108
108
});
109
109
@@ -117,7 +117,7 @@ const result = await rewriter.rewrite(reviewEl.textContent, {
117
117
All three of the APIs support streaming output, via counterpart methods `summarizeStreaming()` / `writeStreaming()` / `rewriteStreaming()` that return `ReadableStream`s of strings. A sample usage would be:
"A draft for an inquiry to my bank about how to enable wire transfers on my account"
@@ -133,7 +133,7 @@ for (const chunk of stream) {
133
133
A created summarizer/writer/rewriter object can be used multiple times. **The only shared state is the initial configuration options**; the inputs do not build on each other. (See more discussion [below](#one-shot-functions-instead-of-summarizer--writer--rewriter-objects).)
@@ -150,7 +150,7 @@ The default behavior for the summarizer/writer/rewriter objects assumes that the
150
150
It's better practice, if possible, to supply the `create()` method with information about the expected languages in use. This allows the implementation to download any necessary supporting material, such as fine-tunings or safety-checking models, and to immediately reject the promise returned by `create()` if the web developer needs to use languages that the browser is not capable of supporting:
151
151
152
152
```js
153
-
constsummarizer=awaitai.summarize.create({
153
+
constsummarizer=awaitSummarizer.create({
154
154
type:"key-points",
155
155
expectedInputLanguages: ["ja", "ko"],
156
156
expectedContextLanguages: ["en", "ja", "ko"],
@@ -189,7 +189,7 @@ Whenever any API call fails due to too-large input, it is rejected with a `Quota
189
189
This allows detecting failures due to overlarge inputs and giving clear feedback to the user, with code such as the following:
Note that all of the following methods can reject (or error the relevant stream) with this type of exception:
207
207
208
-
*`ai.summarizer.create()`, if `sharedContext` is too large;
208
+
*`Summarizer.create()`, if `sharedContext` is too large;
209
209
210
-
*`ai.summarizer.summarize()`/`summarizeStreaming()`, if the combination of the creation-time `sharedContext`, the current method call's `input` argument, and the current method call's `context` is too large;
210
+
*`summarize()`/`summarizeStreaming()`, if the combination of the creation-time `sharedContext`, the current method call's `input` argument, and the current method call's `context` is too large;
211
211
212
212
* Similarly for writer creation / writing, and rewriter creation / rewriting.
213
213
214
214
In some cases, instead of providing errors after the fact, the developer needs to be able to communicate to the user how close they are to the limit. For this, they can use the `inputQuota` property and the `measureInputUsage()` method on the summarizer/writer/rewriter objects:
215
215
216
216
```js
217
-
constrewriter=awaitai.rewriter.create();
217
+
constrewriter=awaitRewriter.create();
218
218
meterEl.max=rewriter.inputQuota;
219
219
220
220
textbox.addEventListener("input", () => {
@@ -264,15 +264,15 @@ An example usage is the following:
// Either the API overall, or the combination of teaser + Japanese input, is not available.
@@ -286,7 +286,7 @@ if (availability !== "unavailable") {
286
286
For cases where using the API is only possible after a download, you can monitor the download progress (e.g. in order to show your users a progress bar) using code such as the following:
287
287
288
288
```js
289
-
constwriter=awaitai.writer.create({
289
+
constwriter=awaitWriter.create({
290
290
...otherOptions,
291
291
monitor(m) {
292
292
m.addEventListener("downloadprogress", e=> {
@@ -322,7 +322,7 @@ Each API comes equipped with a couple of `signal` options that accept `AbortSign
@@ -393,12 +393,6 @@ Although the APIs contain support for streaming output, they don't support strea
393
393
394
394
However, we believe that streaming input would not be a good fit for these APIs. Attempting to summarize or rewrite input as more input streams in will likely result in multiple wasteful rounds of revision. The underlying language model technology does not support streaming input, so the implementation would be buffering the input stream anyway, then repeatedly feeding new versions of the buffered text to the language model. If a developer wants to achieve such results, they can do so themselves, at the cost of writing code which makes the wastefulness of the operation more obvious. Developers can also customize such code, e.g. by only asking for new summaries every 5 seconds (or whatever interval makes the most sense for their use case).
395
395
396
-
### Alternative API spellings
397
-
398
-
In [the TAG review of the translation and language detection APIs](https://github.com/w3ctag/design-reviews/issues/948), some TAG members suggested slightly different patterns than the `ai.something.create()` pattern, such as `AISomething.create()` or `Something.create()`.
399
-
400
-
We are open to such surface-level tweaks to the API entry points, and intend to gather more data from web developers on what they find more understandable and clear.
401
-
402
396
### Directly exposing a "prompt API"
403
397
404
398
The same team that is working on these APIs is also prototyping an experimental [prompt API](https://github.com/webmachinelearning/prompt-api/). A natural question is how these efforts related. Couldn't one easily accomplish summarization/writing/rewriting by directly prompting a language model, thus making these higher-level APIs redundant?
0 commit comments