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
-
ClassDescriptionEnumeration for common types of aspect ratios.Enumeration for common types of audio formats.Enumeration for common types of effort levels.Enumeration for common types of image backgrounds.Enumeration for common types of image formats.Constants with common names for prompt input properties, see
computeQueryInput.Constants with common names for prompt output properties, seecomputeQueryOutput.Enumeration for common types of prompt tasks.Enumeration for common types of transcription formats, when transcribing speech to text.Enumeration for common types of audio formats.Enumeration that defines the methods available for a user to define a JSON schema for the prompt response.Used byJsonSchemaOutputObjectProperty.Enumeration of JSON schema versions.Enumeration that defines the multiplicity of file input parameters in a prompt query configuration, e.g. how many files are allowed.The object-fit property defines how an image should be resized to fit its canvas.Mode that controls the behavior of theforbidOptionalPropertiestransform step.A transformer that applies a series of transformation steps to a JSON schema.A builder that lets you configure a set of transformation steps to be applied to a JSON schema.A single JSON validation error, containing a location and a message.Result of validating a JSON.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.Mixin for aprompt query configuration modelthat allows the user to configure the API URL, i.e. the URL of the prompt service provider.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.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.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.Service that provides common logic needed when executing prompt queries.A replacer that replaces placeholders in an object graph of prompt models.Builder for a replacer that replaces placeholders in an object graph of a prompt model.Represents the result of resolving a files configuration into actual files, seeIPromptExecutionResolveFilesBuilder.build().Builder for resolving a files configuration into actual files.Builder for resolving text parameters.Builder for the file parameters descriptor of a prompt query.Converter that computes a new alpha channel operation based on whether the image has an alpha channel or not.A builder for a converter that can post-process images.A converter that can post-process images.Computes the new format of an image, based on its current format.Computes the new geometry of an image, based on its current width and height.Represents metadata of an image, such as its size or format.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.Builder for the JSON answer descriptor of a prompt query.Service for prompt service providers that provides functionality related to JSON schemas.Service with logic related to prompt input and output parameters, such asPromptTextParameterorPromptFileSetParameter.Mixin for aquery connection configuration modelthat allows the user to configure whether a watermark should be added to generated files (such as images).Mixin for aquery connection configuration modelthat allows the user to configure whether the prompt service may perform web searches when executing a prompt query.Mixin for aprompt query configuration modelthat allows the user to define the aspect ratio, such as e.g. 16:9 or 4:3.Mixin for aprompt query configuration modelthat allows the user to define the format of generated audio files, such as e.g. mp3 or wav.Mixin for aquery connection configuration modelthat allows the user to enter an optional candidate token limit, often referred to as "top-k".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".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.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".Mixin for aquery connection configuration modelthat allows the user to configure whether the prompt service may enhance the user's prompt.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.Mixin for aquery connection configuration modelthat allows the user to a frequency penalty when executing a prompt query.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.Mixin for aprompt query configuration modelthat allows the user to define the background of generated image files, such as e.g. opaque or transparent.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%.Mixin for aprompt query configuration modelthat allows the user to define the format of generated image files, such as e.g. png or jpeg.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.Mixin for aprompt query configuration modelthat allows the user to define a JSON schema for the prompt response.Mixin for aprompt query configuration modelthat allows the user to define how many media files such as images or voice clips should be generated.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.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.Mixin for aquery connection configuration modelthat allows the user to a presence penalty when executing a prompt query.Mixin for aquery connection configuration modelthat allows the user to enter seed when executing a prompt query.Mixin for aquery connection configuration modelthat allows the user to configure whether the query accepts an audio file as afile input parameter.Mixin for aquery connection configuration modelthat allows the user to configure whether the query accepts an image file as afile input parameter.Mixin for aquery connection configuration modelthat allows the user to configure whether the query accepts an pdf file as afile input parameter.Mixin for aquery connection configuration modelthat allows the user to configure whether the query accepts an text file as afile input parameter.Mixin for aquery connection configuration modelthat allows the user to configure whether the query accepts an video file as afile input parameter.Mixin for aquery connection configuration modelthat allows the user to enter an optional system prompt message.Mixin for aprompt query configuration modelthat allows the user to select a type of task that the query should perform.Mixin for aquery connection configuration modelthat allows the user to enter an optional temperature.Mixin for aprompt query configuration modelthat allows the user to define a list text parameters accepted by the query.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.Mixin for aquery connection configuration modelthat allows the user to enter a user prompt message.Mixin for aquery connection configuration modelthat allows the decide whether the model should use sampling or greedy decoding when generating text.Mixin for aprompt query configuration modelthat allows the user to define the format of generated video files, such as e.g.Mixin for aprompt query configuration modelthat allows the user to define the name or ID of a voice to use when synthesizing speech.Builder for the text answer descriptor of a prompt query.Builder for extractingprompt text parametersfrom a given configuration object.Builder for the text parameters descriptor of a prompt query.View model POJO for users to define a JSON schema for the prompt response.View model POJO for users to define a JSON schema for the prompt response, by entering a JSON example.View model POJO for users to define a JSON schema for the prompt response, by entering the JSON schema manually.View model POJO for users to define a JSON schema for the prompt response, by entering a list of properties for the object.View model POJO for users to define a JSON schema for the prompt response, by using a visual JSON schema editor.One of the properties of a JSON object schema, used inJsonSchemaOutputByPropertyList.Generic exception for JSON processing errors for the JSON Schema service.View model for a single file, intended to be used as part of thedeserialized prompt connection configurationordeserialized prompt query configuration.Annotation for model classes that represent the abstract base class of a discriminated union, intended for use with theJsonConfig mixinforprompt service handlers.Annotation for a model class that represents a subclass of a discriminated union, intended for use with theJsonConfig mixinforprompt service handlers.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.Optional annotation for customizing instance fields when serializing and deserializing prompt configuration instances.A configuration for a set of files, used by the configuration of a prompt connection or query.A set of files for dynamic file input parameters of a prompt query.Models a file type, which can either be defined by its file extension (e.g. ".txt") or by its kind (e.g.APromptFileTypethat identifies a file by its extension, e.g. ".txt" or ".png".APromptFileTypethat identifies a file by its kind, e.g.Enumeration of file kinds, which can be used to categorize files by their content type rather than by their file extension.Factory for common alpha channel converters.Factory for common image format converters.Factory for commonIPromptImageGeometryConverterimplementations.Represents the target geometry of an image.Builder forPromptImageGeometryData.PromptServiceHandlerMixin_JsonConfig<ConnectionConfig, QueryConfig>Mixin interface forIPromptServiceHandlerimplementations that provides JSON marshalling for the prompt connection and query configuration.Enumeration for a single input or output file that describes whether the file is required, optional, or never allowed.View model POJO for users to define a system prompt that is sent to the prompt provider.