Interface BaseLlmConnection

All Known Implementing Classes:
GeminiLlmConnection

public interface BaseLlmConnection
The base class for a live model connection.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the connection.
    void
    close(Throwable throwable)
    Closes the connection with an error.
    io.reactivex.rxjava3.core.Flowable<LlmResponse>
    Receives the model responses.
    io.reactivex.rxjava3.core.Completable
    sendContent(com.google.genai.types.Content content)
    Sends a user content to the model.
    default io.reactivex.rxjava3.core.Completable
    sendContent(com.google.genai.types.Content content, boolean partial)
    Sends user content to the model, optionally leaving the current turn open for more content.
    io.reactivex.rxjava3.core.Completable
    sendHistory(List<com.google.genai.types.Content> history)
    Sends the conversation history to the model.
    io.reactivex.rxjava3.core.Completable
    sendRealtime(com.google.genai.types.Blob blob)
    Sends a chunk of audio or a frame of video to the model in realtime.
  • Method Details

    • sendHistory

      io.reactivex.rxjava3.core.Completable sendHistory(List<com.google.genai.types.Content> history)
      Sends the conversation history to the model.

      You call this method right after setting up the model connection. The model will respond if the last content is from user, otherwise it will wait for new user input before responding.

    • sendContent

      io.reactivex.rxjava3.core.Completable sendContent(com.google.genai.types.Content content)
      Sends a user content to the model.

      The model will respond immediately upon receiving the content. If you send function responses, all parts in the content should be function responses.

    • sendContent

      default io.reactivex.rxjava3.core.Completable sendContent(com.google.genai.types.Content content, boolean partial)
      Sends user content to the model, optionally leaving the current turn open for more content.

      The default implementation ignores partial and calls sendContent(Content). Content made only of function responses is always sent as a 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)
      Sends a chunk of audio or a frame of video to the model in realtime.

      The model may not respond immediately upon receiving the blob. It will do voice activity detection and decide when to respond.

    • receive

      io.reactivex.rxjava3.core.Flowable<LlmResponse> receive()
      Receives the model responses.
    • close

      void close()
      Closes the connection.
    • close

      void close(Throwable throwable)
      Closes the connection with an error.