Class BaseLlmFlow
java.lang.Object
com.google.adk.flows.llmflows.BaseLlmFlow
- All Implemented Interfaces:
BaseFlow
- Direct Known Subclasses:
SingleFlow
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final int
protected final List
<RequestProcessor> protected final List
<ResponseProcessor> protected int
-
Constructor Summary
ConstructorsConstructorDescriptionBaseLlmFlow
(List<RequestProcessor> requestProcessors, List<ResponseProcessor> responseProcessors) BaseLlmFlow
(List<RequestProcessor> requestProcessors, List<ResponseProcessor> responseProcessors, Optional<Integer> maxSteps) -
Method Summary
Modifier and TypeMethodDescriptionprotected io.reactivex.rxjava3.core.Single
<ResponseProcessor.ResponseProcessingResult> postprocess
(InvocationContext context, Event baseEventForLlmResponse, LlmRequest llmRequest, LlmResponse llmResponse) Post-processes the LLM response after receiving it from the LLM.protected io.reactivex.rxjava3.core.Single
<RequestProcessor.RequestProcessingResult> preprocess
(InvocationContext context, LlmRequest llmRequest) Pre-processes the LLM request before sending it to the LLM.io.reactivex.rxjava3.core.Flowable
<Event> run
(InvocationContext invocationContext) Executes the full LLM flow by repeatedly callingrunOneStep(com.google.adk.agents.InvocationContext)
until a final response is produced.io.reactivex.rxjava3.core.Flowable
<Event> runLive
(InvocationContext invocationContext) Executes the LLM flow in streaming mode.
-
Field Details
-
requestProcessors
-
responseProcessors
-
stepsCompleted
protected int stepsCompleted -
maxSteps
protected final int maxSteps
-
-
Constructor Details
-
BaseLlmFlow
public BaseLlmFlow(List<RequestProcessor> requestProcessors, List<ResponseProcessor> responseProcessors) -
BaseLlmFlow
public BaseLlmFlow(List<RequestProcessor> requestProcessors, List<ResponseProcessor> responseProcessors, Optional<Integer> maxSteps)
-
-
Method Details
-
preprocess
protected io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> preprocess(InvocationContext context, LlmRequest llmRequest) Pre-processes the LLM request before sending it to the LLM. Executes all registeredRequestProcessor
. -
postprocess
protected io.reactivex.rxjava3.core.Single<ResponseProcessor.ResponseProcessingResult> postprocess(InvocationContext context, Event baseEventForLlmResponse, LlmRequest llmRequest, LlmResponse llmResponse) Post-processes the LLM response after receiving it from the LLM. Executes all registeredResponseProcessor
instances. Handles function calls if present in the response. -
run
Executes the full LLM flow by repeatedly callingrunOneStep(com.google.adk.agents.InvocationContext)
until a final response is produced. -
runLive
Executes the LLM flow in streaming mode.Handles sending history and live requests to the LLM, receiving responses, processing them, and managing agent transfers.
-