Function overrideEmbeding

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

    • embeddingSchema: TEmbeddingSchema

      The schema definition for embedding.

    Returns IEmbeddingSchema

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

    // Override an embedding’s schema with new properties
    overrideEmbeding({
    embeddingName: "TextEmbedding",
    persist: true,
    callbacks: {
    onCreate: (text, embeddings) => console.log(`Created embedding for ${text}`),
    },
    });
    // Logs the operation (if enabled) and updates the embedding schema in the swarm.