Skip to content

Latest commit

 

History

History
100 lines (66 loc) · 2.35 KB

langchain4j.md

File metadata and controls

100 lines (66 loc) · 2.35 KB

Quarkiverse LangChain4j

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.

Guide

In this guide, we will show an example with OpenAI, but you can use any other LLM available on the website.

  1. Add the extension:
./kc-extension.sh add io.quarkiverse.langchain4j:quarkus-langchain4j-openai:0.22.0
  1. Add Quarkus properties in root quarkus.properties(more available options):
quarkus.langchain4j.openai.api-key=sk-...
  1. Build the extended Keycloak distribution:
./kc-extension.sh build
  1. Verify it works by running the distribution in dev mode (access at localhost:8080):
./kc-extension.sh start-dev

Container support

The generated distribution should be available in the root directory with prefix keycloak-extended-*.tar.gz.

  1. Create a builder image:
./kc-extension.sh image
  1. 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"]
  1. Execute the Containerfile/Dockerfile
podman build --tag keycloak-langchain4j -f Dockerfile .
  1. 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

Summary

You should be able to use LangChain4j in your Keycloak deployment or your Keycloak extension.

For more information, check the Quarkus LangChain4j website.