diff --git a/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/AiServicesProcessor.java b/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/AiServicesProcessor.java index 26240583e..f171adc34 100644 --- a/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/AiServicesProcessor.java +++ b/core/deployment/src/main/java/io/quarkiverse/langchain4j/deployment/AiServicesProcessor.java @@ -560,7 +560,7 @@ private List gatherTemplateParamInfo(List templateParams = new ArrayList<>(); for (MethodParameterInfo param : params) { - if (param.annotations().isEmpty()) { // if a parameter has no annotations it is considered a template variable + if (effectiveParamAnnotations(param).isEmpty()) { // if a parameter has no annotations it is considered a template variable templateParams.add(new TemplateParameterInfo(param.position(), param.name())); } else { AnnotationInstance vInstance = param.annotation(V); @@ -581,6 +581,19 @@ private List gatherTemplateParamInfo(List effectiveParamAnnotations(MethodParameterInfo param) { + return param.annotations().stream().filter(ai -> { + String name = ai.name().toString(); + if (name.startsWith("kotlin")) { + return false; + } + if (name.endsWith("NotNull")) { + return false; + } + return true; + }).collect(Collectors.toList()); + } + private Optional gatherSystemMessageInfo(MethodInfo method, List templateParams) { AnnotationInstance instance = method.annotation(Langchain4jDotNames.SYSTEM_MESSAGE); diff --git a/openai/openai-vanilla/deployment/src/test/java/org/acme/examples/aiservices/AiServicesTest.java b/openai/openai-vanilla/deployment/src/test/java/org/acme/examples/aiservices/AiServicesTest.java index be05454a4..48d8600a3 100644 --- a/openai/openai-vanilla/deployment/src/test/java/org/acme/examples/aiservices/AiServicesTest.java +++ b/openai/openai-vanilla/deployment/src/test/java/org/acme/examples/aiservices/AiServicesTest.java @@ -14,6 +14,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.tuple; +import jakarta.validation.constraints.NotNull; import java.io.IOException; import java.time.LocalDate; import java.time.LocalDateTime; @@ -121,7 +122,7 @@ public void test_simple_instruction_with_single_argument_and_no_annotations() th interface Humorist { @UserMessage("Tell me a joke about {{it}}") - String joke(String topic); + String joke(@NotNull String topic); } @Test