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,33 @@
|
||||
package com.ankurm.legacy;
|
||||
|
||||
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.memory.ChatMemory;
|
||||
import org.springframework.ai.chat.metadata.Usage;
|
||||
|
||||
public class SupportBot {
|
||||
|
||||
public String ask(ChatClient.Builder builder, ChatMemory memory, String user, String question) {
|
||||
return builder.defaultAdvisors(MessageChatMemoryAdvisor.builder(memory).build())
|
||||
.build()
|
||||
.prompt()
|
||||
.user(question)
|
||||
.advisors(a -> a.param(ChatMemory.CONVERSATION_ID, user))
|
||||
.call()
|
||||
.content();
|
||||
}
|
||||
|
||||
public AnthropicChatOptions options() {
|
||||
return AnthropicChatOptions.builder()
|
||||
.model("claude-sonnet-4-5")
|
||||
.temperature(0.2)
|
||||
.topK(40)
|
||||
.maxTokens(1024)
|
||||
.build();
|
||||
}
|
||||
|
||||
public long billableInput(Usage usage) {
|
||||
return usage.getPromptTokens() + usage.getCacheReadInputTokens() + usage.getCacheWriteInputTokens();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user