Annotation Interface UserMessage


@Retention(RUNTIME) @Target({METHOD,PARAMETER}) public @interface UserMessage
Specifies either a complete user message or a user message template to be used each time an AI service is invoked. The user message can contain template variables, which will be resolved with values from method parameters annotated with @V.
An example:
 interface Assistant {

     @UserMessage("Say hello to {{name}}")
     String greet(@V("name") String name);
 }
 
@UserMessage can also be used with method parameters:
 interface Assistant {

     @SystemMessage("You are a {{characteristic}} assistant")
     String chat(@UserMessage String userMessage, @V("characteristic") String characteristic);
 }
 
In this case String userMessage can contain unresolved template variables (e.g. "{{characteristic}}"), which will be resolved using the values of method parameters annotated with @V.
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
    The resource from which to read the prompt template.
    Prompt template can be defined in one line or multiple lines.
  • Element Details

    • value

      String[] value
      Prompt 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 fromResource
      The resource from which to read the prompt template. If no resource is specified, the prompt template is taken from value(). If the resource is not found, an IllegalConfigurationException is thrown.

      The resource will be read by calling Class.getResourceAsStream(String) on the AI Service class (interface).

      Default:
      ""