Context assembly with LangChain4j and Ollama
This example is the one shown in the book. It wires four context sources into a single AI service: the system instruction, a bounded chat memory, a content retriever, and a tool object.
Three questions exercise the three sources in turn, so the console output shows which one answered each turn.
Requirements
- Java 21+
- Maven 3.9+
- Ollama installed locally
- A pulled chat model such as
llama3.2:1b - A pulled embedding model such as
nomic-embed-text
Steps for running this example in the shell
- Start Ollama and pull the models:
bash
ollama serve
ollama pull llama3.2:1b
ollama pull nomic-embed-text- Run the application:
bash
mvn compile exec:javaOutput
Use the self-service portal to reset your password, then sign in again.
42
You first asked how to reset your password.