refactor: Simplify chat memory advisor hierarchy and remove deprecated API
- Remove deprecated ChatMemory.get(String conversationId, int lastN) method - Replace AbstractChatMemoryAdvisor with BaseChatMemoryAdvisor interface in api package - Make constructors private in all memory advisor implementations to enforce builder usage - Rename CHAT_MEMORY_CONVERSATION_ID_KEY to CONVERSATION_ID and move to ChatMemory interface - In VectorStoreChatMemoryAdvisor: - Rename DEFAULT_CHAT_MEMORY_RESPONSE_SIZE (100) to DEFAULT_TOP_K (20) - Rename builder method chatMemoryRetrieveSize() to topK() - Remove systemTextAdvise() builder method - In PromptChatMemoryAdvisor: - Remove systemTextAdvise() builder method - Fix bug where only the last user message was stored from prompts with multiple messages - Enhance logging in memory advisors to aid in debugging - Add comprehensive tests for all advisor implementations: - Unit tests for builder behavior - Integration tests for the various chat memory advisors Signed-off-by: Mark Pollack <mark.pollack@broadcom.com>
This commit is contained in:
@@ -428,8 +428,8 @@ A sample `@Service` implementation that uses several advisors is shown below.
|
||||
|
||||
[source,java]
|
||||
----
|
||||
import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_CONVERSATION_ID_KEY;
|
||||
import static org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor.CHAT_MEMORY_RETRIEVE_SIZE_KEY;
|
||||
import static org.springframework.ai.chat.memory.ChatMemory.CHAT_MEMORY_CONVERSATION_ID_KEY;
|
||||
import static org.springframework.ai.chat.client.advisor.vectorstore.VectorStoreChatMemoryAdvisor.CHAT_MEMORY_RETRIEVE_SIZE_KEY;
|
||||
|
||||
@Service
|
||||
public class CustomerSupportAssistant {
|
||||
|
||||
@@ -29,12 +29,19 @@ For details, refer to:
|
||||
[[upgrading-to-1-0-0-RC1]]
|
||||
== Upgrading to 1.0.0-RC1
|
||||
|
||||
=== Chat Client And Advisors
|
||||
=== Chat ClientAnd Advisors
|
||||
|
||||
* When building a `Prompt` from the ChatClient input, the `SystemMessage` built from `systemText()` is now placed first in the message list. Before, it was put last, resulting in errors with several model providers.
|
||||
* In `AbstractChatMemoryAdvisor`, the `doNextWithProtectFromBlockingBefore()` protected method has been changed from accepting the old `AdvisedRequest` to the new `ChatClientRequest`. It’s a breaking change since the alternative was not part of M8.
|
||||
* `MessageAggregator` has a new method to aggregate messages from `ChatClientRequest`. The previous method aggregating messages from the old `AdvisedRequest` has been removed, since it was already marked as deprecated in M8.
|
||||
* In `SimpleLoggerAdvisor`, the `requestToString` input argument needs to be updated to use `ChatClientRequest`. It’s a breaking change since the alternative was not part of M8 yet. Same thing about the constructor.
|
||||
* In `SimpleLoggerAdvisor`, the `requestToString` input argument needs to be updated to use `ChatClientRequest`. It's a breaking change since the alternative was not part of M8 yet. Same thing about the constructor.
|
||||
* `AbstractChatMemoryAdvisor` has been replaced with a `BaseChatMemoryAdvisor` interface in the `api` package. This is a breaking change for any code that directly extended `AbstractChatMemoryAdvisor`.
|
||||
* Public constructors in `MessageChatMemoryAdvisor`, `PromptChatMemoryAdvisor`, and `VectorStoreChatMemoryAdvisor` have been made private. You must now use the builder pattern to create instances (e.g., `MessageChatMemoryAdvisor.builder(chatMemory).build()`).
|
||||
* The constant `CHAT_MEMORY_CONVERSATION_ID_KEY` has been renamed to `CONVERSATION_ID` and moved from `AbstractChatMemoryAdvisor` to the `ChatMemory` interface. Update your imports to use `org.springframework.ai.chat.memory.ChatMemory.CONVERSATION_ID`.
|
||||
* In `VectorStoreChatMemoryAdvisor`:
|
||||
** The constant `DEFAULT_CHAT_MEMORY_RESPONSE_SIZE` (value: 100) has been renamed to `DEFAULT_TOP_K` with a new default value of 20.
|
||||
** The builder method `chatMemoryRetrieveSize(int)` has been renamed to `topK(int)`. Update your code to use the new method name: `VectorStoreChatMemoryAdvisor.builder(store).topK(1).build()`.
|
||||
** The `systemTextAdvise(String)` builder method has been removed. Use the `systemPromptTemplate(PromptTemplate)` method instead.
|
||||
* In `PromptChatMemoryAdvisor`, the `systemTextAdvise(String)` builder method has been removed. Use the `systemPromptTemplate(PromptTemplate)` method instead.
|
||||
|
||||
==== Self-contained Templates in Advisors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user