Add ai-21-migration module: upgrading Spring AI 2.0.x to 2.1.0, measured. One probe source tree run on 2.0.0, 2.0.2, 2.0.3 and 2.1.0 (Anthropic prompt tokens with caching, auth header, discarded temperature, thinking parts, message mutability, entity() on refusals), three compile breaks, API and configuration diffs from the jars, ChatMemory to session copy, a wrapping ToolCallingManager under tool confirmation, the OpenAI Responses switch, VectorStore.upsert on real pgvector, a grep checklist and an OpenRewrite recipe. Scripted and local fake models; no provider called. Spring Boot 4.2.0, Spring AI 2.1.0, Java 25.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7N4ZDbUtA3ofqAqRV
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# rewrite-maven-plugin 6.46.1 + rewrite-spring 6.37.1 with rewrite.yml on a copy of legacy-app
|
||||
compile before (Boot 4.1.0, Spring AI 2.0.0): ok
|
||||
--- before/pom.xml
|
||||
+++ app/pom.xml
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
- <version>4.1.0</version>
|
||||
+ <version>4.2.0</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<properties>
|
||||
<java.version>25</java.version>
|
||||
- <spring-ai.version>2.0.0</spring-ai.version>
|
||||
+ <spring-ai.version>2.1.0</spring-ai.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -44,7 +44,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
- <artifactId>spring-ai-autoconfigure-model-chat-memory-redis</artifactId>
|
||||
+ <artifactId>spring-ai-autoconfigure-model-chat-memory-repository-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
--- before/src/main/java/com/ankurm/legacy/SupportBot.java
|
||||
+++ app/src/main/java/com/ankurm/legacy/SupportBot.java
|
||||
@@ -3,6 +3,7 @@
|
||||
import org.springframework.ai.anthropic.AnthropicChatOptions;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
|
||||
+import org.springframework.ai.chat.client.advisor.api.MemoryAdvisor;
|
||||
import org.springframework.ai.chat.memory.ChatMemory;
|
||||
import org.springframework.ai.chat.metadata.Usage;
|
||||
|
||||
@@ -13,7 +14,7 @@
|
||||
.build()
|
||||
.prompt()
|
||||
.user(question)
|
||||
- .advisors(a -> a.param(ChatMemory.CONVERSATION_ID, user))
|
||||
+ .advisors(a -> a.param(MemoryAdvisor.CONVERSATION_ID, user))
|
||||
.call()
|
||||
.content();
|
||||
}
|
||||
@@ -21,8 +22,6 @@
|
||||
public AnthropicChatOptions options() {
|
||||
return AnthropicChatOptions.builder()
|
||||
.model("claude-sonnet-4-5")
|
||||
- .temperature(0.2)
|
||||
- .topK(40)
|
||||
.maxTokens(1024)
|
||||
.build();
|
||||
}
|
||||
--- before/src/main/resources/application.properties
|
||||
+++ app/src/main/resources/application.properties
|
||||
@@ -1,3 +1,2 @@
|
||||
-spring.ai.anthropic.chat.temperature=0.2
|
||||
-spring.ai.chat.memory.redis.host=localhost
|
||||
+spring.ai.chat.memory.repository.redis.host=localhost
|
||||
spring.ai.chat.memory.repository.jdbc.initialize-schema=always
|
||||
compile after (Boot 4.2.0, Spring AI 2.1.0): ok
|
||||
|
||||
both recipes in one invocation, sampling calls left in SupportBot.java:
|
||||
25: .temperature(0.2)
|
||||
26: .topK(40)
|
||||
Reference in New Issue
Block a user