Class ToolContext
java.lang.Object
com.google.adk.agents.ReadonlyContext
com.google.adk.agents.Context
com.google.adk.agents.CallbackContext
com.google.adk.tools.ToolContext
`ToolContext` 对象为执行工具或函数提供了结构化的上下文环境。
扩展;延长 CallbackContext (并且通过它……) Context); BaseTool.runAsync(Map, ToolContext)
工具回调(tool callbacks)也接受这种类型的数据。
-
嵌套类概述
Nested ClassesModifier and TypeClassDescriptionstatic final class“Builder for”是一个用于描述某种构建工具或框架的术语。它通常表示该工具/框架用于帮助开发者或系统管理员快速、高效地创建或构建特定类型的应用程序、系统或组件。例如:“Builder for Web Applications”(用于构建Web应用程序的工具)或“Builder for Cloud Services”(用于构建云服务的工具)。ToolContext. -
字段摘要
Fields inherited from class Context
eventActionsFields inherited from class ReadonlyContext
invocationContext -
方法概述
Modifier and TypeMethodDescriptionstatic ToolContext.Builderbuilder(InvocationContext invocationContext) voidsetActions(EventActions actions) toString()Methods inherited from class Context
actions, attemptCount, emit, emit, eventActions, eventAuthor, eventAuthor, eventId, functionCallId, functionCallId, listArtifacts, loadArtifact, loadArtifact, output, requestConfirmation, requestConfirmation, requestConfirmation, requireNodeState, resumeInputs, routes, routes, runNode, runNode, runNode, saveArtifact, searchMemory, state, toolConfirmation, toolConfirmationModifier and TypeMethodDescriptionactions()返回相同的结果。EventActionsasContext.eventActions().final int返回该工作流节点当前所处的尝试次数(从 1 开始计数);每次重试都会使尝试次数增加 1。final void发送event从这个工作流节点的……FunctionNode在之前的调用之后、以及输出结果之前,该内容会被显示在 `body` 部分中。final voidemit(com.google.genai.types.Content message) 发送message作为一个没有输出结果的事件……Context.emit(Event)does.返回EventActions与这个上下文相关联。final String返回此工作流节点所触发事件的作者信息;如果未找到相关作者信息,则返回空字符串(此时可以使用该节点的名称作为默认显示内容)。final voideventAuthor(String eventAuthor) 用于设置此工作流节点所生成的事件的作者信息。eventId()返回与此上下文相关联的事件的 ID;如果不存在此类事件,则返回 null。如果存在的话,该函数会返回调用当前工具的函数调用的 ID。voidfunctionCallId(@Nullable String functionCallId) 设置调用当前工具的函数调用的 ID;如果该 ID 为 `null`,则将其清除。列出当前会话中附加的所有工件的文件名。io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename) 从服务中加载该“工件”(artifact)的最新版本。io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename, int version) 从服务中加载某个特定版本的工件(artifact)。output()返回此工作流节点的输出结果;该输出结果实际上是由该节点内部执行的操作所产生的最终结果。useAsOutput如果该子对象包含某个值,则返回该值;如果该子对象不包含任何值,则返回空字符串(即 “”)。void请求确认当前的函数调用是否成功(即是否已经执行完毕)。voidrequestConfirmation(@Nullable String hint) 请求确认当前的函数调用是否成功(即是否已经执行完毕)。voidrequestConfirmation(@Nullable String hint, @Nullable Object payload) 请求确认当前的函数调用是否成功(即是否已经执行完毕)。final NodeExecutionState返回该工作流节点所处的状态;该节点属于当前上下文(context)所管理的流程。返回用户对该工作流节点或其子节点在之前阶段发出的输入请求以及长时间运行的调用的响应结果;这些响应结果是根据中断 ID 进行分类的。routes()返回此工作流节点所选择的路由;如果没有做出任何路由决策,则返回空值。final void选择该工作流节点的路由(即决定数据应通过哪些路径进行传输),从而取代之前的所有路由设置。final io.reactivex.rxjava3.core.Maybe<Object> 运行node作为这个工作流节点的“子节点”(即没有输入参数的节点),其行为如下:Context.runNode(Node, Object, RunNodeConfig)这与默认设置有关。RunNodeConfig.final io.reactivex.rxjava3.core.Maybe<Object> 运行node作为该工作流节点的“子节点”(即该节点所依赖的另一个节点),Context.runNode(Node, Object, RunNodeConfig)这与默认设置有关。RunNodeConfig.final io.reactivex.rxjava3.core.Maybe<Object> runNode(Node node, @Nullable Object nodeInput, RunNodeConfig config) 返回一个Maybe也就是说,一旦用户订阅了该服务,相关程序就会自动运行。node作为该工作流程的一部分(即作为该流程中的一个节点),该节点会输出该节点自身的处理结果;如果该节点没有任何需要处理的数据或任务,那么它将输出空内容(即没有任何输出)。io.reactivex.rxjava3.core.CompletablesaveArtifact(String filename, com.google.genai.types.Part artifact) 保存一个“工件”(artifact),并将其记录为当前会话的变更数据(即“差异信息”或“delta”)。io.reactivex.rxjava3.core.Single<SearchMemoryResponse> searchMemory(String query) 搜索当前用户的内存数据。state()返回当前上下文的“delta-aware”(即能够感知变化)状态。如果当前工具调用成功(即产生了预期的结果),则返回相应的确认信息。voidtoolConfirmation(@Nullable ToolConfirmation toolConfirmation) 用于设置当前工具调用的确认状态;如果该值为 `null`,则会清除确认状态。Methods inherited from class ReadonlyContext
agentName, branch, events, invocationContext, invocationId, sessionId, userContent, userId
-
方法详细信息(Method Details)
-
setActions
-
builder
-
toBuilder
-
toString
-