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

    • requestProcessors

      protected final List<com.google.adk.flows.llmflows.RequestProcessor> requestProcessors
    • responseProcessors

      protected final List<com.google.adk.flows.llmflows.ResponseProcessor> responseProcessors
  • Constructor Details

    • BaseLlmFlow

      public BaseLlmFlow(List<com.google.adk.flows.llmflows.RequestProcessor> requestProcessors, List<com.google.adk.flows.llmflows.ResponseProcessor> responseProcessors)
  • Method Details

    • preprocess

      protected com.google.adk.flows.llmflows.RequestProcessor.RequestProcessingResult preprocess(InvocationContext context, LlmRequest llmRequest)
      Pre-processes the LLM request before sending it to the LLM. Executes all registered RequestProcessor.
    • postprocess

      protected io.reactivex.rxjava3.core.Single<com.google.adk.flows.llmflows.ResponseProcessor.ResponseProcessingResult> 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. Handles function calls if present in the response.
    • run

      public io.reactivex.rxjava3.core.Flowable<Event> run(InvocationContext invocationContext)
      Description copied from interface: BaseFlow
      Run this flow.

      To implement this method, the flow should follow the below requirements:

      1. 1. `session` should be treated as immutable, DO NOT change it.
      2. 2. The caller who trigger the flow is responsible for updating the session as the events being generated. The subclass implementation will assume session is updated after each yield event statement.
      3. 3. A flow may spawn sub-agent flows depending on the agent definition.
      Specified by:
      run in interface BaseFlow
    • runLive

      public io.reactivex.rxjava3.core.Flowable<Event> runLive(InvocationContext invocationContext)
      Specified by:
      runLive in interface BaseFlow