Commit Graph

21 Commits

Author SHA1 Message Date
enricorampazzo
43aa8939d2 Enhance Neo4jChatMemoryRepository, expand integration tests, improve configuration, and update documentation
- Enhanced Neo4jChatMemoryRepository to correctly restore custom metadata for SystemMessage using SystemMessage.Builder.
- Refactored and clarified Neo4jChatMemoryRepository implementation code.
- Added comprehensive integration tests for Neo4jChatMemoryConfig and Neo4jChatMemoryRepository, including:
-- Index creation verification
-- Custom label support
-- Getter validation for all configuration properties
-- Tests for saving and retrieving SystemMessage metadata
-- Tests ensuring saveAll(conversationId, Collections.emptyList()) clears all messages and removes the conversation node
-- Tests for handling of messages with empty content and empty metadata
-- Improved overall test coverage for Neo4j persistence and configuration edge cases
- Fixed resource management bugs in test classes (ensured proper driver/session closure).
- Improved index creation logic in Neo4jChatMemoryConfig for reliability and logging.
- Updated documentation to include Neo4jChatMemoryRepository usage and configuration

Signed-off-by: enricorampazzo <enrico.rampazzo@live.com>
Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
2025-05-06 15:31:11 -04:00
enricorampazzo
4ec067641b updates from spring-ai
Signed-off-by: enricorampazzo <enrico.rampazzo@live.com>
2025-05-06 15:31:11 -04:00
Thomas Vitale
356a68f15e Remove deprecations in JdbcChatMemory
* Remove deprecated APIs for JdbcChatMemory.
* Improve documentation about chat memory vs. chat history.
* Fix mismatch between docs vs code for max messages in MessageWindowChatMemory.

Signed-off-by: Thomas Vitale <ThomasVitale@users.noreply.github.com>
2025-05-06 00:40:08 -04:00
Ilayaperumal Gopinathan
228ef10bfb Remove deprecated methods from Media
- Remove deprecated constructor method Media(MimeType mimeType, URL url) from Media
 - Remove deprecated builder method data(URL url) from Media builder
 - Update references to use the builder and the data(URI) methods

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-05 01:47:45 +01:00
Ilayaperumal Gopinathan
06edee4069 Remove deprecated UserMessage constructors
- Remove deprecated constructor methods
 - Replace them with the builder methods

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-05-05 01:06:21 +01:00
Ilayaperumal Gopinathan
3acc206eb2 Next development version 2025-04-30 17:51:20 +01:00
Ilayaperumal Gopinathan
b657cf3bae Release version 1.0.0-M8 2025-04-30 17:51:07 +01:00
Linar Abzaltdinov
a1db00ab1e Fixed message order for JDBC Chat Memory
- set timestamp manually to prevent saving equal timestamps while batch insert
- return DESC order into get query (in `JdbcChatMemory`)
- Update similar changes for JdbcChatMemoryRepository

This PR solves some problems with message ordering:

JdbcChatMemory fetches rows in DESC order, and MessageChatMemoryAdvisor get and add all messages in that order - from last to first. So messages list needs to be reversed.
After batch insert without specifying timestamp manually all rows have the same timestamp (because database sets current_timestamp by default). Sooo after fetching rows from database the message order is unpredictable - they have same timestamp.

Signed-off-by: Linar Abzaltdinov <abzaltdinov@gmail.com>
2025-04-29 16:04:32 +01:00
Linar Abzaltdinov
1bf5787865 Fix message order in Cassandra chat memory after retrieving from db
Fixes: https://github.com/spring-projects/spring-ai/issues/2815

Added integration tests

Replaced deprecated CassandraContainer test-container by actual one

Reordered imports in CassandraChatMemoryIT

Signed-off-by: Linar Abzaltdinov <abzaltdinov@gmail.com>

Fixing CassandraChatMemoryAutoConfigurationIT for the correct ordering

Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-04-28 20:20:10 -04:00
Eddú Meléndez Gonzales
22c778f8cc Switch CassandraContainer implementation (#2663)
`org.testcontainers.containers.CassandraContainer` is deprecated.

Signed-off-by: Eddú Meléndez <eddu.melendez@gmail.com>
2025-04-28 17:08:27 +01:00
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
Soby Chacko
d9e7ace996 Miscellaneous checkstyle fixes
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-04-14 09:48:03 +01:00
Ilayaperumal Gopinathan
853d478bca Add SCM URL to the chat memory POM files
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-10 22:34:38 +01:00
Ilayaperumal Gopinathan
442b2e9156 Update project URL in the POM files for chat memory modules
Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
2025-04-10 22:34:29 +01:00
Ilayaperumal Gopinathan
bda702e8e1 Next development version 2025-04-10 20:23:38 +01:00
Ilayaperumal Gopinathan
584138af28 Release version 1.0.0-M7 2025-04-10 20:23:07 +01:00
leijendary
4be10028b0 feat: JDBC implementation of ChatMemory
Signed-off-by: leijendary <jonathanleijendekker@gmail.com>

Remove references to spring-ai-core module in jdbc chat memory
2025-04-07 15:08:58 -04:00
Ilayaperumal Gopinathan
b4fa31188a Refactoring cleanup
- Update Spring AI BOM with the newly added modules
 - Remove unnecessary dependencies from the modules' POM file
2025-04-04 12:43:22 -04:00
Soby Chacko
717e419515 Rename spring-ai parent from spring-ai to spring-ai-parent
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-04-04 12:43:22 -04:00
Soby Chacko
f7f00328a1 Migrate Cassandra chat memory implementation to its own module
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
2025-04-04 11:44:38 -04:00
Mark Pollack
d45ff8e984 Refactorings
- Avoid overlapping package names
  Changed in spring-ai-commons package from org.sf.ai.model to org.sf.ai.content
  Refactor advisor module name to be spring-ai-advisors-vector-store
    Moved advisors into org.springframework.ai.chat.client.advisor.vectorstore

- Created top level memory directory
- Create new module spring-ai-model-chat-memory-neo4j and moved neo4j memory classes out of the vectorstore module
  Updated neo4j autoconfiguation
2025-04-04 11:44:38 -04:00