Function overrideAdvisor

  • Overrides an existing advisor schema in the swarm system with a new or partial schema. This function updates the configuration of an advisor identified by its advisorName, applying the provided schema properties. It operates outside any existing method or execution contexts to ensure isolation, leveraging beginContext for a clean execution scope. Logs the override operation if logging is enabled in the global configuration. Only the provided properties will be updated - omitted properties remain unchanged.

    Type Parameters

    • T = string

      The type of message content the advisor accepts (defaults to string). Can be a custom object, Blob, or string.

    Parameters

    • advisorSchema: TAdvisorSchema<T>

      Partial schema definition for advisor. Must include advisorName, other properties are optional.

    Returns TAdvisorSchema<T>

    The updated complete advisor schema.

    overrideAdvisor

    If the advisor schema service encounters an error during the override operation (e.g., invalid advisorName or schema).

    // Override advisor's description only
    overrideAdvisor({
    advisorName: "KnowledgeBase",
    docDescription: "Updated knowledge repository",
    });
    // Override advisor with custom message type
    interface CustomMessage { query: string; context: string[] }
    overrideAdvisor<CustomMessage>({
    advisorName: "StructuredAdvisor",
    getChat: async (args) => `Query: ${args.message.query}`
    });