Interface AiServiceInvocationSummaryEvent
- All Superinterfaces:
AiServiceEvent
- All Known Implementing Classes:
DefaultAiServiceInvocationSummaryEvent
A composite event summarizing a single AI Service invocation: all the events fired for it.
It is fired once an invocation is over, right after its AiServiceCompletedEvent, AiServiceErrorEvent
or AiServiceCancelledEvent, and contains every AiServiceEvent fired for that invocation (i.e. every
event sharing its InvocationContext.invocationId()), in the order they were fired, starting with the
AiServiceStartedEvent and ending with the AiServiceCompletedEvent, AiServiceErrorEvent or
AiServiceCancelledEvent.
A few things to keep in mind:
-
Events are only collected for an invocation if an AiServiceInvocationSummaryListener is registered when its
AiServiceStartedEventis fired. -
The event is only fired once the invocation fires its
AiServiceCompletedEvent,AiServiceErrorEventorAiServiceCancelledEvent. AI Services always fire exactly one of them; for an AI Service implementation that does not (for example one built by an integration), the collected events are held until then. -
Events fired for an invocation after it has ended (for example
ToolCompensatedEvents fired once a canceled invocation has been rolled back) are not included. - An AI Service invoked while another AI Service invocation is in progress (for example from within a tool) is a separate invocation with its own invocation id, so it results in its own AiServiceInvocationSummaryEvent.
-
For an AI Service method returning a
TokenStream, the invocation starts when the method is called, but only ends once the stream has been started withTokenStream.start(). Events collected for aTokenStreamthat is never started are never released, so always start the streams you create. Ifstart()fails because of a configuration error (for example a missing error handler), the invocation ends with anAiServiceErrorEvent; callingstart()again once fixed starts a new invocation. -
Each subscription to the reactive stream returned by an AI Service method, and each call of
TokenStream.start(), is a separate invocation with its own invocation id, so it results in its own AiServiceInvocationSummaryEvent, also when several subscriptions run at the same time.
This event is fired by the AiServiceListenerRegistrar itself and cannot be
fired directly.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classBuilder forAiServiceInvocationSummaryEventinstances.Nested classes/interfaces inherited from interface AiServiceEvent
AiServiceEvent.Builder<T> -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a new builder for constructing anAiServiceInvocationSummaryEvent.default Class<AiServiceInvocationSummaryEvent> Retrieves the class type of the event, representing the specific category of the AI Service invocation event.events()Returns all the events fired for this AI Service invocation, in the order they were fired.Creates a new builder instance initialized with the properties of thisAiServiceEvent.Methods inherited from interface AiServiceEvent
invocationContext
-
Method Details
-
events
List<AiServiceEvent> events()Returns all the events fired for this AI Service invocation, in the order they were fired.- Returns:
- An unmodifiable list of the events, in the order they were fired
-
eventClass
Description copied from interface:AiServiceEventRetrieves the class type of the event, representing the specific category of the AI Service invocation event.- Specified by:
eventClassin interfaceAiServiceEvent
-
toBuilder
Description copied from interface:AiServiceEventCreates a new builder instance initialized with the properties of thisAiServiceEvent. This allows modification of the existing properties and reconstruction of the event.- Specified by:
toBuilderin interfaceAiServiceEvent
-
builder
Creates a new builder for constructing anAiServiceInvocationSummaryEvent.- Returns:
- A new builder instance
-