Player not loading? Watch on YouTube
Venkat Subramaniam introduces LangChain4j through Java examples that progress from a simple prompt to conversational retrieval over custom documents. He explains its interfaces and model adapters through an analogy with JDBC drivers, showing how application code can depend on a common interface while provider-specific dependencies handle model access.
The first demo calls OpenAI with an API key read from an environment variable. A dad-joke prompt then gains a system message that steers the response toward programming. The document example uses two text files: one lists conference speakers and talk titles, while the other contains titles and abstracts. Subramaniam connects an embedding model, an in-memory store and a content retriever, with 6,000-character chunks, 100-character overlap and a sliding window of 10 chat messages.
Follow-up questions demonstrate how the conversation retains references to earlier answers. The responses also vary, and Subramaniam warns about hallucinations and incomplete results. He recommends experimenting with document splitting and separating reusable ingestion from retrieval, with persistent storage for shared application data.
The demonstrated generation calls use OpenAI, and he also discusses the option of using a local LLM. The closing discussion covers agent workflows and names Spring AI as another option for Spring applications.