Package io.jmix.aichat.data
Interface AiChatMessageFactory<T extends AiChatMessage>
- Type Parameters:
T- the message type
- All Superinterfaces:
Function<AiChatMessageContext,,T> Serializable
- All Known Implementing Classes:
DefaultAiChatMessageFactory
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface AiChatMessageFactory<T extends AiChatMessage>
extends Function<AiChatMessageContext,T>, Serializable
Creates message instances of the application's type for
AiChat. AiChat mints the user echo and the
assistant response through this factory. In Jmix this is expected to be backed by
Metadata.create.
A named Function rather than a bare one: everything it is given arrives in an
AiChatMessageContext, so a value added later reaches every factory without changing
this interface, and the type keeps a home for the persistence obligation below.
-
Method Summary
Modifier and TypeMethodDescriptionapply(AiChatMessageContext context) Creates a message for the given context.
-
Method Details
-
apply
Creates a message for the given context. The factory owns persistence: for an entity source it saves each attachment's bytes to file storage and sets the resultingFileRefs on the created message.- Specified by:
applyin interfaceFunction<AiChatMessageContext,T extends AiChatMessage> - Parameters:
context- what is known about the message to create- Returns:
- the created message
-