Awesome
Spring AI
The Spring AI project provides a Spring-friendly API and abstractions for developing AI applications.
Its goal is to apply to the AI domain Spring ecosystem design principles such as portability and modular design and promote using POJOs as the building blocks of an application to the AI domain.
At its core, Spring AI addresses the fundamental challenge of AI integration: Connecting your enterprise Data and APIs with the AI Models.
For further information go to our Spring AI Reference Documentation.
The project draws inspiration from notable Python projects, such as LangChain and LlamaIndex, but Spring AI is not a direct port of those projects. The project was founded with the belief that the next wave of Generative AI applications will not be only for Python developers but will be ubiquitous across many programming languages.
This is a high level feature overview. You can find more details in the Reference Documentation
- Support for all major AI Model providers such as Anthropic, OpenAI, Microsoft, Amazon, Google, and Ollama. Supported model types include:
- Portable API support across AI providers for both synchronous and streaming API options are supported. Access to model-specific features is also available.
- Structured Outputs - Mapping of AI Model output to POJOs.
- Support for all major Vector Database providers such as Apache Cassandra, Azure Vector Search, Chroma, Milvus, MongoDB Atlas, Neo4j, Oracle, PostgreSQL/PGVector, PineCone, Qdrant, Redis, and Weaviate.
- Portable API across Vector Store providers, including a novel SQL-like metadata filter API.
- Tools/Function Calling - permits the model to request the execution of client-side tools and functions, thereby accessing necessary real-time information as required.
- Observability - Provides insights into AI-related operations.
- Document injection ETL framework for Data Engineering.
- AI Model Evaluation - Utilities to help evaluate generated content and protect against hallucinated response.
- ChatClient API - Fluent API for communicating with AI Chat Models, idiomatically similar to the WebClient and RestClient APIs.
- Advisors API - Encapsulates recurring Generative AI patterns, transforms data sent to and from Language Models (LLMs), and provides portability across various models and use cases.
- Support for Chat Conversation Memory and Retrieval Augmented Generation (RAG).
- Spring Boot Auto Configuration and Starters for all AI Models and Vector Stores - use the start.spring.io to select the Model or Vector-store of choice.
Breaking changes
- Refer to the upgrade notes to see how to upgrade to 1.0.0.M1 or higher.
Getting Started
Please refer to the Getting Started Guide for instruction on adding your dependencies.
Cloning the repo
This repository contains large model files. To clone it you have to either:
- Ignore the large files (won't affect the spring-ai behaviour) :
GIT_LFS_SKIP_SMUDGE=1 git clone git@github.com:spring-projects/spring-ai.git
. - Or install the Git Large File Storage before cloning the repo.
Building
To build with running unit tests
./mvnw clean package
To build including integration tests. Set API key environment variables for OpenAI and Azure OpenAI before running.
./mvnw clean verify -Pintegration-tests
To run a specific integration test allowing for up to two attempts to succeed. This is useful when a hosted service is not reliable or times out.
./mvnw -pl vector-stores/spring-ai-pgvector-store -Pintegration-tests -Dfailsafe.rerunFailingTestsCount=2 -Dit.test=PgVectorStoreIT verify
To build the docs
./mvnw -pl spring-ai-docs antora
The docs are then in the directory spring-ai-docs/target/antora/site/index.html
To reformat using the java-format plugin
./mvnw spring-javaformat:apply
To update the year on license headers using the license-maven-plugin
./mvnw license:update-file-header -Plicense
To check javadocs using the javadoc:javadoc
./mvnw javadoc:javadoc -Pjavadoc
To build with checkstyles enabled. Checkstyles are currently disabled, but you can enable them by doing the following:
./mvnw clean package -DskipTests -Ddisable.checks=false
Project Links
<!-- * [Discussions](https://github.com/spring-projects/spring-ai/discussions) - Go here if you have a question, suggestion, or feedback! -->Educational Resources
Spring AI blogs:
- Leverage the Power of 45k, free, Hugging Face Models with Spring AI and Ollama
- Supercharging Your AI Applications with Spring AI Advisors
- Spring AI with NVIDIA LLM API
- Spring AI Embraces OpenAI's Structured Outputs: Enhancing JSON Response Reliability
- Spring AI with Groq - a blazingly fast AI inference engine
- Spring AI with Ollama Tool Support
- Spring AI - Structured Output
- Spring AI - Multimodality - Orbis Sensualium Pictus
- Function Calling in Java and Spring AI using the latest Mistral AI API
- AI Meets Spring Petclinic: Implementing an AI Assistant with Spring AI (Part I)
- AI Meets Spring Petclinic: Implementing an AI Assistant with Spring AI (Part II)
Code Examples
- Flight Booking Assistant - Spring AI powered expert system demo
- Spring AI Chat Bot CLI - chatbot with Retrieval-Augmented Generation (RAG) and conversational memory capabilities
- Spring AI Samples (community driven) Thomas Vitale - Samples showing how to build Java applications powered by Generative AI and Large Language Models (LLMs)
- Spring Ai Examples - (community driven) Craig Walls
- Practical AI examples using Spring AI with UI frontend - (community driven) Marcus Hellberg
Workshops
- Spring AI Zero to Hero Workshop - Example applications showing how to use Spring AI to build Generative AI projects.
- (outdated) Workshop material for Azure OpenAI - contains step-by-step examples from 'hello world' to 'retrieval augmented generation'
Talks and Videos
Some selected videos. Search YouTube! for more.