Annotation Interface SystemMessage
Specifies either a complete system message (prompt) or a system message template to be used each time an AI service is invoked.
An example:
An example:
An example:
interface Assistant {
@SystemMessage("You are a helpful assistant")
String chat(String userMessage);
}
The system message can contain template variables,
which will be resolved with values from method parameters annotated with @V.
An example:
interface Assistant {
@SystemMessage("You are a {{characteristic}} assistant")
String chat(@UserMessage String userMessage, @V("characteristic") String characteristic);
}
When both @SystemMessage and AiServices.systemMessageProvider(Function) are configured,
@SystemMessage takes precedence.- See Also:
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
String[] valuePrompt template can be defined in one line or multiple lines. If the template is defined in multiple lines, the lines will be joined with a delimiter defined below.- Default:
{""}
-
delimiter
String delimiter- Default:
"\n"
-
fromResource
String fromResourceThe resource from which to read the prompt template. If no resource is specified, the prompt template is taken fromvalue(). If the resource is not found, anIllegalConfigurationExceptionis thrown.The resource will be read by calling
Class.getResourceAsStream(String)on the AI Service class (interface).- Default:
""
-