Skip to content

Commit

Permalink
Merge pull request #459 from ppalaga/240412-quantora
Browse files Browse the repository at this point in the history
Use Quarkus Antora for testing and live-editting of the docs
  • Loading branch information
geoand authored Apr 12, 2024
2 parents 177efc9 + c9e7d3c commit 1d158e7
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 7 deletions.
13 changes: 13 additions & 0 deletions docs/README.adoc
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/includes/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:project-version: 0.10.4
:langchain4j-version: 0.29.1
:examples-dir: ./../examples/
:examples-dir: ./../examples/
110 changes: 110 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
<artifactId>quarkus-langchain4j-chroma</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-pgvector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-pinecone</artifactId>
Expand All @@ -61,62 +66,167 @@
<artifactId>quarkus-langchain4j-watsonx</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.antora</groupId>
<artifactId>quarkus-antora</artifactId>
<version>${quarkus-antora.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>

<!-- Make sure the doc is built after the other artifacts -->
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-openai-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-redis-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-chroma-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-pinecone-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-pgvector-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-hugging-face-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-ollama-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-infinispan-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-cohere-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-bam-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.langchain4j</groupId>
<artifactId>quarkus-langchain4j-watsonx-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
14 changes: 11 additions & 3 deletions docs/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -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
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
Original file line number Diff line number Diff line change
@@ -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("<h1 class=\"page\">Quarkus LangChain4j</h1>"));
}

}
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<quarkus.version>3.8.2</quarkus.version>
<langchain4j.version>0.29.1</langchain4j.version>
<langchain4j-embeddings.version>0.29.1</langchain4j-embeddings.version>
<quarkus-antora.version>0.0.2</quarkus-antora.version>
<quarkus-poi.version>2.0.4</quarkus-poi.version> <!-- we need to use this version because langchain4j uses POI 5.2.3 instead of 5.2.5 and the substitution needed is different in the two versions -->
<assertj.version>3.25.3</assertj.version>
<wiremock.version>3.5.2</wiremock.version>
Expand Down

0 comments on commit 1d158e7

Please sign in to comment.