Class BaseLlmFlow

java.lang.Object
com.google.adk.flows.llmflows.BaseLlmFlow
All Implemented Interfaces:
BaseFlow
Direct Known Subclasses:
SingleFlow

public abstract class BaseLlmFlow extends Object implements BaseFlow
A basic flow that calls the LLM in a loop until a final response is generated.
  • Field Details

  • Constructor Details

  • Method Details

    • preprocess

      protected io.reactivex.rxjava3.core.Flowable<Event> preprocess(InvocationContext context, AtomicReference<LlmRequest> llmRequestRef)
      Pre-processes the LLM request before sending it to the LLM. Executes all registered RequestProcessor transforming the provided llmRequestRef in-place, and emits the events generated by them.
    • postprocess

      protected io.reactivex.rxjava3.core.Flowable<Event> postprocess(InvocationContext context, Event baseEventForLlmResponse, LlmRequest llmRequest, LlmResponse llmResponse)
      Post-processes the LLM response after receiving it from the LLM. Executes all registered ResponseProcessor instances. Emits events for the model response and any subsequent function calls.
    • run

      public io.reactivex.rxjava3.core.Flowable<Event> run(InvocationContext invocationContext)
      Executes the full LLM flow by repeatedly calling runOneStep(InvocationContext) until a final response is produced.
      Specified by:
      run in interface BaseFlow
      Returns:
      A Flowable of all Events generated during the flow.
    • runLive

      public io.reactivex.rxjava3.core.Flowable<Event> runLive(InvocationContext invocationContext)
      Executes the LLM flow in streaming mode.

      Handles sending history and live requests to the LLM, receiving responses, processing them, and managing agent transfers.

      Specified by:
      runLive in interface BaseFlow
      Returns:
      A Flowable of Events streamed in real-time.