EmbeddingRoleResolver

fun interface EmbeddingRoleResolver

Decides what an embedding role means for a given call.

The embedding counterpart of RoleResolver, with the same ordering rules: application beans first in org.springframework.core.Ordered order, then the platform's own ConfigurableEmbeddingRoleResolver, so configuration is always the last word. The platform takes the first non-null answer, so a resolver can handle the roles it cares about and return null for the rest.

WHY THIS EXISTS AT ALL, given that an embedding service can be a Spring bean and a role could just name one. Because the bean stream is captured once, when the platform is built. A deployment whose provider key arrives after startup has no embedding bean to name at that point and never gets one, so its embedding default is a placeholder for the life of the process - which is the restart that bring-your-own-key removed from chat and left in place for embeddings. A resolver is asked per call, so a key stored a second ago embeds the next document.

Implementations must be thread-safe: one instance serves every call, on any thread.

Inheritors

Functions

Link copied to clipboard