类:GlobalInstructionPlugin

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

public class GlobalInstructionPlugin extends BasePlugin
该插件在应用程序(App)层面提供了全局指令功能。

全局指令适用于应用程序中的所有代理(agent),为设置适用于整个应用程序的指令、标识符或“特性”提供了一种统一的方式。这些全局指令可以以静态字符串的形式提供,也可以作为函数的形式提供;后者会根据特定条件来解析并执行相应的指令。 CallbackContext.

该插件通过 `before_model_callback` 函数来发挥作用,从而能够在 LLM(大型语言模型)的请求被发送到模型之前对其进行修改。具体来说,它会将一条全局指令添加到代理提供的任何现有系统指令之前。

  • 构造函数详细信息

    • GlobalInstructionPlugin

      public GlobalInstructionPlugin(String globalInstruction)
    • GlobalInstructionPlugin

      public GlobalInstructionPlugin(String globalInstruction, String name)
    • GlobalInstructionPlugin

      public GlobalInstructionPlugin(Function<CallbackContext, io.reactivex.rxjava3.core.Maybe<String>> instructionProvider)
    • GlobalInstructionPlugin

      public GlobalInstructionPlugin(Function<CallbackContext, io.reactivex.rxjava3.core.Maybe<String>> instructionProvider, String name)
  • 方法详细信息(Method Details)

    • beforeModelCallback

      public io.reactivex.rxjava3.core.Maybe<LlmResponse> beforeModelCallback(CallbackContext callbackContext, LlmRequest.Builder llmRequest)
      描述内容复制自接口文档: Plugin
      在请求被发送到模型之前,会先执行这个回调函数。
      Parameters:
      callbackContext - The context for the current agent call.
      llmRequest - The mutable request builder, allowing modification of the request before it is sent to the model.
      Returns:
      An optional LlmResponse to trigger an early exit. Returning Empty to proceed normally.