chromium/third_party/blink/public/mojom/ai/ai_text_session.mojom

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

module blink.mojom;

import "third_party/blink/public/mojom/ai/ai_text_session_info.mojom";
import "third_party/blink/public/mojom/ai/model_streaming_responder.mojom";

// A session for a model that allows executing an input and streaming the output.
interface AITextSession {
  // Prompts the model on the given input.
  Prompt(string input, pending_remote<ModelStreamingResponder> pending_responder);
  // Creates a new session with the same configuration and existing context as
  // the current session.
  // Note that this method is called by the `AITextSession.clone()` method from
  // blink, but it is named as `Fork` instead of `Clone` to avoid confusion with
  // the "clone" term in mojo context (which indicates binding another client to
  // the same instance).
  // Similar to `AIManager.CreateTextSession`, this method returns the information
  // of the created session.
  Fork(
    pending_receiver<blink.mojom.AITextSession> session
  ) => (AITextSessionInfo? info);
  // Destroys the session.
  Destroy();
};