`Class OutputSchema`

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

public final class OutputSchema extends Object implements RequestProcessor
该处理器负责处理使用相关工具的代理程序的输出数据结构(即输出数据格式)。
  • 构造函数详细信息

    • OutputSchema

      public OutputSchema()
  • 方法详细信息(Method Details)

    • processRequest

      public io.reactivex.rxjava3.core.Single<RequestProcessor.RequestProcessingResult> processRequest(InvocationContext context, LlmRequest request)
      描述内容复制自接口文档: RequestProcessor
      将 LLM 请求作为预处理阶段的一部分进行处理。
      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)
      提取已成功验证的数据。 set_model_response 将结果以 JSON 格式返回。

      只有通过了输出模式验证的结果才会被记录在事件操作中。 SetModelResponseTool返回的结果仅包含验证信息(即数据是否满足预设的条件)。发送给模型的验证反馈信息永远不会被纳入最终的、结构化的响应结果中。

      Parameters:
      functionResponseEvent - The function response event to check.
      Returns:
      JSON response string if set_model_response succeeded, Optional.empty() otherwise.
    • createFinalModelResponseEvent

      public static Event createFinalModelResponseEvent(InvocationContext context, String jsonResponse)
      从 `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.