类:SaveFilesAsArtifactsPlugin

java.lang.Object
com.google.adk.plugins.BasePlugin
com.google.adk.plugins.SaveFilesAsArtifactsPlugin
All Implemented Interfaces:
Plugin

public class SaveFilesAsArtifactsPlugin extends BasePlugin
将用户消息中附带的文件保存为“工件”(artifacts),并用一个占位符来替换这些文件;该占位符会为这些工件指定名称,以便代理程序(agents)日后能够加载这些文件。 LoadArtifactsTool每个文件都会以其原始文件名保存。 display name其中,a user: 前缀(prefix)会在用户的各个会话中保持一致;如果某个文件没有显示名称(display name),则会使用一个自动生成的名称来标识该文件。对于大小超过 20 MB 的文件,系统会用错误提示信息来替代这些文件。该功能实现了与 Python ADK 相同的功能(即对文件进行统一管理和处理)。 SaveFilesAsArtifactsPlugin.
  • 构造函数详细信息

    • SaveFilesAsArtifactsPlugin

      public SaveFilesAsArtifactsPlugin()
    • SaveFilesAsArtifactsPlugin

      public SaveFilesAsArtifactsPlugin(boolean attachFileReference)
    • SaveFilesAsArtifactsPlugin

      public SaveFilesAsArtifactsPlugin(boolean attachFileReference, String name)
      创建该插件。
      Parameters:
      attachFileReference - Whether to also attach a FileData reference to each saved file when the artifact service stores it at a URI the model can read (gs, https or http).
      name - The unique name of the plugin instance.
  • 方法详细信息(Method Details)

    • onUserMessageCallback

      public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> onUserMessageCallback(InvocationContext invocationContext, com.google.genai.types.Content userMessage)
      描述内容复制自接口文档: Plugin
      当在调用开始之前接收到用户消息时,会执行此回调函数。
      Parameters:
      invocationContext - The context for the entire invocation.
      userMessage - The message content input by user.
      Returns:
      An optional Content to replace the user message. Returning Empty to proceed normally.
    • beforeAgentCallback

      public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> beforeAgentCallback(BaseAgent agent, CallbackContext callbackContext)
      该功能用于报告从用户消息中保存的版本信息;这些版本信息是在第一个代理程序开始运行时被记录下来的。需要注意的是:插件无法直接为用户自己的事件添加额外的操作(即无法修改用户事件的处理流程)。
      Parameters:
      agent - The agent that is about to run.
      callbackContext - The context for the agent invocation.
      Returns:
      An optional Content object to bypass the agent's execution. Returning Empty to proceed normally.