Class LlmRequest

java.lang.Object
com.google.adk.JsonBaseModel
com.google.adk.models.LlmRequest

public abstract class LlmRequest extends JsonBaseModel
表示一个要发送给大型语言模型(LLM)的请求。
  • 构造函数详细信息

    • LlmRequest

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

    • model

      public abstract Optional<String> model()
      返回要使用的 LLM(大型语言模型)的名称。如果未设置该名称,则会使用 LLM 类的默认模型。
      Returns:
      An optional string representing the model name.
    • contents

      public abstract List<com.google.genai.types.Content> contents()
      返回发送给大型语言模型(LLM)的所有内容的列表。
      Returns:
      A list of Content objects.
    • config

      public abstract Optional<com.google.genai.types.GenerateContentConfig> config()
      返回用于内容生成的配置信息。
      Returns:
      An optional GenerateContentConfig object containing the generation settings.
    • liveConnectConfig

      public abstract com.google.genai.types.LiveConnectConfig liveConnectConfig()
      返回用于实时连接的配置信息。这些配置信息是根据 `InvocationContext` 中的 `RunConfig` 对象进行填充的。
      Returns:
      An optional LiveConnectConfig object containing the live connection settings.
    • tools

      public abstract Map<String,BaseTool> tools()
      返回一个映射(map),其中包含了大型语言模型(LLM)可使用的各种工具。
      Returns:
      A map where keys are tool names and values are BaseTool instances.
    • cacheConfig

      public abstract Optional<ContextCacheConfig> cacheConfig()
      此请求的上下文缓存配置;当上下文缓存功能被禁用时,该配置为空。
    • cacheMetadata

      public abstract Optional<CacheMetadata> cacheMetadata()
      从代理的最新响应中获取缓存状态,用于重用或刷新缓存。
    • cacheableContentsTokenCount

      public abstract Optional<Integer> cacheableContentsTokenCount()
      代理上次请求中生成的提示令牌(prompt token)的数量,用于决定是否需要缓存该请求的结果。
    • getFirstSystemInstruction

      public Optional<String> getFirstSystemInstruction()
      如果请求中包含系统指令信息,该方法会返回该系统指令的文本(即第一条系统指令的描述或内容)。
    • getSystemInstructions

      public com.google.common.collect.ImmutableList<String> getSystemInstructions()
      从请求中返回所有系统指令的文本,并将这些文本存储在一个不可变的列表中。
    • builder

      public static LlmRequest.Builder builder()
    • toBuilder

      public abstract LlmRequest.Builder toBuilder()