Package dev.langchain4j.service
Annotation Interface V
When a parameter of a method in an AI Service is annotated with
@V
,
it becomes a prompt template variable. Its value will be injected into prompt templates defined
via @UserMessage
, @SystemMessage
and AiServices.systemMessageProvider(Function)
.
Example:
@UserMessage("Hello, my name is {{name}}. I am {{age}} years old.")
String chat(@V("name") String name, @V("age") int age);
This annotation is necessary only when the "-parameters" option is *not* enabled during Java compilation. If the "-parameters" option is enabled, parameter names can directly serve as identifiers, eliminating the need to define a value of @V annotation. Example:
@UserMessage("Hello, my name is {{name}}. I am {{age}} years old.")
String chat(@V String name, @V int age);
When using Spring Boot, defining the value of this annotation is not required.
- See Also:
-
Required Element Summary
Required Elements
-
Element Details
-
value
String valueName of a variable (placeholder) in a prompt template.
-