Setup | Running the Project | Notebooks | Project Structure | Implementation Details
This project uses Docker Compose to set up a complete environment for running Java-based AI applications with Redis. The environment includes:
- A Jupyter Notebook server with Java kernel support
- Redis Stack (includes Redis and RedisInsight)
- Pre-installed dependencies for AI/ML workloads
- Docker and Docker Compose
- OpenAI API key (for notebooks that use OpenAI services)
- Create a
.env
file in the project root with your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here
-
Clone the repository (if you haven't already):
git clone https://github.com/redis-developer/redis-ai-resources.git cd redis-ai-resources/java-resources
-
Start the Docker containers:
docker-compose up -d
-
Access the Jupyter environment:
-
Open your browser and navigate to http://localhost:8888
-
The token is usually shown in the docker-compose logs. You can view them with:
docker-compose logs jupyter
-
-
Access RedisInsight:
- Open your browser and navigate to http://localhost:8001
- Connect to Redis using the following details:
- Host: redis-java
- Port: 6379
- No password (unless configured)
-
When finished, stop the containers:
docker-compose down
Notebook | Description |
---|---|
RAG/spring_ai_redis_rag.ipynb | Demonstrates building a RAG-based beer recommendation chatbot using Spring AI and Redis as the vector store |
java-recipes/
├── .env # Environment variables (create this)
├── docker-compose.yml # Docker Compose configuration
├── jupyter/ # Jupyter configuration files
│ ├── Dockerfile # Dockerfile for Jupyter with Java kernel
│ ├── environment.yml # Conda environment specification
│ ├── install.py # JJava kernel installation script
│ ├── kernel.json # Kernel specification
│ └── java/ # Java dependencies and configuration
│ └── pom.xml # Maven project file with dependencies
└── resources/ # Data files for notebooks
└── beers.json.gz # Compressed beer dataset
The project uses JJava, a Jupyter kernel for Java based on JShell. This allows for interactive Java development in Jupyter notebooks.
Key components:
- Java 21 for modern Java features
- Maven for dependency management
- JJava kernel for Jupyter integration
The Spring AI notebooks showcase how to use Spring's AI capabilities with Redis:
- Spring AI: Framework for building AI-powered applications
- Redis Vector Store: Used for storing and querying vector embeddings
- Transformer Models: For generating embeddings locally
- RAG Pattern: Demonstrates the Retrieval Augmented Generation pattern
The Docker setup includes:
-
Jupyter Container:
- Based on minimal Jupyter notebook image
- Adds Java 21, Maven, and the JJava kernel
- Includes Python environment with PyTorch and other ML libraries
-
Redis Container:
- Uses Redis Stack image with Vector Search capabilities
- Persists data using Docker volumes
- Exposes Redis on port 6379 and RedisInsight on port 8001
The spring-ai-rag.ipynb
notebook demonstrates:
- Loading and embedding beer data into Redis Vector Store
- Using local transformer models for generating embeddings
- Connecting to OpenAI for LLM capabilities
- Building a RAG pipeline to answer beer-related queries
- Semantic search over beer properties and descriptions