Home

Awesome

spring-ai-zero-to-hero

Example applications showing how to use Spring AI to build Generative AI projects.

Software Prerequisites

You need the following software installed: Java 21, docker, ollama, httpie, ard your favourite Java IDE. This is a lot of GBs to download so please make sure to have all this stuff installed before the conference workshop, as the conference wifi may be slow, so you might not be able to run the samples.

Java development tooling

Http Client

Containerization tools

Local AI Models

ollama makes running models on your laptop easy and very educational. You can run the models locally and learn how they work.

Save the conference Wi-Fi

Please make sure that the software list above is installed on your laptop before the workshop starts. After install:

  1. clone this repo to your laptop
  2. Run the ./download-deps.sh script pull local AI models, and container images.
  3. Run the check-deps.sh script to check that the all the required software is installed, the output of the script on my machine looks like.
./check-deps.sh
============================
Checking Java installation:
============================
Java is installed. Version details:
openjdk version "21.0.4" 2024-07-16 LTS
OpenJDK Runtime Environment (build 21.0.4+9-LTS)
OpenJDK 64-Bit Server VM (build 21.0.4+9-LTS, mixed mode, sharing)

===============================
Checking Ollama installation:
===============================
Ollama is installed. Version details:
ollama version is 0.3.10

========================================
Checking if llama3.1 model is pulled:
========================================
llama3.1 model is pulled and available.

==============================
Checking Docker installation:
==============================
Docker is installed. Version details:
Docker version 27.1.1, build 6312585

Checking Docker image: pgvector/pgvector:pg16
Docker image pgvector/pgvector:pg16 is pulled.

Checking Docker image: dpage/pgadmin4:8.6
Docker image dpage/pgadmin4:8.6 is pulled.

===============================
Checking HTTPie installation:
===============================
HTTPie is installed. Version details:
3.2.3

if you run into issues try running the commands in the check-deps.sh script one at a time.

API Keys

You will be provided with API keys for online AI services during the workshop, these keys will only be valid during the workshop. Highly recommend you get your own keys to continue experimenting after the workshop.

OpenAI

Azure OpenAI

Outline

Generative AI is a transformational technology impacting our world in profound ways and creating unprecedented opportunities. This workshop is designed for Spring developers looking to add generative AI to existing applications or to implement brand new AI apps using the Spring AI project.

We assume no previous AI experience. The workshop will teach you key AI concepts and how to apply them in your applications, using the Spring AI project.

The workshop is hands-on. Bring your laptop and a willingness to learn. We will provide Spring AI based sample code and the API keys for the AI services. By the end of the day you will know how to add generative AI features to your Spring apps.

Key Concepts covered:

Hands on Code Exercises with Spring AI:

Repo Organization

Spring AI provides a consistent API to work with many different types of AI providers. For example, the same code wil work with OpenAI, Google Vertex AI, Azure OpenAI, and local AI models. The major directories in this repo are:

Recommendations to get the most out of the repo

  1. Run the samples with the different AI providers to see how the same code works with different providers.
  2. Run the gateway application and inspect the API requests/responses to see what interaction with the AI projects looks like on the wire.
  3. Make sure to run ollama and download the llama3 model to see how easy it is to run local AI models.
  4. The code in this repo is designed to be read in order, so start with the code in the api directory and work your way through the projects. Once you have looked at the code in the api directory move on to the code in the patterns' directory.
  5. Spring AI project is evolving quickly, it is possible that the code in this repo will be using a snapshot release of the Spring AI project, or that it falls behind the latest version. If you run into problem with this repo, send a pull request or open an issue.