Annotation Interface K


@Target(PARAMETER) @Retention(RUNTIME) public @interface K
A parameter of an agentic method is annotated with @K to indicate that it is populated with the value of a key representing a specific typed state in the agentic system. That parameter also becomes a prompt template variable, so its value will be injected into prompt templates defined via @UserMessage, @SystemMessage and AiServices.systemMessageProvider(Function). The variable name to be used in the prompt template corresponds to the one returned by the TypedKey.name() method of the class specified as the value of this annotation, which by default is the simple name of the class implementing the TypedKey interface.

Example:

@UserMessage("Hello, my name is {{UserName}}. I am {{UserAge}} years old.")
String chat(@K(UserName.class) String name, @K(UserAge.class) int age);

where:

public class UserName implements AgentState<String> {}"
public class UserAge implements AgentState<Integer> {}"
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Class<? extends TypedKey<?>>