Class LibrarySupportLogic
java.lang.Object
sk.iway.iwcm.components.ai.providers.LibrarySupportLogic
- All Implemented Interfaces:
AiInterface
- Direct Known Subclasses:
GeminiService,LocalEmbeddingService,LocalTextService,LocalTranslateService,OpenAiService,OpenRouterService
CMS adapter around the framework-neutral
webjet-ai client.
CMS-side provider integrations should extend this class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceResolves immutable options for the private literal-translation request pipeline. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLibrarySupportLogic(com.webjetcms.ai.AiClient aiClient, WebjetAiConfigurationService configurationService) protectedLibrarySupportLogic(com.webjetcms.ai.AiClient aiClient, WebjetAiConfigurationService configurationService, LibrarySupportLogic.LiteralTranslationOptionsResolver literalTranslationOptionsResolver) Creates a CMS provider adapter with optional literal-translation support. -
Method Summary
Modifier and TypeMethodDescriptionprotected final WebjetAiConfigurationServicegetAiImageResponse(AssistantDefinitionEntity assistant, InputDataDTO inputData, Prop prop, AiStatRepository statRepo, jakarta.servlet.http.HttpServletRequest request) Executes an image generation or editing request and stores returned images in temporary storage.getAiResponse(AssistantDefinitionEntity assistant, InputDataDTO inputData, Prop prop, AiStatRepository statRepo, jakarta.servlet.http.HttpServletRequest request) Executes a text request, restores protected INCLUDE commands, and records usage and audit data.getAiStreamResponse(AssistantDefinitionEntity assistant, InputDataDTO inputData, Prop prop, AiStatRepository statRepo, BufferedWriter writer, jakarta.servlet.http.HttpServletRequest request) Streams a text request while restoring protected INCLUDE commands and records usage and audit data.getBonusHtml(AssistantDefinitionEntity assistant, Prop prop) Builds provider-supported image option controls for the assistant UI.getSupportedModels(Prop prop, jakarta.servlet.http.HttpServletRequest request) Lists models available from the configured provider for the current request.booleanisInit()protected voidvalidatePromptExpansion(com.webjetcms.ai.AiPromptTemplate.ExpansionResult expansion, Long assistantId) Validates content expanded into trusted prompt instructions before a request is built.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface sk.iway.iwcm.components.ai.providers.AiInterface
configure, getApiKey, getImageNameModel, getProviderId, getTitleKey
-
Constructor Details
-
LibrarySupportLogic
protected LibrarySupportLogic(com.webjetcms.ai.AiClient aiClient, WebjetAiConfigurationService configurationService) -
LibrarySupportLogic
protected LibrarySupportLogic(com.webjetcms.ai.AiClient aiClient, WebjetAiConfigurationService configurationService, LibrarySupportLogic.LiteralTranslationOptionsResolver literalTranslationOptionsResolver) Creates a CMS provider adapter with optional literal-translation support. The resolver may supply translation options only. Request construction and all security invariants remain owned by this class.- Parameters:
aiClient- client used to execute provider requestsconfigurationService- service used to resolve provider configurationliteralTranslationOptionsResolver- resolver for literal translation options, ornullfor the standard protected-prompt request pipeline
-
-
Method Details
-
isInit
public boolean isInit()- Specified by:
isInitin interfaceAiInterface
-
getSupportedModels
public List<LabelValue> getSupportedModels(Prop prop, jakarta.servlet.http.HttpServletRequest request) Lists models available from the configured provider for the current request. Provider failures are recorded in the audit log and produce an empty result.- Specified by:
getSupportedModelsin interfaceAiInterface- Parameters:
prop- translations used to format provider errorsrequest- request used to resolve provider configuration- Returns:
- provider models represented as label-value options
-
getAiResponse
public AssistantResponseDTO getAiResponse(AssistantDefinitionEntity assistant, InputDataDTO inputData, Prop prop, AiStatRepository statRepo, jakarta.servlet.http.HttpServletRequest request) throws ProviderCallException Executes a text request, restores protected INCLUDE commands, and records usage and audit data.- Specified by:
getAiResponsein interfaceAiInterface- Parameters:
assistant- assistant configuration used for the requestinputData- input text, user prompt, and related request dataprop- translations used to format provider errorsstatRepo- repository used to record token statisticsrequest- request used to resolve provider configuration and statistics context- Returns:
- response DTO containing the generated text and token usage
- Throws:
ProviderCallException- if request preparation, provider execution, or response processing fails
-
getAiStreamResponse
public AssistantResponseDTO getAiStreamResponse(AssistantDefinitionEntity assistant, InputDataDTO inputData, Prop prop, AiStatRepository statRepo, BufferedWriter writer, jakarta.servlet.http.HttpServletRequest request) throws ProviderCallException Streams a text request while restoring protected INCLUDE commands and records usage and audit data.- Specified by:
getAiStreamResponsein interfaceAiInterface- Parameters:
assistant- assistant configuration used for the requestinputData- input text, user prompt, and related request dataprop- translations used to format provider errorsstatRepo- repository used to record token statisticswriter- destination for streamed response contentrequest- request used to resolve provider configuration and statistics context- Returns:
- response DTO containing the complete streamed text and token usage
- Throws:
ProviderCallException- if request preparation, provider execution, streaming, or response processing fails
-
getAiImageResponse
public AssistantResponseDTO getAiImageResponse(AssistantDefinitionEntity assistant, InputDataDTO inputData, Prop prop, AiStatRepository statRepo, jakarta.servlet.http.HttpServletRequest request) throws ProviderCallException Executes an image generation or editing request and stores returned images in temporary storage.- Specified by:
getAiImageResponsein interfaceAiInterface- Parameters:
assistant- assistant configuration used for the requestinputData- image prompt, source image, and requested image optionsprop- translations used to format provider errorsstatRepo- repository used to record token statisticsrequest- request used to resolve provider configuration and statistics context- Returns:
- response DTO containing temporary image files, a generated filename, and token usage
- Throws:
ProviderCallException- if request preparation, provider execution, or image processing fails
-
configurationService
-
getBonusHtml
Builds provider-supported image option controls for the assistant UI.- Specified by:
getBonusHtmlin interfaceAiInterface- Parameters:
assistant- assistant whose operation and model define the available controlsprop- translations used for control labels- Returns:
- HTML controls, or an empty string when the assistant has no supported image options
-
validatePromptExpansion
protected void validatePromptExpansion(com.webjetcms.ai.AiPromptTemplate.ExpansionResult expansion, Long assistantId) throws IOException Validates content expanded into trusted prompt instructions before a request is built. The default implementation accepts every expansion. Providers may override this hook to reject suspicious expanded sources.- Parameters:
expansion- expanded prompt and its source classificationsassistantId- assistant identifier used when auditing validation failures- Throws:
IOException- if a provider-specific validation rejects the expansion
-