From c9e7d3cd256f288bbe7cffb935923f4268e7dd8d Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Fri, 12 Apr 2024 00:04:41 +0200 Subject: [PATCH] Use Quarkus Antora for testing and live-editting of the docs --- docs/README.adoc | 13 +++ .../samples/AiServiceWithFaultTolerance.java | 6 +- docs/pom.xml | 110 ++++++++++++++++++ .../src/main/resources/application.properties | 14 ++- .../langchain4j/docs/it/AntoraTest.java | 27 +++++ pom.xml | 1 + 6 files changed, 165 insertions(+), 6 deletions(-) create mode 100644 docs/README.adoc create mode 100644 docs/src/test/java/io/quarkiverse/langchain4j/docs/it/AntoraTest.java diff --git a/docs/README.adoc b/docs/README.adoc new file mode 100644 index 000000000..c97c42160 --- /dev/null +++ b/docs/README.adoc @@ -0,0 +1,13 @@ += Antora documentation site for Quarkus LangChain4j + +To edit the documentation with live-reload, start Quarkus in dev mode + +[source,shell] +---- +$ cd docs +$ mvn quarkus:dev +---- + +Once the application has started, hit `w` to open the freshly generated site in browser. + +See https://docs.quarkiverse.io/quarkus-antora/dev/index.html[Quarkus Antora] documentation for more details. diff --git a/docs/modules/ROOT/examples/io/quarkiverse/langchain4j/samples/AiServiceWithFaultTolerance.java b/docs/modules/ROOT/examples/io/quarkiverse/langchain4j/samples/AiServiceWithFaultTolerance.java index c4399f01d..d9980a4c6 100644 --- a/docs/modules/ROOT/examples/io/quarkiverse/langchain4j/samples/AiServiceWithFaultTolerance.java +++ b/docs/modules/ROOT/examples/io/quarkiverse/langchain4j/samples/AiServiceWithFaultTolerance.java @@ -1,9 +1,9 @@ package io.quarkiverse.langchain4j.samples; -import java.util.concurrent.TimeUnit; +import java.time.temporal.ChronoUnit; import org.eclipse.microprofile.faulttolerance.Fallback; -import org.junit.jupiter.api.Timeout; +import org.eclipse.microprofile.faulttolerance.Timeout; import dev.langchain4j.service.SystemMessage; import dev.langchain4j.service.UserMessage; @@ -14,7 +14,7 @@ public interface AiServiceWithFaultTolerance { @SystemMessage("You are a professional poet") @UserMessage("Write a poem about {topic}. The poem should be {lines} lines long.") - @Timeout(value = 60, unit = TimeUnit.SECONDS) + @Timeout(value = 60, unit = ChronoUnit.SECONDS) @Fallback(fallbackMethod = "fallback") String writeAPoem(String topic, int lines); diff --git a/docs/pom.xml b/docs/pom.xml index 336027665..6208ed092 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -41,6 +41,11 @@ quarkus-langchain4j-chroma ${project.version} + + io.quarkiverse.langchain4j + quarkus-langchain4j-pgvector + ${project.version} + io.quarkiverse.langchain4j quarkus-langchain4j-pinecone @@ -61,62 +66,167 @@ quarkus-langchain4j-watsonx ${project.version} + + io.quarkiverse.antora + quarkus-antora + ${quarkus-antora.version} + + + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + io.quarkiverse.langchain4j quarkus-langchain4j-openai-deployment ${project.version} + pom + test + + + * + * + + io.quarkiverse.langchain4j quarkus-langchain4j-redis-deployment ${project.version} + pom + test + + + * + * + + io.quarkiverse.langchain4j quarkus-langchain4j-chroma-deployment ${project.version} + pom + test + + + * + * + + io.quarkiverse.langchain4j quarkus-langchain4j-pinecone-deployment ${project.version} + pom + test + + + * + * + + io.quarkiverse.langchain4j quarkus-langchain4j-pgvector-deployment ${project.version} + pom + test + + + * + * + + io.quarkiverse.langchain4j quarkus-langchain4j-hugging-face-deployment ${project.version} + pom + test + + + * + * + + io.quarkiverse.langchain4j quarkus-langchain4j-ollama-deployment ${project.version} + pom + test + + + * + * + + io.quarkiverse.langchain4j quarkus-langchain4j-infinispan-deployment ${project.version} + pom + test + + + * + * + + io.quarkiverse.langchain4j quarkus-langchain4j-cohere-deployment ${project.version} + pom + test + + + * + * + + io.quarkiverse.langchain4j quarkus-langchain4j-bam-deployment ${project.version} + pom + test + + + * + * + + io.quarkiverse.langchain4j quarkus-langchain4j-watsonx-deployment ${project.version} + pom + test + + + * + * + + diff --git a/docs/src/main/resources/application.properties b/docs/src/main/resources/application.properties index b58e4c158..b6bea363d 100644 --- a/docs/src/main/resources/application.properties +++ b/docs/src/main/resources/application.properties @@ -1,9 +1,17 @@ # Just there to satisfy mandatory properties -quarkus.langchain4j.redis.dimension=180 +quarkus.langchain4j.chat-model.provider=openai +quarkus.langchain4j.chroma.url=dummy +quarkus.langchain4j.embedding-model.provider=openai quarkus.langchain4j.infinispan.dimension=180 +quarkus.langchain4j.openai.api-key=dummy-key +quarkus.langchain4j.pgvector.dimension=180 quarkus.langchain4j.pinecone.environment=abc quarkus.langchain4j.pinecone.index-name=abc quarkus.langchain4j.pinecone.project-id=abc quarkus.langchain4j.pinecone.api-key=abc -quarkus.langchain4j.chat-model.provider=openai -quarkus.langchain4j.embedding-model.provider=openai \ No newline at end of file +quarkus.langchain4j.redis.dimension=180 +quarkus.redis.hosts=redis://localhost:6379 + + +# We do not need the dev services when testing the Antora site +quarkus.devservices.enabled = false diff --git a/docs/src/test/java/io/quarkiverse/langchain4j/docs/it/AntoraTest.java b/docs/src/test/java/io/quarkiverse/langchain4j/docs/it/AntoraTest.java new file mode 100644 index 000000000..1260912fa --- /dev/null +++ b/docs/src/test/java/io/quarkiverse/langchain4j/docs/it/AntoraTest.java @@ -0,0 +1,27 @@ +package io.quarkiverse.langchain4j.docs.it; + +import java.io.IOException; +import java.util.concurrent.TimeoutException; + +import org.hamcrest.CoreMatchers; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +@QuarkusTest +public class AntoraTest { + + @Test + public void antoraSite() throws TimeoutException, IOException, InterruptedException { + RestAssured + .given() + .contentType(ContentType.HTML) + .get("/quarkus-langchain4j/dev/index.html") + .then() + .statusCode(200) + .body(CoreMatchers.containsString("

Quarkus LangChain4j

")); + } + +} diff --git a/pom.xml b/pom.xml index 80f768093..f00db146a 100644 --- a/pom.xml +++ b/pom.xml @@ -45,6 +45,7 @@ 3.8.2 0.29.1 0.29.1 + 0.0.2 2.0.4 3.25.3 3.5.2