Package dev.langchain4j.service
package dev.langchain4j.service
-
ClassDescriptionAiServices<T>AI Services is a high-level API of LangChain4j to interact with
ChatLanguageModel
andStreamingChatLanguageModel
.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 language model to which you can subscribe and receive updates when a new token is available, when language 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.