Class AiDataLoadServiceImpl

java.lang.Object
io.jmix.aitools.dataload.impl.AiDataLoadServiceImpl
All Implemented Interfaces:
AiDataLoadService, org.springframework.beans.factory.InitializingBean

@Component("aitls_AiDataLoadServiceImpl") public class AiDataLoadServiceImpl extends Object implements AiDataLoadService, org.springframework.beans.factory.InitializingBean
The default implementation of AiDataLoadService.

It uses DataLoadAiTool tools (entity discovery, JPQL execution, etc.) to get a valid JPQL query from LLM. This JPQL is validated and can be repaired if it is required.

See Also:
  • Field Details

  • Constructor Details

    • AiDataLoadServiceImpl

      public AiDataLoadServiceImpl()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • send

      public @Nullable String send(String message)
      Description copied from interface: AiDataLoadService
      Sends a stateless message to the data-load chat and blocks until the full reply is produced. Chat history is not persisted.
      Specified by:
      send in interface AiDataLoadService
      Parameters:
      message - user message in natural language
      Returns:
      natural-language reply from the LLM
    • stream

      public reactor.core.publisher.Flux<String> stream(String message)
      Description copied from interface: AiDataLoadService
      Streams a stateless reply to the data-load chat as a flux of text chunks. Chat history is not persisted.
      Specified by:
      stream in interface AiDataLoadService
      Parameters:
      message - user message in natural language
      Returns:
      flux emitting reply chunks in order
    • loadData

      public EntityDataLoadResult loadData(String userText)
      Description copied from interface: AiDataLoadService
      Generates a JPQL query for the given natural-language request, executes it and returns the structured result (query draft, validation, rows). Runs statelessly without persisting chat history.
      Specified by:
      loadData in interface AiDataLoadService
      Parameters:
      userText - user request in natural language
      Returns:
      result containing the generated query, its validation and the fetched rows
    • buildChatClientPrompt

      protected org.springframework.ai.chat.client.ChatClient.ChatClientRequestSpec buildChatClientPrompt(String message)
    • buildChatClient

      protected void buildChatClient()
    • resolveResponseLanguage

      protected String resolveResponseLanguage()
    • checkChatClient

      protected void checkChatClient()
    • toExecutionParameters

      protected List<JpqlExecutionParameter> toExecutionParameters(List<GeneratedJpqlParameter> generatedParameters)