EmbeddingTrackingConfiguration

Spring configuration that automatically wraps every EmbeddingService bean in EmbeddingOperations so that embedding usage is tracked and priced against the current com.embabel.agent.core.AgentProcess.

The wrapping happens via a BeanPostProcessor, which intercepts both statically declared @Bean methods and dynamically registered singletons (used by the model autoconfigure modules — see e.g. OpenAiModelsConfig).

Wrapping is idempotent: an already-wrapped EmbeddingOperations is returned as is.

Every EmbeddingEventListener bean in the context is aggregated and injected into each wrapped EmbeddingOperations. This is the channel through which standalone (non-agent) callers receive embedding events.

If no TokenCountEstimator is present in the context, the heuristic (~ 4 chars per token) is used as a fallback.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun embeddingTrackingBeanPostProcessor(tokenCountEstimatorProvider: <Error class: unknown class><<Error class: unknown class><String>>, embeddingEventListenersProvider: <Error class: unknown class><EmbeddingEventListener>): <Error class: unknown class>