Package io.quarkiverse.langchain4j
Annotation Interface RegisterAiService
Used to create Langchain4j's
AiServices
in a declarative manner that the application can then use simply by
using the class as a CDI bean.
Under the hood Langchain4j's AiServices.builder(Class)
is called
while also providing the builder with the proper ChatLanguageModel
, tools
beans,
ChatMemory
or ChatMemoryProvider
, ModerationModel
and Retriever
.
NOTE: The resulting CDI bean is ApplicationScoped
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Marker that is used to tell Quarkus to use theChatLanguageModel
that has been configured as a CDI bean by any of the extensions providing such capability (such asquarkus-langchain4j-openai
andquarkus-langchain4j-hugging-face
).static final class
Marker that is used to tell Quarkus to use the retriever that the user has configured as a CDI beanstatic final class
Marker that is used to tell Quarkus to use the retriever that the user has configured as a CDI beanstatic final class
Marker class to indicate that no chat memory should be usedstatic final class
Marker class to indicate that no retriever should be used -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionConfigures the way to obtain theChatLanguageModel
to use.Configures the way to obtain theChatMemoryProvider
to use.Class<? extends Supplier<dev.langchain4j.retriever.Retriever<dev.langchain4j.data.segment.TextSegment>>>
Configures the way to obtain theRetriever
to use (when using RAG).Class<?>[]
Tool classes to use.
-
Element Details
-
chatLanguageModelSupplier
Configures the way to obtain theChatLanguageModel
to use. If not configured, the default CDI bean implementing the model is looked up. Such a bean provided automatically by extensions suchquarkus-langchain4j-openai
andquarkus-langchain4j-hugging-face
- Default:
- io.quarkiverse.langchain4j.RegisterAiService.BeanChatLanguageModelSupplier.class
-
tools
Class<?>[] toolsTool classes to use. All tools are expected to be CDI beans.NOTE: when this is used,
chatMemoryProviderSupplier
must NOT be set toRegisterAiService.NoChatMemoryProviderSupplier
.- Default:
- {}
-
chatMemoryProviderSupplier
Class<? extends Supplier<dev.langchain4j.memory.chat.ChatMemoryProvider>> chatMemoryProviderSupplierConfigures the way to obtain theChatMemoryProvider
to use. By default, Quarkus will look for a CDI bean that implementsChatMemoryProvider
. If an arbitraryChatMemoryProvider
instance is needed, a custom implementation ofSupplier<dev.langchain4j.memory.chat.ChatMemoryProvider>
needs to be provided.If the memory provider to use is exposed as a CDI bean exposing the type
ChatMemoryProvider
, then set the value toRegisterAiService.BeanChatMemoryProviderSupplier
- Default:
- io.quarkiverse.langchain4j.RegisterAiService.NoChatMemoryProviderSupplier.class
-
retrieverSupplier
Class<? extends Supplier<dev.langchain4j.retriever.Retriever<dev.langchain4j.data.segment.TextSegment>>> retrieverSupplierConfigures the way to obtain theRetriever
to use (when using RAG). By default, no chat memory is used. If a CDI bean of typeChatMemory
is needed, the value should beRegisterAiService.BeanRetrieverSupplier
. If an arbitraryChatMemory
instance is needed, a custom implementation ofSupplier<dev.langchain4j.memory.ChatMemory>
needs to be provided.- Default:
- io.quarkiverse.langchain4j.RegisterAiService.NoRetrieverSupplier.class
-