Quarkus extension: quarkus-langchain4j-*
Quarkiverse extension?: Yes
LangChain4j extensions seamlessly integrates LLMs into Quarkus applications, enabling the harnessing of LLM capabilities for the development of more intelligent applications.
It is possible to connect with various LLMs as:
- OpenAI
- HuggingFace
- Ollama
- Mistral
- IBM Watson
- More
For more information, check the Quarkus LangChain4j website.
In this guide, we will show an example with OpenAI, but you can use any other LLM available on the website.
- Add the extension:
./kc-extension.sh add io.quarkiverse.langchain4j:quarkus-langchain4j-openai:0.22.0
- Add Quarkus properties in
root
quarkus.properties
(more available options):
quarkus.langchain4j.openai.api-key=sk-...
- Build the extended Keycloak distribution:
./kc-extension.sh build
- Verify it works by running the distribution in dev mode (access at
localhost:8080
):
./kc-extension.sh start-dev
The generated distribution should be available in the root directory with prefix keycloak-extended-*.tar.gz
.
- Create a builder image:
./kc-extension.sh image
- Create your Containerfile/Dockerfile with the builder image
FROM localhost/keycloak-extended:nightly AS builder
# Put your build-time config options
RUN /opt/keycloak/bin/kc.sh build
FROM localhost/keycloak-extended:nightly
COPY --from=builder /opt/keycloak/ /opt/keycloak/
# Put your runtime config options
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
- Execute the Containerfile/Dockerfile
podman build --tag keycloak-langchain4j -f Dockerfile .
- Start the optimized image
podman run -p 8080:8080 \
-e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
-e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
keycloak-langchain4j \
start --hostname-strict=false --http-enabled=true --optimized
You should be able to use LangChain4j in your Keycloak deployment or your Keycloak extension.
For more information, check the Quarkus LangChain4j website.