Package de.xima.fc.prompt.service.support
This package contains the following utilities:
Mixins for prompt connection and query models
Prompts consist of 2 parts, a connection configuration and a query configuration. The connection configuration defines how to connect to the prompt service provider, the query configuration defines the prompt to execute. Each prompt service handler can have a different type of configuration, and usually uses a custom data model class to represent the configuration.
In practice, different types of prompt services will often share similar configuration options, such as e.g. "API key" or a "prompt text". To increase interoperability between different prompt service handlers, implementations should use the same property name for similar configuration options. This way, when the user switches between different prompt services, the configuration data can be preserved. To facilitate this, this package contains mixin interfaces that define common configuration options with a consistent property name. Prompt service handler implementations are encouraged to use these mixins when possible.
For mixins for connection configurations, use de.xima.fc.prompt.conventions IPromptConnectionConfig_*,
e.g. IPromptConnectionConfig_ApiKey.
For mixins for query configurations, use de.xima.fc.prompt.conventions IPromptQueryConfig_*, e.g.
IPromptQueryConfig_UserPrompt.
The Faces taglib with the namespace http://www.xima.de/taglib/xfc/prompt often also contains a
corresponding component for editing the data defined by a mixin. See the class documentation of the mixin for
details.
Common option names
Often, prompt services can perform a multitude of tasks, such as generating text, generating images, transcribing
speech, and so on. A common pattern for prompt service implementations is to let the user select the task to perform
as part of the query configuration UI. The IPromptQueryConfig_Task mixin provides a String property for specifying the task name.
While it is up to each prompt service handler implementation how to call different tasks, we encourage the use of
common task names to increase interoperability between different prompt service handlers.
CommonPromptTask defines constants with standard names for
common tasks. Use these if possible.
In addition, there are other classes with constants for common option values:
CommonAudioFormat- common audio format names, e.g. for speech synthesis outputCommonImageFormat- common image format names, e.g. for image generation outputCommonVideoFormat- common video format names, e.g. for video generation output
Common output properties
CommonPromptOutputProperty contains constants
with common names for prompt output properties, such as the main text answer. You can use these for the
computeQueryOutput method of a prompt service handler implementations. Use of these properties is not mandatory, but
encouraged to improve interoperability between different prompt service implementations.
JSON schema service
Models respond to prompt with a plain text response. While that may be sufficient for simple use cases, more complex scenarios often require structured data, e.g. when you want to access the data programmatically. Some prompt services now offer the ability to define a JSON schema that describes the expected structure of the response. The prompt service will then respond with a JSON object that conforms to the schema.
The CDI-injectable IPromptJsonSchemaService provides various utility methods for working with JSON schemas in the context of prompts,
such as extracting the JSON schema from a configured
IPromptQueryConfig_JsonSchemaOutput; or
transforming a JSON schema to be compatible with the restrictions imposed by a specific prompt service provider.
Prompt parameters service
The CDI-injectable IPromptParametersService provides common utility methods often needed by prompt service handlers for their input and
output parameters, especially for implementing the
computeQueryInput and
computeQueryInput methods.
Execution commons service
The CDI-injectable
IPromptExecutionCommonsService provides
common utility methods often needed by the
executePromptQuery
method of prompt service handlers.
Mixins for prompt service handlers
The prompt engine is implementation-agnostic and can work with any prompt service handler that implements the
IPromptServiceHandler interface. It does not know about any
details from specific implementations. As a result, the prompt service handler interface defines a wide-range of
methods, so that implementations can provide the necessary functionality.
To ease the implementation of prompt service handlers, this package contains mixin interfaces that provide default implementations for common functionalities, so that these do not have to be re-implemented by each prompt service handler.
PromptServiceHandlerMixin_JsonConfig- Mixin for handlers that wish to use a model class that can be serialized as JSON. See the class documentation of the mixin for details.
- Since:
- 8.5.0
-
Interface Summary Interface Description IJsonSchemaTransformer A transformer that applies a series of transformation steps to a JSON schema.IJsonSchemaTransformerBuilder A builder that lets you configure a set of transformation steps to be applied to a JSON schema.IJsonValidationError A single JSON validation error, containing a location and a message.IJsonValidationResult Result of validating a JSON.IPromptConnectionConfig_ApiKey Mixin for aprompt query configuration modelthat allows the user to configure the API key, i.e. the token needed to authenticate with the prompt service provider.IPromptConnectionConfig_ApiUrl Mixin for aprompt query configuration modelthat allows the user to configure the API URL, i.e. the URL of the prompt service provider.IPromptConnectionConfig_ConnectTimeout Mixin for aprompt query configuration modelthat allows the user to configure the connection timeout, i.e. the maximum time to wait for a connection (to the prompt service provider) to be established.IPromptConnectionConfig_Model Mixin for aprompt query configuration modelthat allows the user to configure the model, i.e. the name of the model to use for the prompt service.IPromptConnectionConfig_ReadTimeout Mixin for aprompt query configuration modelthat allows the user to configure the read timeout, i.e. the maximum time to wait for the response from the prompt service provider after sending a request.IPromptExecutionCommonsService Service that provides common logic needed when executing prompt queries.IPromptExecutionObjectGraphPlaceholderReplacer A replacer that replaces placeholders in an object graph of prompt models.IPromptExecutionObjectGraphPlaceholderReplacerBuilder Builder for a replacer that replaces placeholders in an object graph of a prompt model.IPromptExecutionResolvedFiles Represents the result of resolving a files configuration into actual files, seeIPromptExecutionResolveFilesBuilder.build().IPromptExecutionResolveFilesBuilder Builder for resolving a files configuration into actual files.IPromptExecutionResolveTextParametersBuilder Builder for resolving text parameters.IPromptFileParametersDescriptorBuilder Builder for the file parameters descriptor of a prompt query.IPromptImageAlphaChannelConverter Converter that computes a new alpha channel operation based on whether the image has an alpha channel or not.IPromptImageConvertBuilder A builder for a converter that can post-process images.IPromptImageConverter A converter that can post-process images.IPromptImageFormatConverter Computes the new format of an image, based on its current format.IPromptImageGeometryConverter Computes the new geometry of an image, based on its current width and height.IPromptImageInfo Represents metadata of an image, such as its size or format.IPromptImageService Service for working with images in relation to prompt services, e.g. transforming images before they are sent to a prompt service; or after they were received from a prompt service.IPromptJsonAnswerDescriptorBuilder Builder for the JSON answer descriptor of a prompt query.IPromptJsonSchemaService Service for prompt service providers that provides functionality related to JSON schemas.IPromptParametersService Service with logic related to prompt input and output parameters, such asPromptTextParameterorPromptFileSetParameter.IPromptQueryConfig_AddWatermark Mixin for aquery connection configuration modelthat allows the user to configure whether a watermark should be added to generated files (such as images).IPromptQueryConfig_AllowWebSearch Mixin for aquery connection configuration modelthat allows the user to configure whether the prompt service may perform web searches when executing a prompt query.IPromptQueryConfig_AspectRatio Mixin for aprompt query configuration modelthat allows the user to define the aspect ratio, such as e.g. 16:9 or 4:3.IPromptQueryConfig_AudioFormat Mixin for aprompt query configuration modelthat allows the user to define the format of generated audio files, such as e.g. mp3 or wav.IPromptQueryConfig_CandidateTokenLimit Mixin for aquery connection configuration modelthat allows the user to enter an optional candidate token limit, often referred to as "top-k".IPromptQueryConfig_CumulativeProbabilityThreshold Mixin for aquery connection configuration modelthat allows the user to enter an optional cumulative probability threshold for nucleus sampling, often referred to as "top-p".IPromptQueryConfig_DisplayResolution Mixin for aprompt query configuration modelthat allows the user to define the resolution of generated image or video files, such as e.g. 512x512 or 256x256.IPromptQueryConfig_EffortLevel Mixin for aprompt query configuration modelthat allows the user to define amount of effort the prompt service should put into answering the prompt, sometimes also referred to as "reasoning effort" or "thinking level".IPromptQueryConfig_EnhanceUserPrompt Mixin for aquery connection configuration modelthat allows the user to configure whether the prompt service may enhance the user's prompt.IPromptQueryConfig_Files Mixin for aprompt query configuration modelthat allows the user to configure files for the prompt query, by uploading a list of static files and/or by defining a list file set parameters accepted by the query.IPromptQueryConfig_FrequencyPenalty Mixin for aquery connection configuration modelthat allows the user to a frequency penalty when executing a prompt query.IPromptQueryConfig_GeneratedTokenLimit Mixin for aquery connection configuration modelthat allows the user to enter the number of tokens the model should generate at most in its response to the prompt.IPromptQueryConfig_ImageBackground Mixin for aprompt query configuration modelthat allows the user to define the background of generated image files, such as e.g. opaque or transparent.IPromptQueryConfig_ImageCompressionQuality Mixin for aprompt query configuration modelthat allows the user to define the compression quality of generated image files, if the image format supports compression, as a percentage value from 0% to 100%.IPromptQueryConfig_ImageFormat Mixin for aprompt query configuration modelthat allows the user to define the format of generated image files, such as e.g. png or jpeg.IPromptQueryConfig_InputLanguage Mixin for aprompt query configuration modelthat allows the user to define the language of the input text or files that are passed on to the prompt.IPromptQueryConfig_JsonSchemaOutput Mixin for aprompt query configuration modelthat allows the user to define a JSON schema for the prompt response.IPromptQueryConfig_MediaCount Mixin for aprompt query configuration modelthat allows the user to define how many media files such as images or voice clips should be generated.IPromptQueryConfig_MediaSpeed Mixin for aprompt query configuration modelthat allows the user to define the speed at which a media (e.g. speech or music) file should be generated.IPromptQueryConfig_OutputLanguage Mixin for aprompt query configuration modelthat allows the user to define the language of the output text or files that are returned by the prompt.IPromptQueryConfig_PresencePenalty Mixin for aquery connection configuration modelthat allows the user to a presence penalty when executing a prompt query.IPromptQueryConfig_Seed Mixin for aquery connection configuration modelthat allows the user to enter seed when executing a prompt query.IPromptQueryConfig_SingleAudioInput Mixin for aquery connection configuration modelthat allows the user to configure whether the query accepts an audio file as afile input parameter.IPromptQueryConfig_SingleImageInput Mixin for aquery connection configuration modelthat allows the user to configure whether the query accepts an image file as afile input parameter.IPromptQueryConfig_SinglePdfInput Mixin for aquery connection configuration modelthat allows the user to configure whether the query accepts an pdf file as afile input parameter.IPromptQueryConfig_SingleTextInput Mixin for aquery connection configuration modelthat allows the user to configure whether the query accepts an text file as afile input parameter.IPromptQueryConfig_SingleVideoInput Mixin for aquery connection configuration modelthat allows the user to configure whether the query accepts an video file as afile input parameter.IPromptQueryConfig_SystemPrompt Mixin for aquery connection configuration modelthat allows the user to enter an optional system prompt message.IPromptQueryConfig_Task Mixin for aprompt query configuration modelthat allows the user to select a type of task that the query should perform.IPromptQueryConfig_Temperature Mixin for aquery connection configuration modelthat allows the user to enter an optional temperature.IPromptQueryConfig_TextParameters Mixin for aprompt query configuration modelthat allows the user to define a list text parameters accepted by the query.IPromptQueryConfig_TranscriptionFormat Mixin for aprompt query configuration modelthat allows the user to define the format when transcribing speech to text, such as e.g. plain text or subtitles.IPromptQueryConfig_UserPrompt Mixin for aquery connection configuration modelthat allows the user to enter a user prompt message.IPromptQueryConfig_UseSampling Mixin for aquery connection configuration modelthat allows the decide whether the model should use sampling or greedy decoding when generating text.IPromptQueryConfig_VideoFormat Mixin for aprompt query configuration modelthat allows the user to define the format of generated video files, such as e.g.IPromptQueryConfig_Voice Mixin for aprompt query configuration modelthat allows the user to define the name or ID of a voice to use when synthesizing speech.IPromptTextAnswerDescriptorBuilder Builder for the text answer descriptor of a prompt query.IPromptTextInputParamsBuilder Builder for extractingprompt text parametersfrom a given configuration object.IPromptTextParameterDescriptorBuilder Builder for the text parameters descriptor of a prompt query.PromptServiceHandlerMixin_JsonConfig<ConnectionConfig,QueryConfig> Mixin interface forIPromptServiceHandlerimplementations that provides JSON marshalling for the prompt connection and query configuration. -
Class Summary Class Description CommonAspectRatio Enumeration for common types of aspect ratios.CommonAudioFormat Enumeration for common types of audio formats.CommonEffortLevel Enumeration for common types of effort levels.CommonImageBackground Enumeration for common types of image backgrounds.CommonImageFormat Enumeration for common types of image formats.CommonPromptInputProperty Constants with common names for prompt input properties, seecomputeQueryInput.CommonPromptOutputProperty Constants with common names for prompt output properties, seecomputeQueryOutput.CommonPromptTask Enumeration for common types of prompt tasks.CommonTranscriptionFormat Enumeration for common types of transcription formats, when transcribing speech to text.CommonVideoFormat Enumeration for common types of audio formats.JsonSchemaOutput View model POJO for users to define a JSON schema for the prompt response.JsonSchemaOutputByJsonExample View model POJO for users to define a JSON schema for the prompt response, by entering a JSON example.JsonSchemaOutputByManualInput View model POJO for users to define a JSON schema for the prompt response, by entering the JSON schema manually.JsonSchemaOutputByPropertyList View model POJO for users to define a JSON schema for the prompt response, by entering a list of properties for the object.JsonSchemaOutputByVisualEditor View model POJO for users to define a JSON schema for the prompt response, by using a visual JSON schema editor.JsonSchemaOutputObjectProperty One of the properties of a JSON object schema, used inJsonSchemaOutputByPropertyList.PromptConfigFile View model for a single file, intended to be used as part of thedeserialized prompt connection configurationordeserialized prompt query configuration.PromptFiles A configuration for a set of files, used by the configuration of a prompt connection or query.PromptFileSetParameter A set of files for dynamic file input parameters of a prompt query.PromptFileType Models a file type, which can either be defined by its file extension (e.g. ".txt") or by its kind (e.g.PromptFileType.Extension APromptFileTypethat identifies a file by its extension, e.g. ".txt" or ".png".PromptFileType.Kind APromptFileTypethat identifies a file by its kind, e.g.PromptImageAlphaChannelConverters Factory for common alpha channel converters.PromptImageFormatConverters Factory for common image format converters.PromptImageGeometryConverters Factory for commonIPromptImageGeometryConverterimplementations.PromptImageGeometryData Represents the target geometry of an image.PromptImageGeometryData.Builder Builder forPromptImageGeometryData.PromptTextParameter SystemPrompt View model POJO for users to define a system prompt that is sent to the prompt provider. -
Enum Summary Enum Description EJsonSchemaDefinitionMethod Enumeration that defines the methods available for a user to define a JSON schema for the prompt response.EJsonSchemaOutputPropertyType Used byJsonSchemaOutputObjectProperty.EJsonSchemaVersion Enumeration of JSON schema versions.EPromptConfigParamFileMultiplicity Enumeration that defines the multiplicity of file input parameters in a prompt query configuration, e.g. how many files are allowed.EPromptImageObjectFit The object-fit property defines how an image should be resized to fit its canvas.ForbidOptionalPropertiesMode Mode that controls the behavior of theforbidOptionalPropertiestransform step.PromptFileSource PromptFileType.PromptFileKind Enumeration of file kinds, which can be used to categorize files by their content type rather than by their file extension.SingularFileMode Enumeration for a single input or output file that describes whether the file is required, optional, or never allowed. -
Exception Summary Exception Description JsonSchemaServiceException Generic exception for JSON processing errors for the JSON Schema service. -
Annotation Types Summary Annotation Type Description PromptConfigJsonDiscriminatedUnion Annotation for model classes that represent the abstract base class of a discriminated union, intended for use with theJsonConfig mixinforprompt service handlers.PromptConfigJsonDiscriminatedUnionMember Annotation for a model class that represents a subclass of a discriminated union, intended for use with theJsonConfig mixinforprompt service handlers.PromptConfigJsonDiscriminator Annotation for the discriminator field of a model class that represents the abstract base class of a discriminated union, intended for use with theJsonConfig mixinforprompt service handlers.PromptConfigJsonField Optional annotation for customizing instance fields when serializing and deserializing prompt configuration instances.PromptTextParams