Package io.jmix.aitools.dataload.impl
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 Summary
FieldsModifier and TypeFieldDescriptionprotected AiToolRegistryprotected @Nullable org.springframework.ai.chat.client.ChatClientprotected ChatClientFactoryprotected EntityDataLoadGenerationServiceprotected JpqlExecutionServiceprotected ResponseLanguageProviderprotected DataLoadChatSystemPromptProvider -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidprotected org.springframework.ai.chat.client.ChatClient.ChatClientRequestSpecbuildChatClientPrompt(String message) protected voidGenerates a JPQL query for the given natural-language request, executes it and returns the structured result (query draft, validation, rows).protected String@Nullable StringSends a stateless message to the data-load chat and blocks until the full reply is produced.reactor.core.publisher.Flux<String> Streams a stateless reply to the data-load chat as a flux of text chunks.protected List<JpqlExecutionParameter> toExecutionParameters(List<GeneratedJpqlParameter> generatedParameters)
-
Field Details
-
chatClientFactory
-
systemPromptProvider
-
aiToolRegistry
-
responseLanguageProvider
-
entityDataLoadGenerationService
-
jpqlExecutionService
-
chatClient
protected @Nullable org.springframework.ai.chat.client.ChatClient chatClient
-
-
Constructor Details
-
AiDataLoadServiceImpl
public AiDataLoadServiceImpl()
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
send
Description copied from interface:AiDataLoadServiceSends a stateless message to the data-load chat and blocks until the full reply is produced. Chat history is not persisted.- Specified by:
sendin interfaceAiDataLoadService- Parameters:
message- user message in natural language- Returns:
- natural-language reply from the LLM
-
stream
Description copied from interface:AiDataLoadServiceStreams a stateless reply to the data-load chat as a flux of text chunks. Chat history is not persisted.- Specified by:
streamin interfaceAiDataLoadService- Parameters:
message- user message in natural language- Returns:
- flux emitting reply chunks in order
-
loadData
Description copied from interface:AiDataLoadServiceGenerates 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:
loadDatain interfaceAiDataLoadService- 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
-
checkChatClient
protected void checkChatClient() -
toExecutionParameters
protected List<JpqlExecutionParameter> toExecutionParameters(List<GeneratedJpqlParameter> generatedParameters)
-