Class OutputSchema

java.lang.Object
com.google.adk.flows.llmflows.OutputSchema
All Implemented Interfaces:
RequestProcessor

public final class OutputSchema extends Object implements RequestProcessor
Processor that handles output schema for agents with tools.
  • Constructor Details

    • OutputSchema

      public OutputSchema()
  • Method Details

    • processRequest

      public io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> processRequest(InvocationContext context, LlmRequest request)
      Description copied from interface: RequestProcessor
      Process the LLM request as part of the pre-processing stage.
      Specified by:
      processRequest in interface RequestProcessor
      Parameters:
      context - the invocation context.
      request - the LLM request to process.
      Returns:
      a list of events generated during processing (if any).
    • getStructuredModelResponse

      public static Optional<String> getStructuredModelResponse(Event functionResponseEvent)
      Check if function response contains set_model_response and extract JSON.
      Parameters:
      functionResponseEvent - The function response event to check.
      Returns:
      JSON response string if set_model_response was called, Optional.empty() otherwise.
    • createFinalModelResponseEvent

      public static Event createFinalModelResponseEvent(InvocationContext context, String jsonResponse)
      Create a final model response event from set_model_response JSON.
      Parameters:
      context - The invocation context.
      jsonResponse - The JSON response from set_model_response tool.
      Returns:
      A new Event that looks like a normal model response.