Package dev.langchain4j.service.spring
Annotation Interface AiService
An interface annotated with
@AiService will be automatically registered as a bean
and wired with all the following components (beans) available in the context:
-You can also explicitly specify which components (beans) should be wired into this AI Service by settingChatModel-StreamingChatModel-ChatMemory-ChatMemoryProvider-ContentRetriever-RetrievalAugmentor- All beans containing methods annotated with@Tool
wiringMode() to AiServiceWiringMode.EXPLICIT
and specifying bean names using the following attributes:
-See more information about AI Services here and in the Javadoc ofchatModel()-streamingChatModel()-chatMemory()-chatMemoryProvider()-contentRetriever()-retrievalAugmentor()
AiServices.- See Also:
-
AiServices
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionWhen thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aChatMemorybean that should be used by this AI Service.When thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aChatMemoryProviderbean that should be used by this AI Service.When thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aChatModelbean that should be used by this AI Service.When thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aContentRetrieverbean that should be used by this AI Service.When thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aModerationModelbean that should be used by this AI Service.When thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aRetrievalAugmentorbean that should be used by this AI Service.When thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aStreamingChatModelbean that should be used by this AI Service.String[]When thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the names of beans containing methods annotated withToolthat should be used by this AI Service.Specifies how LangChain4j components (beans) are wired (injected) into this AI Service.
-
Element Details
-
wiringMode
AiServiceWiringMode wiringModeSpecifies how LangChain4j components (beans) are wired (injected) into this AI Service.- Default:
- AUTOMATIC
-
chatModel
String chatModelWhen thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aChatModelbean that should be used by this AI Service.- Default:
- ""
-
streamingChatModel
String streamingChatModelWhen thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aStreamingChatModelbean that should be used by this AI Service.- Default:
- ""
-
chatMemory
String chatMemoryWhen thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aChatMemorybean that should be used by this AI Service.- Default:
- ""
-
chatMemoryProvider
String chatMemoryProviderWhen thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aChatMemoryProviderbean that should be used by this AI Service.- Default:
- ""
-
contentRetriever
String contentRetrieverWhen thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aContentRetrieverbean that should be used by this AI Service.- Default:
- ""
-
retrievalAugmentor
String retrievalAugmentorWhen thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aRetrievalAugmentorbean that should be used by this AI Service.- Default:
- ""
-
moderationModel
String moderationModelWhen thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the name of aModerationModelbean that should be used by this AI Service.- Default:
- ""
-
tools
String[] toolsWhen thewiringMode()is set toAiServiceWiringMode.EXPLICIT, this attribute specifies the names of beans containing methods annotated withToolthat should be used by this AI Service.- Default:
- {}
-