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 Details

    • chatClientFactory

      @Autowired protected ChatClientFactory chatClientFactory
    • aiToolRegistry

      @Autowired protected AiToolRegistry aiToolRegistry
    • systemPromptProvider

      @Autowired protected AiAssistantSystemPromptProvider systemPromptProvider
    • responseLanguageProvider

      @Autowired protected ResponseLanguageProvider 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:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • send

      public @Nullable String send(String message)
      Description copied from interface: AiAssistantService
      Sends a message to the chat model and blocks until the full reply is produced.
      Specified by:
      send in interface AiAssistantService
      Parameters:
      message - user message
      Returns:
      full reply text
    • stream

      public reactor.core.publisher.Flux<String> stream(String message)
      Description copied from interface: AiAssistantService
      Streams the chat model's reply as a flux of text chunks.
      Specified by:
      stream in interface AiAssistantService
      Parameters:
      message - user message
      Returns:
      flux emitting reply chunks in order
    • buildPrompt

      protected org.springframework.ai.chat.client.ChatClient.ChatClientRequestSpec buildPrompt(String message)
    • resolveResponseLanguage

      protected String resolveResponseLanguage()
    • checkChatClient

      protected void checkChatClient()