Interface EmbeddingModelListener
EmbeddingModel listener that listens for requests, responses and errors.
Threading — these callbacks must not block. They are always invoked synchronously, on the model's own
threads: on the synchronous API (embed) the caller's thread; on the asynchronous API (embedAsync),
onRequest(EmbeddingModelRequestContext) runs on the thread that starts the call and onResponse(EmbeddingModelResponseContext)/onError(EmbeddingModelErrorContext) on the
transport's I/O worker thread that reads the response (for HTTP models, the JDK HTTP client's HttpClient-*
workers). Blocking in a callback — a synchronous database write, a synchronous HTTP call to an observability
backend, synchronous file logging — stalls that worker and, under concurrency, degrades throughput for all
in-flight calls. Keep these methods non-blocking; if a callback must perform blocking I/O, offload it to your own
executor.
- Since:
- 1.11.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidonError(EmbeddingModelErrorContext errorContext) This method is called when an error occurs during interaction with the embedding model.default voidonRequest(EmbeddingModelRequestContext requestContext) This method is called before the request is executed against the embedding model.default voidonResponse(EmbeddingModelResponseContext responseContext) This method is called after a successful embedding operation completes.
-
Method Details
-
onRequest
This method is called before the request is executed against the embedding model.- Parameters:
requestContext- The request context. It contains the input and attributes. The attributes can be used to pass data between methods of this listener or between multiple listeners.
-
onResponse
This method is called after a successful embedding operation completes.- Parameters:
responseContext- The response context. It contains the response, corresponding request and attributes. The attributes can be used to pass data between methods of this listener or between multiple listeners.
-
onError
This method is called when an error occurs during interaction with the embedding model.- Parameters:
errorContext- The error context. It contains the error, corresponding request and attributes. The attributes can be used to pass data between methods of this listener or between multiple listeners.
-