Interface BaseLlmConnection

All Known Implementing Classes:
GeminiLlmConnection

public interface BaseLlmConnection
用于实现实时模型连接的基类。
  • 方法概述

    Modifier and Type
    Method
    Description
    void
    关闭连接。
    void
    close(Throwable throwable)
    以错误状态关闭连接。
    io.reactivex.rxjava3.core.Flowable<LlmResponse>
    接收模型的响应结果。
    io.reactivex.rxjava3.core.Completable
    sendContent(com.google.genai.types.Content content)
    将用户生成的内容发送给模型。
    default io.reactivex.rxjava3.core.Completable
    sendContent(com.google.genai.types.Content content, boolean partial)
    将用户内容发送给模型;同时可以选择让当前轮次保持开放状态,以便用户继续添加更多内容。
    io.reactivex.rxjava3.core.Completable
    sendHistory(List<com.google.genai.types.Content> history)
    将对话历史记录发送给模型。
    io.reactivex.rxjava3.core.Completable
    sendRealtime(com.google.genai.types.Blob blob)
    实时将一段音频或一帧视频数据发送给模型。
  • 方法详细信息(Method Details)

    • sendHistory

      io.reactivex.rxjava3.core.Completable sendHistory(List<com.google.genai.types.Content> history)
      将对话历史记录发送给模型。

      你需要在建立模型连接后立即调用此方法。如果模型中的最新数据来自用户输入,模型会立即作出响应;否则,模型会等待用户再次输入新的数据后再作出响应。

    • sendContent

      io.reactivex.rxjava3.core.Completable sendContent(com.google.genai.types.Content content)
      将用户生成的内容发送给模型。

      该模型在接收到内容后会立即作出响应。如果您发送的是函数响应(function responses),那么内容中的所有部分都必须是函数响应。

    • sendContent

      default io.reactivex.rxjava3.core.Completable sendContent(com.google.genai.types.Content content, boolean partial)
      将用户内容发送给模型;同时可以选择让当前轮次保持开放状态,以便用户继续添加更多内容。

      默认的实现会忽略这一点。 partial 并调用(相关函数或方法) sendContent(Content)仅由函数返回的结果组成的内容,总是以“工具响应”(tool response)的形式被发送出去。

      Parameters:
      content - the content to send
      partial - whether this content is a partial update that does not complete the current turn
    • sendRealtime

      io.reactivex.rxjava3.core.Completable sendRealtime(com.google.genai.types.Blob blob)
      实时将一段音频或一帧视频数据发送给模型。

      该模型在接收到数据后可能不会立即做出响应。它会先进行语音活动检测,然后决定何时再作出回应。

    • receive

      io.reactivex.rxjava3.core.Flowable<LlmResponse> receive()
      接收模型的响应结果。
    • close

      void close()
      关闭连接。
    • close

      void close(Throwable throwable)
      以错误状态关闭连接。