chromium/third_party/blink/renderer/modules/ai/ai_rewriter.idl

// Copyright 2024 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Rewriter API
// https://github.com/explainers-by-googlers/writing-assistance-apis

dictionary AIRewriterRewriteOptions {
  DOMString context;
  AbortSignal signal;
};

[
  Exposed=(Window,Worker),
  RuntimeEnabled=AIRewriterAPI
]
interface AIRewriter {
  [
    Measure,
    CallWith=ScriptState,
    RaisesException
  ]
  Promise<DOMString> rewrite(
    DOMString input,
    optional AIRewriterRewriteOptions options = {});

  [
    Measure,
    CallWith=ScriptState,
    RaisesException
  ]
  ReadableStream rewriteStreaming(
    DOMString input,
    optional AIRewriterRewriteOptions options = {});

  [
    Measure,
    CallWith=ScriptState,
    RaisesException
  ]
  void destroy();

  readonly attribute DOMString sharedContext;
  readonly attribute AIRewriterTone tone;
  readonly attribute AIRewriterLength length;
};