Package io.jmix.aitools.service.impl
Class AiAssistantServiceImpl
java.lang.Object
io.jmix.aitools.service.impl.AiAssistantServiceImpl
- All Implemented Interfaces:
AiAssistantService,org.springframework.beans.factory.InitializingBean
@Component("aitls_AiAssistantServiceImpl")
public class AiAssistantServiceImpl
extends Object
implements AiAssistantService, org.springframework.beans.factory.InitializingBean
Default
AiAssistantService based on the application's chat model.
Builds a chat client with the default system prompt and all registered tools on startup.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AiToolRegistryprotected @Nullable org.springframework.ai.chat.client.ChatClientprotected ChatClientFactoryprotected ResponseLanguageProviderprotected AiAssistantSystemPromptProvider -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidBuilds the chat client after the bean is created.protected org.springframework.ai.chat.client.ChatClient.ChatClientRequestSpecbuildPrompt(String message) protected voidprotected String@Nullable StringSends a message to the chat model and blocks until the full reply is produced.reactor.core.publisher.Flux<String> Streams the chat model's reply as a flux of text chunks.
-
Field Details
-
chatClientFactory
-
aiToolRegistry
-
systemPromptProvider
-
responseLanguageProvider
-
chatClient
protected @Nullable org.springframework.ai.chat.client.ChatClient chatClient
-
-
Constructor Details
-
AiAssistantServiceImpl
public AiAssistantServiceImpl()
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()Builds the chat client after the bean is created.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
send
Description copied from interface:AiAssistantServiceSends a message to the chat model and blocks until the full reply is produced.- Specified by:
sendin interfaceAiAssistantService- Parameters:
message- user message- Returns:
- full reply text
-
stream
Description copied from interface:AiAssistantServiceStreams the chat model's reply as a flux of text chunks.- Specified by:
streamin interfaceAiAssistantService- Parameters:
message- user message- Returns:
- flux emitting reply chunks in order
-
buildPrompt
protected org.springframework.ai.chat.client.ChatClient.ChatClientRequestSpec buildPrompt(String message) -
resolveResponseLanguage
-
checkChatClient
protected void checkChatClient()
-