Thomas Vitale 0024e4dd49 Chat Memory Enhancements
* ChatMemory will become a generic interface to implement different memory management strategies. It’s been moved from the “”spring-ai-client-chat” package to “spring-ai-model” package while retaining the same package, so it’s transparent to users.
* A MessageWindowChatMemory has been introduced to provide support for a chat memory that keeps at most N messages in the memory.
* A ChatMemoryRepository interface has been introduced to support different storage strategies for the chat memory. It’s meant to be used as part of a ChatMemory implementation. This is different than before, where the storage-specific implementation was directly tied to the ChatMemory. This design is familiar to Spring users since it’s used already in the ecosystem. The goal was to use a programming model similar to Spring Session and Spring Data.
* The JdbcChatMemory has been supersed by JdbcChatMemoryRepository.
* A ChatMemory bean is auto-configured for you whenever using one of the Spring AI Model starters. By default, it uses the MessageWindowChatMemory implementation and stores the conversation history in memory. If a different repository is already configured (e.g., Cassandra, JDBC, or Neo4j), Spring AI will use that instead.
* First-class documentation has been introduced to describe the ChatMemory API and related features.
* All the changes introduced in this PR are backward-compatible.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-04-25 15:53:20 -04:00
2024-10-24 16:43:59 -04:00
2024-10-24 16:43:59 -04:00
2025-04-25 15:53:20 -04:00
2025-04-25 15:53:20 -04:00
2025-04-25 15:53:20 -04:00
2025-04-25 15:53:20 -04:00
2025-04-25 15:53:20 -04:00
2025-04-10 20:23:38 +01:00
2025-04-10 20:23:38 +01:00
2024-10-24 16:43:59 -04:00
2023-07-24 19:37:06 -04:00
2024-10-24 16:43:59 -04:00
2023-07-24 19:37:06 -04:00
2025-04-25 15:53:20 -04:00
2024-10-24 20:31:19 -04:00

Spring AI build status build status

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.

spring-ai-integration-diagram-3

At its core, Spring AI addresses the fundamental challenge of AI integration: Connecting your enterprise Data and APIs with the AI Models.

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.

You can check out the blog post Why Spring AI for additional motivations.

This is a high level feature overview. You can find more details in the Reference Documentation

Getting Started

Please refer to the Getting Started Guide for instruction on adding your dependencies.

Project Resources

  • Awesome Spring AI - A curated list of awesome resources, tools, tutorials, and projects for building generative AI applications using Spring AI
  • Spring AI Examples contains example projects that explain specific features in more detail.

Breaking changes

  • Refer to the upgrade notes to see how to upgrade to 1.0.0.M1 or higher.

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.

./mvnw clean verify -Pintegration-tests

Note that you should set API key environment variables for OpenAI or other model providers before running. If the API key isn't set for a specific model provider, the integration test is skipped.

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

Integration Tests

There are many integration tests ,so it often isn't realistic to run them all at once.

A quick pass through the most important pathways that runs integration tests for

  • OpenAI models
  • OpenAI autoconfiguration
  • PGVector
  • Chroma

can be done with the profile -Pci-fast-integration-tests and is used in the main CI build of this project.

A full integration test is done twice a day in the Spring AI Integration Test Repository

One way to run integration tests on part of the code is to first do a quick compile and install of the project

./mvnw clean install -DskipTests -Dmaven.javadoc.skip=true

Then run the integration test for a specific module using the -pl option

./mvnw verify -Pintegration-tests -pl spring-ai-spring-boot-testcontainers

Documentation

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
Description
No description provided
Readme 87 MiB
Languages
Java 99.5%
Kotlin 0.3%