LangChain4j is a Java-native framework that offers two levels of abstraction for integrating Large Language Models (LLMs) into applications.
The two levels of abstraction provided by LangChain4j are Low-Level Abstraction and High-Level Abstraction.
Low-Level Abstraction gives developers full control over customized workflows and direct access to LLM primitives.
Components accessible at the low-level include ChatModel, LanguageModel, UserMessage, AiMessage, EmbeddingStore, Embedding, ImageModel, ModerationModel, and ScoringModel.
With Low-Level Abstraction, developers need to manage input formatting, output parsing, state, and chaining logic manually.
High-Level Abstraction, known as AI Services, simplifies common LLM tasks using a declarative, proxy-based interface.
AI Services handle formatting inputs for LLMs, parsing LLM responses, managing chat memory, integrating tools, and supporting Retrieval-Augmented Generation (RAG).
Developers define interactions with LLMs as Java interfaces, and LangChain4j generates concrete implementations at runtime.
LangChain4j aims to reduce boilerplate and increase developer productivity with its High-Level Abstraction using AI Services.