`ClassInvocationContext.Builder`
java.lang.Object
com.google.adk.agents.InvocationContext.Builder
- Enclosing class:
InvocationContext
“Builder for”是一个用于描述某种构建工具或框架的术语。它通常表示该工具/框架用于帮助开发者或系统管理员快速、高效地创建或构建特定类型的应用程序、系统或组件。例如:“Builder for Web Applications”(用于构建Web应用程序的工具)或“Builder for Cloud Services”(用于构建云服务的工具)。
InvocationContext.-
方法概述
Modifier and TypeMethodDescription用于指定被调用的代理(agent)。artifactService(BaseArtifactService artifactService) 用于设置用于持久化存储工件(artifacts)的服务。设置调用所使用的分支 ID。build()构建(Builds the)InvocationContext`instance.`callbackContextData(Map<String, Object> callbackContextData) 为该调用设置回调函数的上下文数据。contextCacheConfig(@Nullable ContextCacheConfig contextCacheConfig) 为当前代理进程设置上下文缓存配置。endInvocation(boolean endInvocation) 用于确定是否应该结束此次调用。eventsCompactionConfig(@Nullable EventsCompactionConfig eventsCompactionConfig) 为当前代理的运行过程设置事件压缩配置。instantSource(@Nullable InstantSource instantSource) 用于设置调用操作的源代码(即代码的来源位置)。null(默认选项)会自动选择相应的选项。InstantSource.system().invocationId(String invocationId) 为该调用设置唯一的 ID。liveRequestQueue(@Nullable LiveRequestQueue liveRequestQueue) 用于设置用于管理实时请求(live requests)的队列(queue)。memoryService(BaseMemoryService memoryService) 用于设置用于访问代理内存的内存服务。该参数用于指定调用任务所执行的流程节点;当调用任务是通过代理(agent)来执行的时,该参数的值为 `null`。pluginManager(Plugin pluginManager) 用于设置插件管理器,以便访问各种工具和插件。resumabilityConfig(@Nullable ResumabilityConfig resumabilityConfig) 设置调用操作的“可恢复性”(resumability)配置。为当前代理的运行设置配置参数。scheduler(@Nullable io.reactivex.rxjava3.core.Scheduler scheduler) 用于设置调用过程中内部任务分发的调度器;详情请参见……InvocationContext.scheduler().设置与此调用相关的会话(session)。sessionService(BaseSessionService sessionService) 用于设置用于管理会话状态的会话服务。userContent(@Nullable com.google.genai.types.Content userContent) 设置触发了此次调用的用户内容。uuidProvider(@Nullable UuidProvider uuidProvider) 用于设置调用过程中使用的 UUID 生成工具(即 UUID 提供者)。null(默认选项)会自动选择相应的选项。UuidProvider.SYSTEM.
-
方法详细信息(Method Details)
-
sessionService
@CanIgnoreReturnValue public InvocationContext.Builder sessionService(BaseSessionService sessionService) 用于设置用于管理会话状态的会话服务。- Parameters:
sessionService- the session service to use; required.- Returns:
- this builder instance for chaining.
-
artifactService
@CanIgnoreReturnValue public InvocationContext.Builder artifactService(BaseArtifactService artifactService) 用于设置用于持久化存储工件(artifacts)的服务。- Parameters:
artifactService- the artifact service to use; required.- Returns:
- this builder instance for chaining.
-
memoryService
@CanIgnoreReturnValue public InvocationContext.Builder memoryService(BaseMemoryService memoryService) 用于设置用于访问代理内存的内存服务。- Parameters:
memoryService- the memory service to use.- Returns:
- this builder instance for chaining.
-
pluginManager
用于设置插件管理器,以便访问各种工具和插件。- Parameters:
pluginManager- the plugin manager to use.- Returns:
- this builder instance for chaining.
-
liveRequestQueue
@CanIgnoreReturnValue public InvocationContext.Builder liveRequestQueue(@Nullable LiveRequestQueue liveRequestQueue) 用于设置用于管理实时请求(live requests)的队列(queue)。- Parameters:
liveRequestQueue- the queue for managing live requests.- Returns:
- this builder instance for chaining.
-
branch
设置调用所使用的分支 ID。- Parameters:
branch- the branch ID for the invocation.- Returns:
- this builder instance for chaining.
-
invocationId
为该调用设置唯一的 ID。- Parameters:
invocationId- the unique ID for the invocation.- Returns:
- this builder instance for chaining.
-
agent
用于指定被调用的代理(agent)。- Parameters:
agent- the agent being invoked; required.- Returns:
- this builder instance for chaining.
-
node
该参数用于指定调用任务所执行的 workflow 节点;当调用任务通过代理(agent)来执行时,该参数的值为 `null`。当调用任务通过某个具体的 workflow 节点来执行时,相应的代理(agent)也会被激活(即开始运行)。NodeViewAgent该符号代表节点(node)。 -
session
设置与此调用相关的会话(session)。- Parameters:
session- the session associated with this invocation; required.- Returns:
- this builder instance for chaining.
-
userContent
@CanIgnoreReturnValue public InvocationContext.Builder userContent(@Nullable com.google.genai.types.Content userContent) 设置触发了此次调用的用户内容。- Parameters:
userContent- the user content that triggered this invocation.- Returns:
- this builder instance for chaining.
-
runConfig
为当前代理的运行设置配置参数。- Parameters:
runConfig- the configuration for the current agent run.- Returns:
- this builder instance for chaining.
-
endInvocation
用于确定是否应该结束此次调用。- Parameters:
endInvocation- whether this invocation should be ended.- Returns:
- this builder instance for chaining.
-
eventsCompactionConfig
@CanIgnoreReturnValue public InvocationContext.Builder eventsCompactionConfig(@Nullable EventsCompactionConfig eventsCompactionConfig) 为当前代理的运行过程设置事件压缩配置。- Parameters:
eventsCompactionConfig- the events compaction configuration.- Returns:
- this builder instance for chaining.
-
contextCacheConfig
@CanIgnoreReturnValue public InvocationContext.Builder contextCacheConfig(@Nullable ContextCacheConfig contextCacheConfig) 为当前代理进程设置上下文缓存配置。- Parameters:
contextCacheConfig- the context cache configuration.- Returns:
- this builder instance for chaining.
-
resumabilityConfig
@CanIgnoreReturnValue public InvocationContext.Builder resumabilityConfig(@Nullable ResumabilityConfig resumabilityConfig) 设置调用操作的“可恢复性”(resumability)配置。- Parameters:
resumabilityConfig- the resumability configuration.- Returns:
- this builder instance for chaining.
-
scheduler
@CanIgnoreReturnValue public InvocationContext.Builder scheduler(@Nullable io.reactivex.rxjava3.core.Scheduler scheduler) - Parameters:
scheduler- the scheduler, ornullfor the default.- Returns:
- this builder instance for chaining.
-
callbackContextData
@CanIgnoreReturnValue public InvocationContext.Builder callbackContextData(Map<String, Object> callbackContextData) 为该调用设置回调函数的上下文数据。- Parameters:
callbackContextData- the callback context data.- Returns:
- this builder instance for chaining.
-
instantSource
@CanIgnoreReturnValue public InvocationContext.Builder instantSource(@Nullable InstantSource instantSource) 用于设置调用操作的源代码(即代码的来源位置)。null(默认选项)会自动选择相应的选项。InstantSource.system().- Parameters:
instantSource- the source of the current time, ornullfor the default.- Returns:
- this builder instance for chaining.
-
uuidProvider
@CanIgnoreReturnValue public InvocationContext.Builder uuidProvider(@Nullable UuidProvider uuidProvider) 用于设置调用过程中使用的 UUID 生成工具(即 UUID 提供者)。null(默认选项)会自动选择相应的选项。UuidProvider.SYSTEM.- Parameters:
uuidProvider- the provider for new unique identifiers, ornullfor the default.- Returns:
- this builder instance for chaining.
-
build
构建(Builds the)InvocationContext`instance.`- Throws:
IllegalStateException- if any required parameters are missing.
-