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 LangChain4j with Quarkus or Spring Boot, using this annotation is not necessary.
- See Also:
-
Required Element Summary
-
Element Details
-
value
String valueName of a variable (placeholder) in a prompt template.
-