Function overrideCompletion

  • Overrides an existing completion schema in the swarm system with a new or partial schema. This function updates the configuration of a completion mechanism identified by its completionName, 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.

    Parameters

    • OptionalcompletionSchema: TCompletionSchema

      The schema containing the completion’s unique name and optional properties to override.

      • completionName

        The unique identifier of the completion to override, matching ICompletionSchema["completionName"].

    Returns ICompletionSchema

    No return value; the override is applied directly to the swarm’s completion schema service.

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

    // Override a completion’s schema with new properties
    overrideCompletion({
    completionName: "TextCompletion",
    model: "gpt-4",
    maxTokens: 500,
    });
    // Logs the operation (if enabled) and updates the completion schema in the swarm.