Package dev.langchain4j.service
package dev.langchain4j.service
-
ClassDescriptionAiServices<T>AI Services is a high-level API of LangChain4j to interact with
ChatModelandStreamingChatModel.An event emitted by the reactive stream of a non-blocking streaming AI Service — that is, an AI Service method declared to return aFlow.PublisherofAiServiceStreamingEvent.Base class holding theInvocationContextcommon to every event.Signals that a tool has finished executing, carrying its request and result.Signals that a tool is about to be executed.A fully assembled tool call requested by the model (before it is executed).The finalChatResponseof the interaction — the answer.AChatResponseof an intermediate (tool-calling) round — i.e. not the final answer.A chunk of the model's textual response, as it streams.A chunk of the model's thinking/reasoning, as it streams.A chunk of a tool call's arguments, as they stream.A provider-specific raw event, relayed as-is from the model's reactive stream.The content retrieved by RAG for this interaction, emitted once before the first response chunk.Signals that a successfully-executed tool was compensated (rolled back) — for example because another tool in the same round failed.A cold, non-blocking reactive stream for an AI Service method that returns aFlow.PublisherofAiServiceStreamingEvents.Parameters for creating anAiServiceTokenStream.Builder forAiServiceTokenStreamParameters.Utility class responsible for resolving variable names and values for prompt templates by leveraging method parameters and their annotations.The value of a method parameter annotated with @MemoryId will be used to find the memory belonging to that user/conversation.When a method in the AI Service is annotated with @Moderate, each invocation of this method will call not only the LLM, but also the moderation model (which must be provided during the construction of the AI Service) in parallel.Thrown when content moderation fails, i.e., when content is flagged by the moderation model.Result<T>Represents the result of an AI Service invocation.Specifies either a complete system message (prompt) or a system message template to be used each time an AI service is invoked.Represents a token stream from the model to which you can subscribe and receive updates when a new partial response (usually a single token) is available, when the model finishes streaming, or when an error occurs during streaming.Specifies either a complete user message or a user message template to be used each time an AI service is invoked.The value of a method parameter annotated with @UserName will be injected into the field 'name' of a UserMessage.When a parameter of a method in an AI Service is annotated with@V, it becomes a prompt template variable.