Skip to content

piomin/spring-ai-showcase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring AI Showcase Demo Project Twitter

CircleCI

SonarCloud Bugs Coverage Lines of Code

This project demonstrates the integration of AI capabilities within a Spring Boot application, utilizing the Spring AI framework.


Table of Contents

Architecture

Currently, there are four @RestControllers that show Spring AI features:

pl.piomin.services.controller.PersonController - prompt template, chat memory, and structured output based on a simple example that asks AI model to generate some persons

pl.piomin.services.controller.WalletController - function calling that calculates a value of our wallet stored in local database in conjunction with the latest stock prices

pl.piomin.services.controller.StockController - RAG with a Pinecone vector store and OpenAI based on stock prices API

pl.piomin.services.controller.ImageController - image model and multimodality

The architecture is designed to be modular and scalable, focusing on demonstrating how AI features can be incorporated into Spring-based applications.

Running the Application

Follow these steps to run the application locally.

git clone https://github.com/piomin/spring-ai-showcase.git
cd spring-ai-showcase

By default, this sample Spring AI app connects to OpenAI. So, before running the app you must set a token:

export OPEN_AI_TOKEN=<YOUR_API_TOKEN>
mvn spring-boot:run

To enable integration with Mistral, we should activate the mistral-ai profile:

export MISTRAL_AI_TOKEN=<YOUR_API_TOKEN>
mvn spring-boot:run -Pmistral-ai

To enable integration with Ollama, we should activate the ollama-ai profile:

mvn spring-boot:run -Pollama-ai

Before that, we must run the model on Ollama, e.g.:

ollama run llava

For scenarios with a vector store (StockController, ImageController) you need to export the following ENV:

export PINECONE_TOKEN=<YOUR_PINECONE_TOKEN>

For scenarios with a stock API (StockController, WalletController) you need to export the following ENV:

export STOCK_API_KEY=<YOUR_PINECONE_TOKEN>

More details in the articles.

Articles

  1. Getting started with Spring AI Chat Model and easily switch between different AI providers including OpenAI, Mistral AI and Ollama. The example is available in the branch master. A detailed guide may be found in the following article: Getting Started with Spring AI and Chat Model
  2. Getting started with Spring AI Function Calling for OpenAI chat models. The example is available in the branch master. A detailed guide may be found in the following article: Getting Started with Spring AI Function Calling
  3. Using RAG (Retrieval Augmented Generation) and Vector Store with Spring AI. The example is available in the branch master. A detailed guide may be found in the following article: Using RAG and Vector Store with Spring AI
  4. Using Multimodality feature and Image Model with Spring AI and OpenAI. The example is available in the branch master. A detailed guide may be found in the following article: Spring AI with Multimodality and Images
  5. Running multiple models with Ollama and integration through Spring AI. The example is available in the branch master. A detailed guide may be found in the following article: Using Ollama with Spring AI