Skip to content

Commit

Permalink
Merge pull request #133 from quarkiverse/#129
Browse files Browse the repository at this point in the history
Ignore OpenTelemetry parameter annotations
  • Loading branch information
geoand authored Dec 12, 2023
2 parents 7a55f08 + cdaaf80 commit bd69775
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ private List<AnnotationInstance> effectiveParamAnnotations(MethodParameterInfo p
if (name.endsWith("NotNull")) {
return false;
}
if (name.startsWith("io.opentelemetry")) {
return false;
}
return true;
}).collect(Collectors.toList());
}
Expand Down
5 changes: 5 additions & 0 deletions openai/openai-vanilla/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-instrumentation-annotations</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import dev.langchain4j.service.UserMessage;
import dev.langchain4j.service.V;
import dev.langchain4j.store.memory.chat.ChatMemoryStore;
import io.opentelemetry.instrumentation.annotations.SpanAttribute;
import io.quarkiverse.langchain4j.openai.test.WiremockUtils;
import io.quarkus.test.QuarkusUnitTest;

Expand Down Expand Up @@ -122,13 +123,16 @@ public void test_simple_instruction_with_single_argument_and_no_annotations() th

interface Humorist {

@UserMessage("Tell me a joke about {{it}}")
String joke(@NotNull String topic);
@UserMessage("Tell me a joke about {{wrapper.topic}}")
String joke(@SpanAttribute @NotNull Wrapper wrapper);
}

public record Wrapper(String topic) {
}

@Test
public void test_simple_instruction_with_single_argument() throws IOException {
String result = AiServices.create(Humorist.class, createChatModel()).joke("programmers");
String result = AiServices.create(Humorist.class, createChatModel()).joke(new Wrapper("programmers"));
assertThat(result).isNotBlank();

assertSingleRequestMessage(getRequestAsMap(), "Tell me a joke about programmers");
Expand Down

0 comments on commit bd69775

Please sign in to comment.