Class DefaultJpqlRepairer
java.lang.Object
io.jmix.aitools.dataload.repair.impl.DefaultJpqlRepairer
- All Implemented Interfaces:
JpqlRepairer,org.springframework.beans.factory.InitializingBean
public class DefaultJpqlRepairer
extends Object
implements JpqlRepairer, org.springframework.beans.factory.InitializingBean
Default
JpqlRepairer that re-prompts the LLM with the previous query and its validation
issues, then parses the corrected JPQL from the model's JSON reply.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChatClientFactoryprotected JpqlRepairerPromptProviderprotected tools.jackson.databind.ObjectMapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInitializes the JSON object mapper after the bean is created.protected tools.jackson.databind.ObjectMapperprotected @Nullable GeneratedJpqlResultexecutePrompt(JpqlRepairRequest request) Re-prompts the model with the previous query and its validation issues and parses the corrected query from the reply.protected StringformatRepairGuidance(List<JpqlValidationIssue> issues) protected Stringprotected GeneratedJpqlResultprotected String@Nullable GeneratedJpqlResultrepair(JpqlRepairRequest request) Attempts to repair the invalid query described by the request.protected @Nullable GeneratedJpqlParameterMaps a parameter payload to aGeneratedJpqlParameter, or returnsnullto skip it when the model provided no parameter name (such a parameter cannot be bound).protected String
-
Field Details
-
jpqlRepairerPromptProvider
-
chatClientFactory
-
objectMapper
protected tools.jackson.databind.ObjectMapper objectMapper
-
-
Constructor Details
-
DefaultJpqlRepairer
public DefaultJpqlRepairer()
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()Initializes the JSON object mapper after the bean is created.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
repair
Description copied from interface:JpqlRepairerAttempts to repair the invalid query described by the request.- Specified by:
repairin interfaceJpqlRepairer- Parameters:
request- repair request with the current query- Returns:
- query draft, or
nullif no repaired result could be produced
-
formatValidationIssues
-
formatRepairGuidance
-
executePrompt
Re-prompts the model with the previous query and its validation issues and parses the corrected query from the reply.Returns
nullwhen the reply yields no query draft (empty, or no parseable JSON object). The caller then keeps the original validation issues instead of failing with a technical error, and the raw reply is logged.- Parameters:
request- repair request with the previous query and its validation issues- Returns:
- repaired query draft, or
nullif the reply could not be parsed
-
readPromptTemplate
-
mapToGeneratedJpqlResult
-
toGeneratedJpqlParameter
protected @Nullable GeneratedJpqlParameter toGeneratedJpqlParameter(GeneratedJpqlParameterPayload payload) Maps a parameter payload to aGeneratedJpqlParameter, or returnsnullto skip it when the model provided no parameter name (such a parameter cannot be bound).- Parameters:
payload- raw parameter payload from the model- Returns:
- mapped parameter, or
nullif it has no usable name
-
createObjectMapper
protected tools.jackson.databind.ObjectMapper createObjectMapper() -
toJson
-