Upgrade Notes
Upgrading to 1.0.0-SNAPSHOT
Overview
1.0.0-SNAPSHOT 版本包含对工件 ID、包名和模块结构的重大更改。本节提供使用 SNAPSHOT 版本的具体指导。
The 1.0.0-SNAPSHOT version includes significant changes to artifact IDs, package names, and module structure. This section provides guidance specific to using the SNAPSHOT version.
Add Snapshot Repositories
要使用 1.0.0-SNAPSHOT 版本,您需要将快照仓库添加到构建文件中。有关详细说明,请参阅《入门指南》中的 Snapshots - Add Snapshot Repositories 部分。
To use the 1.0.0-SNAPSHOT version, you need to add the snapshot repositories to your build file. For detailed instructions, refer to the Snapshots - Add Snapshot Repositories section in the Getting Started guide.
Update Dependency Management
在您的构建配置中,将 Spring AI BOM 版本更新为 1.0.0-SNAPSHOT
。有关配置依赖管理器的详细说明,请参阅《入门指南》中的 Dependency Management 部分。
Update your Spring AI BOM version to 1.0.0-SNAPSHOT
in your build configuration.
For detailed instructions on configuring dependency management, refer to the Dependency Management section in the Getting Started guide.
Artifact ID, Package, and Module Changes
1.0.0-SNAPSHOT 包含对工件 ID、包名和模块结构的更改。
The 1.0.0-SNAPSHOT includes changes to artifact IDs, package names, and module structure.
有关详细信息,请参阅:- Common Artifact ID Changes - Common Package Changes - Common Module Structure
For details, refer to: - Common Artifact ID Changes - Common Package Changes - Common Module Structure
Upgrading to 1.0.0-RC1
您可以使用 OpenRewrite 配方自动化升级到 1.0.0-RC1 的过程。此配方有助于应用此版本所需的许多代码更改。在 Arconia Spring AI Migrations 查找配方和使用说明。
You can automate the upgrade process to 1.0.0-RC1 using an OpenRewrite recipe. This recipe helps apply many of the necessary code changes for this version. Find the recipe and usage instructions at Arconia Spring AI Migrations.
Breaking Changes
Chat Client and Advisors
影响最终用户代码的主要更改是:
The main changes that impact end user code are:
-
In
VectorStoreChatMemoryAdvisor
:-
常量
CHAT_MEMORY_RETRIEVE_SIZE_KEY
已重命名为TOP_K
。 -
The constant
CHAT_MEMORY_RETRIEVE_SIZE_KEY
has been renamed toTOP_K
. -
常量
DEFAULT_CHAT_MEMORY_RESPONSE_SIZE
(值:100)已重命名为DEFAULT_TOP_K
,新默认值为 20。 -
The constant
DEFAULT_CHAT_MEMORY_RESPONSE_SIZE
(value: 100) has been renamed toDEFAULT_TOP_K
with a new default value of 20.
-
-
常量
CHAT_MEMORY_CONVERSATION_ID_KEY
已重命名为CONVERSATION_ID
,并从AbstractChatMemoryAdvisor
移动到ChatMemory
接口。更新您的导入以使用org.springframework.ai.chat.memory.ChatMemory.CONVERSATION_ID
。 -
The constant
CHAT_MEMORY_CONVERSATION_ID_KEY
has been renamed toCONVERSATION_ID
and moved fromAbstractChatMemoryAdvisor
to theChatMemory
interface. Update your imports to useorg.springframework.ai.chat.memory.ChatMemory.CONVERSATION_ID
.
Self-contained Templates in Advisors
执行提示增强的内置顾问已更新为使用自包含模板。目标是让每个顾问都能够执行模板操作,而不会影响或受其他顾问中的模板和提示决策的影响。
The built-in advisors that perform prompt augmentation have been updated to use self-contained templates. The goal is for each advisor to be able to perform templating operations without affecting nor being affected by templating and prompt decisions in other advisors.
If you were providing custom templates for the following advisors, you’ll need to update them to ensure all expected placeholders are included.
If you were providing custom templates for the following advisors, you’ll need to update them to ensure all expected placeholders are included.
-
QuestionAnswerAdvisor
期望一个包含以下占位符的模板(参见 more details ):-
一个
query
占位符用于接收用户问题。 -
a
query
placeholder to receive the user question. -
一个
question_answer_context
占位符用于接收检索到的上下文。 -
a
question_answer_context
placeholder to receive the retrieved context.
-
-
The
QuestionAnswerAdvisor
expects a template with the following placeholders (see more details):-
一个
query
占位符用于接收用户问题。 -
a
query
placeholder to receive the user question. -
一个
question_answer_context
占位符用于接收检索到的上下文。 -
a
question_answer_context
placeholder to receive the retrieved context.
-
-
PromptChatMemoryAdvisor
期望一个模板,其中包含以下占位符(参见 more details ):-
* 一个
instructions
占位符,用于接收原始系统消息。 -
an
instructions
placeholder to receive the original system message. -
* 一个
memory
占位符,用于接收检索到的对话记忆。 -
a
memory
placeholder to receive the retrieved conversation memory.
-
-
The
PromptChatMemoryAdvisor
expects a template with the following placeholders (see more details):-
* 一个
instructions
占位符,用于接收原始系统消息。 -
an
instructions
placeholder to receive the original system message. -
* 一个
memory
占位符,用于接收检索到的对话记忆。 -
a
memory
placeholder to receive the retrieved conversation memory.
-
-
VectorStoreChatMemoryAdvisor
期望一个模板,其中包含以下占位符(参见 more details ):-
* 一个
instructions
占位符,用于接收原始系统消息。 -
an
instructions
placeholder to receive the original system message. -
* 一个
long_term_memory
占位符,用于接收检索到的对话记忆。 -
a
long_term_memory
placeholder to receive the retrieved conversation memory.
-
-
The
VectorStoreChatMemoryAdvisor
expects a template with the following placeholders (see more details):-
* 一个
instructions
占位符,用于接收原始系统消息。 -
an
instructions
placeholder to receive the original system message. -
* 一个
long_term_memory
占位符,用于接收检索到的对话记忆。 -
a
long_term_memory
placeholder to receive the retrieved conversation memory.
-
Observability
-
重构了内容观察,使用日志记录而不是跟踪( ca843e8 )
-
将内容观察过滤器替换为日志处理程序
-
Replaced content observation filters with logging handlers
-
重命名了配置属性,以更好地反映其用途:
-
include-prompt
→log-prompt
-
include-completion
→log-completion
-
include-query-response
→log-query-response
-
-
-
Renamed configuration properties to better reflect their purpose:
-
include-prompt
→log-prompt
-
include-completion
→log-completion
-
include-query-response
→log-query-response
-
-
* 添加了
TracingAwareLoggingObservationHandler
用于支持跟踪的日志记录。 -
Added
TracingAwareLoggingObservationHandler
for trace-aware logging -
Replaced
micrometer-tracing-bridge-otel
withmicrometer-tracing
-
* 删除了基于事件的跟踪,改为直接日志记录。
-
Removed event-based tracing in favor of direct logging
-
* 删除了对 OTel SDK 的直接依赖。
-
Removed direct dependency on the OTel SDK
-
* 在观察属性中(在
ChatClientBuilderProperties
、ChatObservationProperties
和ImageObservationProperties
中)将includePrompt
重命名为logPrompt
。 -
Renamed
includePrompt
tologPrompt
in observation properties (inChatClientBuilderProperties
,ChatObservationProperties
, andImageObservationProperties
)
-
Refactored content observation to use logging instead of tracing (ca843e8)
-
将内容观察过滤器替换为日志处理程序
-
Replaced content observation filters with logging handlers
-
重命名了配置属性,以更好地反映其用途:
-
include-prompt
→log-prompt
-
include-completion
→log-completion
-
include-query-response
→log-query-response
-
-
-
Renamed configuration properties to better reflect their purpose:
-
include-prompt
→log-prompt
-
include-completion
→log-completion
-
include-query-response
→log-query-response
-
-
* 添加了
TracingAwareLoggingObservationHandler
用于支持跟踪的日志记录。 -
Added
TracingAwareLoggingObservationHandler
for trace-aware logging -
Replaced
micrometer-tracing-bridge-otel
withmicrometer-tracing
-
* 删除了基于事件的跟踪,改为直接日志记录。
-
Removed event-based tracing in favor of direct logging
-
* 删除了对 OTel SDK 的直接依赖。
-
Removed direct dependency on the OTel SDK
-
* 在观察属性中(在
ChatClientBuilderProperties
、ChatObservationProperties
和ImageObservationProperties
中)将includePrompt
重命名为logPrompt
。 -
Renamed
includePrompt
tologPrompt
in observation properties (inChatClientBuilderProperties
,ChatObservationProperties
, andImageObservationProperties
)
Chat Memory Repository Module and Autoconfiguration Renaming
我们通过在整个代码库中添加存储库后缀,标准化了聊天记忆组件的命名模式。此更改影响 Cassandra、JDBC 和 Neo4j 实现,影响工件 ID、Java 包名和类名,以提高清晰度。
We’ve standardized the naming pattern for chat memory components by adding the repository suffix throughout the codebase. This change affects Cassandra, JDBC, and Neo4j implementations, impacting artifact IDs, Java package names, and class names for clarity.
Artifact IDs
所有与记忆相关的工件现在都遵循一致的模式:
All memory-related artifacts now follow a consistent pattern:
-
spring-ai-model-chat-memory-
→spring-ai-model-chat-memory-repository-
-
spring-ai-autoconfigure-model-chat-memory-
→spring-ai-autoconfigure-model-chat-memory-repository-
-
spring-ai-starter-model-chat-memory-
→spring-ai-starter-model-chat-memory-repository-
Java Packages
-
* 包路径现在包含
.repository.
段。 -
Package paths now include
.repository.
segment -
Example:
org.springframework.ai.chat.memory.jdbc
→org.springframework.ai.chat.memory.repository.jdbc
Configuration Classes
-
* 主自动配置类现在使用
Repository
后缀。 -
Main autoconfiguration classes now use the
Repository
suffix -
Example:
JdbcChatMemoryAutoConfiguration
→JdbcChatMemoryRepositoryAutoConfiguration
Properties
-
* 配置属性从
spring.ai.chat.memory.<storage>…​
重命名为spring.ai.chat.memory.repository.<storage>…​
。 -
Configuration properties renamed from
spring.ai.chat.memory.<storage>…
tospring.ai.chat.memory.repository.<storage>…
Migration Required: - 更新您的 Maven/Gradle 依赖项以使用新的工件 ID。- 更新所有使用了旧包或类名的导入、类引用或配置。
Migration Required: - Update your Maven/Gradle dependencies to use the new artifact IDs. - Update any imports, class references, or configuration that used the old package or class names.
Message Aggregator Refactoring
Changes
-
MessageAggregator
类已从spring-ai-client-chat
模块中的org.springframework.ai.chat.model
包移动到spring-ai-model
模块(包名相同)。 -
MessageAggregator
class has been moved fromorg.springframework.ai.chat.model
package in thespring-ai-client-chat
module to thespring-ai-model
module (same package name) -
The
aggregateChatClientResponse
方法已从MessageAggregator
中移除,并移动到org.springframework.ai.chat.client
包中的新类ChatClientMessageAggregator
。 -
The
aggregateChatClientResponse
method has been removed fromMessageAggregator
and moved to a new classChatClientMessageAggregator
in theorg.springframework.ai.chat.client
package
Migration Guide
如果您直接使用 MessageAggregator
中的 aggregateChatClientResponse
方法,则需要改用新的 ChatClientMessageAggregator
类:
If you were directly using the aggregateChatClientResponse
method from MessageAggregator
, you need to use the new ChatClientMessageAggregator
class instead:
// Before
new MessageAggregator().aggregateChatClientResponse(chatClientResponses, aggregationHandler);
// After
new ChatClientMessageAggregator().aggregateChatClientResponse(chatClientResponses, aggregationHandler);
别忘了添加相应的导入:
Don’t forget to add the appropriate import:
import org.springframework.ai.chat.client.ChatClientMessageAggregator;
Watson
Watson AI 模型已被移除,因为它基于旧的文本生成技术,该技术已被认为过时,因为现在有新的聊天生成模型可用。希望 Watson 能在 Spring AI 的未来版本中重新出现。
The Watson AI model was removed as it was based on the older text generation that is considered outdated as there is a new chat generation model available. Hopefully Watson will reappear in a future version of Spring AI
MoonShot and QianFan
Moonshot 和 Qianfan 已被移除,因为它们无法从中国境外访问。它们已被移至 Spring AI 社区仓库。
Moonshot and Qianfan have been removed since they are not accessible from outside China. These have been moved to the Spring AI Community repository.
Memory Management
-
Removed CassandraChatMemory implementation (11e3c8f)
-
简化了聊天内存顾问层级结构并移除了已弃用的 API ( 848a3fd )。
-
Simplified chat memory advisor hierarchy and removed deprecated API (848a3fd)
-
移除了 JdbcChatMemory 中的弃用 ( 356a68f )。
-
Removed deprecations in JdbcChatMemory (356a68f)
-
重构了聊天内存仓库 artifacts 以提高清晰度 ( 2d517ee )。
-
Refactored chat memory repository artifacts for clarity (2d517ee)
-
重构了聊天内存仓库自动配置和 Spring Boot starters 以提高清晰度 ( f6dba1b )。
-
Refactored chat memory repository autoconfigurations and Spring Boot starters for clarity (f6dba1b)
Message and Template APIs
-
移除了已弃用的 UserMessage 构造函数 ( 06edee4 )。
-
Removed deprecated UserMessage constructors (06edee4)
-
移除了已弃用的 PromptTemplate 构造函数 ( 722c77e )。
-
Removed deprecated PromptTemplate constructors (722c77e)
-
移除了 Media 中的已弃用方法 ( 228ef10 )。
-
Removed deprecated methods from Media (228ef10)
-
重构了 StTemplateRenderer:将 supportStFunctions 重命名为 validateStFunctions ( 0e15197 )。
-
Refactored StTemplateRenderer: renamed supportStFunctions to validateStFunctions (0e15197)
-
移除了移动后的 TemplateRender 接口中剩余的部分 ( 52675d8 )。
-
Removed left over TemplateRender interface after moving it (52675d8)
Upgrading to 1.0.0-M8
您可以使用 OpenRewrite 配方自动将升级过程升级到 1.0.0-M8。此配方有助于应用此版本所需的许多代码更改。请在 Arconia Spring AI Migrations 处找到配方和使用说明。
You can automate the upgrade process to 1.0.0-M8 using an OpenRewrite recipe. This recipe helps apply many of the necessary code changes for this version. Find the recipe and usage instructions at Arconia Spring AI Migrations.
Breaking Changes
当从 Spring AI 1.0 M7 升级到 1.0 M8 时,以前注册工具回调的用户会遇到重大更改,导致工具调用功能静默失败。这尤其影响使用已弃用的 tools()
方法的代码。
When upgrading from Spring AI 1.0 M7 to 1.0 M8, users who previously registered tool callbacks are encountering breaking changes that cause tool calling functionality to silently fail. This is specifically impacting code that used the deprecated tools()
method.
Example
以下是一个在 M7 中有效但在 M8 中不再按预期运行的代码示例:
Here’s an example of code that worked in M7 but no longer functions as expected in M8:
// This worked in M7 but silently fails in M8
ChatClient chatClient = new OpenAiChatClient(api)
.tools(List.of(
new Tool("get_current_weather", "Get the current weather in a given location",
new ToolSpecification.ToolParameter("location", "The city and state, e.g. San Francisco, CA", true))
))
.toolCallbacks(List.of(
new ToolCallback("get_current_weather", (toolName, params) -> {
// Weather retrieval logic
return Map.of("temperature", 72, "unit", "fahrenheit", "description", "Sunny");
})
));
Solution
解决方案是使用 toolSpecifications()
方法而不是已弃用的 tools()
方法:
The solution is to use the toolSpecifications()
method instead of the deprecated tools()
method:
// This works in M8
ChatClient chatClient = new OpenAiChatClient(api)
.toolSpecifications(List.of(
new Tool("get_current_weather", "Get the current weather in a given location",
new ToolSpecification.ToolParameter("location", "The city and state, e.g. San Francisco, CA", true))
))
.toolCallbacks(List.of(
new ToolCallback("get_current_weather", (toolName, params) -> {
// Weather retrieval logic
return Map.of("temperature", 72, "unit", "fahrenheit", "description", "Sunny");
})
));
Removed Implementations and APIs
Memory Management
-
Removed CassandraChatMemory implementation (11e3c8f)
-
简化了聊天内存顾问层级结构并移除了已弃用的 API ( 848a3fd )。
-
Simplified chat memory advisor hierarchy and removed deprecated API (848a3fd)
-
移除了 JdbcChatMemory 中的弃用 ( 356a68f )。
-
Removed deprecations in JdbcChatMemory (356a68f)
-
重构了聊天内存仓库 artifacts 以提高清晰度 ( 2d517ee )。
-
Refactored chat memory repository artifacts for clarity (2d517ee)
-
重构了聊天内存仓库自动配置和 Spring Boot starters 以提高清晰度 ( f6dba1b )。
-
Refactored chat memory repository autoconfigurations and Spring Boot starters for clarity (f6dba1b)
Client APIs
-
移除了 ChatClient 和 Advisors 中的弃用 ( 4fe74d8 )。
-
Removed deprecations in ChatClient and Advisors (4fe74d8)
-
对 chatclient 工具调用的重大更改 ( 5b7849d )
-
Breaking changes to chatclient tool calling (5b7849d)
-
移除了 OllamaApi 和 AnthropicApi 中的弃用 ( 46be898 )。
-
Removed deprecations from OllamaApi and AnthropicApi (46be898)
Message and Template APIs
-
移除了已弃用的 UserMessage 构造函数 ( 06edee4 )。
-
Removed deprecated UserMessage constructors (06edee4)
-
移除了已弃用的 PromptTemplate 构造函数 ( 722c77e )。
-
Removed deprecated PromptTemplate constructors (722c77e)
-
移除了 Media 中的已弃用方法 ( 228ef10 )。
-
Removed deprecated methods from Media (228ef10)
-
重构了 StTemplateRenderer:将 supportStFunctions 重命名为 validateStFunctions ( 0e15197 )。
-
Refactored StTemplateRenderer: renamed supportStFunctions to validateStFunctions (0e15197)
-
移除了移动后的 TemplateRender 接口中剩余的部分 ( 52675d8 )。
-
Removed left over TemplateRender interface after moving it (52675d8)
Behavior Changes
Observability
-
重构了内容观察,使用日志记录而不是跟踪( ca843e8 )
-
将内容观察过滤器替换为日志处理程序
-
Replaced content observation filters with logging handlers
-
重命名了配置属性,以更好地反映其用途:
-
include-prompt
→log-prompt
-
include-completion
→log-completion
-
include-query-response
→log-query-response
-
-
-
Renamed configuration properties to better reflect their purpose:
-
include-prompt
→log-prompt
-
include-completion
→log-completion
-
include-query-response
→log-query-response
-
-
* 添加了
TracingAwareLoggingObservationHandler
用于支持跟踪的日志记录。 -
Added
TracingAwareLoggingObservationHandler
for trace-aware logging -
Replaced
micrometer-tracing-bridge-otel
withmicrometer-tracing
-
* 删除了基于事件的跟踪,改为直接日志记录。
-
Removed event-based tracing in favor of direct logging
-
* 删除了对 OTel SDK 的直接依赖。
-
Removed direct dependency on the OTel SDK
-
* 在观察属性中(在
ChatClientBuilderProperties
、ChatObservationProperties
和ImageObservationProperties
中)将includePrompt
重命名为logPrompt
。 -
Renamed
includePrompt
tologPrompt
in observation properties (inChatClientBuilderProperties
,ChatObservationProperties
, andImageObservationProperties
)
-
Refactored content observation to use logging instead of tracing (ca843e8)
-
将内容观察过滤器替换为日志处理程序
-
Replaced content observation filters with logging handlers
-
重命名了配置属性,以更好地反映其用途:
-
include-prompt
→log-prompt
-
include-completion
→log-completion
-
include-query-response
→log-query-response
-
-
-
Renamed configuration properties to better reflect their purpose:
-
include-prompt
→log-prompt
-
include-completion
→log-completion
-
include-query-response
→log-query-response
-
-
* 添加了
TracingAwareLoggingObservationHandler
用于支持跟踪的日志记录。 -
Added
TracingAwareLoggingObservationHandler
for trace-aware logging -
Replaced
micrometer-tracing-bridge-otel
withmicrometer-tracing
-
* 删除了基于事件的跟踪,改为直接日志记录。
-
Removed event-based tracing in favor of direct logging
-
* 删除了对 OTel SDK 的直接依赖。
-
Removed direct dependency on the OTel SDK
-
* 在观察属性中(在
ChatClientBuilderProperties
、ChatObservationProperties
和ImageObservationProperties
中)将includePrompt
重命名为logPrompt
。 -
Renamed
includePrompt
tologPrompt
in observation properties (inChatClientBuilderProperties
,ChatObservationProperties
, andImageObservationProperties
)
Upgrading to 1.0.0-M7
Overview of Changes
Spring AI 1.0.0-M7 是 RC1 和 GA 版本之前的最后一个里程碑版本。它引入了对 artifact ID、包名和模块结构的几项重要更改,这些更改将在最终版本中保留。
Spring AI 1.0.0-M7 is the last milestone release before the RC1 and GA releases. It introduces several important changes to artifact IDs, package names, and module structure that will be maintained in the final release.
Artifact ID, Package, and Module Changes
1.0.0-M7 包含与 1.0.0-SNAPSHOT 相同的结构更改。
The 1.0.0-M7 includes the same structural changes as 1.0.0-SNAPSHOT.
有关详细信息,请参阅:- Common Artifact ID Changes - Common Package Changes - Common Module Structure
For details, refer to: - Common Artifact ID Changes - Common Package Changes - Common Module Structure
MCP Java SDK Upgrade to 0.9.0
Spring AI 1.0.0-M7 现在使用 MCP Java SDK 0.9.0 版,该版本与以前的版本相比有重大更改。如果您在应用程序中使用 MCP,则需要更新代码以适应这些更改。
Spring AI 1.0.0-M7 now uses MCP Java SDK version 0.9.0, which includes significant changes from previous versions. If you’re using MCP in your applications, you’ll need to update your code to accommodate these changes.
主要变化包括:
Key changes include:
Interface Renaming
-
ClientMcpTransport
→McpClientTransport
-
ServerMcpTransport
→McpServerTransport
-
DefaultMcpSession
→McpClientSession
或McpServerSession
-
DefaultMcpSession
→McpClientSession
orMcpServerSession
-
所有
*Registration
类 →*Specification
类 -
All
*Registration
classes →*Specification
classes
Server Creation Changes
-
使用
McpServerTransportProvider
而不是ServerMcpTransport
-
Use
McpServerTransportProvider
instead ofServerMcpTransport
// Before
ServerMcpTransport transport = new WebFluxSseServerTransport(objectMapper, "/mcp/message");
var server = McpServer.sync(transport)
.serverInfo("my-server", "1.0.0")
.build();
// After
McpServerTransportProvider transportProvider = new WebFluxSseServerTransportProvider(objectMapper, "/mcp/message");
var server = McpServer.sync(transportProvider)
.serverInfo("my-server", "1.0.0")
.build();
Handler Signature Changes
所有处理程序现在都接收一个 exchange
参数作为它们的第一个参数:
All handlers now receive an exchange
parameter as their first argument:
// Before
.tool(calculatorTool, args -> new CallToolResult("Result: " + calculate(args)))
// After
.tool(calculatorTool, (exchange, args) -> new CallToolResult("Result: " + calculate(args)))
Client Interaction via Exchange
以前在服务器上可用的方法现在通过交换对象访问:
Methods previously available on the server are now accessed through the exchange object:
// Before
ClientCapabilities capabilities = server.getClientCapabilities();
CreateMessageResult result = server.createMessage(new CreateMessageRequest(...));
// After
ClientCapabilities capabilities = exchange.getClientCapabilities();
CreateMessageResult result = exchange.createMessage(new CreateMessageRequest(...));
Roots Change Handlers
// Before
.rootsChangeConsumers(List.of(
roots -> System.out.println("Roots changed: " + roots)
))
// After
.rootsChangeHandlers(List.of(
(exchange, roots) -> System.out.println("Roots changed: " + roots)
))
有关迁移 MCP 代码的完整指南,请参阅 MCP Migration Guide 。
For a complete guide to migrating MCP code, refer to the MCP Migration Guide.
Enabling/Disabling Model Auto-Configuration
以前用于启用/禁用模型自动配置的配置属性已删除:
The previous configuration properties for enabling/disabling model auto-configuration have been removed:
-
spring.ai.<provider>.chat.enabled
-
spring.ai.<provider>.embedding.enabled
-
spring.ai.<provider>.image.enabled
-
spring.ai.<provider>.moderation.enabled
默认情况下,如果在类路径上找到模型提供程序(例如 OpenAI、Ollama),则其相应模型类型(聊天、嵌入等)的自动配置将启用。如果存在相同模型类型的多个提供程序(例如同时存在 spring-ai-openai-spring-boot-starter
和 spring-ai-ollama-spring-boot-starter
),则可以使用以下属性来选择哪个 which 提供程序的自动配置应该处于活动状态,从而有效地禁用其他提供程序的特定模型类型。
By default, if a model provider (e.g., OpenAI, Ollama) is found on the classpath, its corresponding auto-configuration for relevant model types (chat, embedding, etc.) is enabled. If multiple providers for the same model type are present (e.g., both spring-ai-openai-spring-boot-starter
and spring-ai-ollama-spring-boot-starter
), you can use the following properties to select which provider’s auto-configuration should be active, effectively disabling the others for that specific model type.
要完全禁用特定模型类型的自动配置,即使只有一个提供程序存在,请将相应属性设置为与类路径上任何提供程序都不匹配的值(例如 none
或 disabled
)。
To disable auto-configuration for a specific model type entirely, even if only one provider is present, set the corresponding property to a value that does not match any provider on the classpath (e.g., none
or disabled
).
您可以参考 SpringAIModels
枚举,了解已知提供程序值的列表。
You can refer to the SpringAIModels
enumeration for a list of well-known provider values.
-
spring.ai.model.audio.speech=<model-provider|none>
-
spring.ai.model.audio.transcription=<model-provider|none>
-
spring.ai.model.chat=<model-provider|none>
-
spring.ai.model.embedding=<model-provider|none>
-
spring.ai.model.embedding.multimodal=<model-provider|none>
-
spring.ai.model.embedding.text=<model-provider|none>
-
spring.ai.model.image=<model-provider|none>
-
spring.ai.model.moderation=<model-provider|none>
Automating upgrading using AI
您可以使用 Claude Code CLI 工具和提供的提示自动将升级过程升级到 1.0.0-M7:
You can automate the upgrade process to 1.0.0-M7 using the Claude Code CLI tool with a provided prompt:
-
Download the Claude Code CLI tool
-
从 update-to-m7.txt 文件中复制提示
-
Copy the prompt from the update-to-m7.txt file
-
将提示粘贴到 Claude Code CLI 中
-
Paste the prompt into the Claude Code CLI
-
AI 将分析您的项目并进行必要的更改
-
The AI will analyze your project and make the necessary changes
自动化升级提示目前处理工件 ID 更改、包重定位和模块结构更改,但尚未包含升级到 MCP 0.9.0 的自动更改。如果您正在使用 MCP,您需要按照 MCP Java SDK Upgrade 部分中的指南手动更新您的代码。 |
The automated upgrade prompt currently handles artifact ID changes, package relocations, and module structure changes, but does not yet include automatic changes for upgrading to MCP 0.9.0. If you’re using MCP, you’ll need to manually update your code following the guidance in the MCP Java SDK Upgrade section. |
Common Changes Across Versions
Artifact ID Changes
Spring AI 启动器工件的命名模式已更改。您需要根据以下模式更新您的依赖项:
The naming pattern for Spring AI starter artifacts has changed. You’ll need to update your dependencies according to the following patterns:
-
模型启动器:
spring-ai-{model}-spring-boot-starter
→spring-ai-starter-model-{model}
-
Model starters:
spring-ai-{model}-spring-boot-starter
→spring-ai-starter-model-{model}
-
向量存储启动器:
spring-ai-{store}-store-spring-boot-starter
→spring-ai-starter-vector-store-{store}
-
Vector Store starters:
spring-ai-{store}-store-spring-boot-starter
→spring-ai-starter-vector-store-{store}
-
MCP 启动器:
spring-ai-mcp-{type}-spring-boot-starter
→spring-ai-starter-mcp-{type}
-
MCP starters:
spring-ai-mcp-{type}-spring-boot-starter
→spring-ai-starter-mcp-{type}
Examples
-
Maven
-
Gradle
<!-- BEFORE -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>
<!-- AFTER -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-openai</artifactId>
</dependency>
// BEFORE
implementation 'org.springframework.ai:spring-ai-openai-spring-boot-starter'
implementation 'org.springframework.ai:spring-ai-redis-store-spring-boot-starter'
// AFTER
implementation 'org.springframework.ai:spring-ai-starter-model-openai'
implementation 'org.springframework.ai:spring-ai-starter-vector-store-redis'
Changes to Spring AI Autoconfiguration Artifacts
Spring AI 自动配置已从单个整体工件更改为每个模型、向量存储和其他组件的单独自动配置工件。进行此更改是为了最大程度地减少不同版本的依赖库冲突的影响,例如 Google Protocol Buffers、Google RPC 等。通过将自动配置分离为组件特定的工件,您可以避免引入不必要的依赖项并降低应用程序中版本冲突的风险。
The Spring AI autoconfiguration has changed from a single monolithic artifact to individual autoconfiguration artifacts per model, vector store, and other components. This change was made to minimize the impact of different versions of dependent libraries conflicting, such as Google Protocol Buffers, Google RPC, and others. By separating autoconfiguration into component-specific artifacts, you can avoid pulling in unnecessary dependencies and reduce the risk of version conflicts in your application.
原始的整体工件不再可用:
The original monolithic artifact is no longer available:
<!-- NO LONGER AVAILABLE -->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-spring-boot-autoconfigure</artifactId>
<version>${project.version}</version>
</dependency>
相反,每个组件现在都有自己的自动配置工件,遵循以下模式:
Instead, each component now has its own autoconfiguration artifact following these patterns:
-
Model autoconfiguration:
spring-ai-autoconfigure-model-{model}
-
Vector Store autoconfiguration:
spring-ai-autoconfigure-vector-store-{store}
-
MCP autoconfiguration:
spring-ai-autoconfigure-mcp-{type}
Examples of New Autoconfiguration Artifacts
-
Models
-
Vector Stores
-
MCP
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-model-openai</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-model-anthropic</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-model-vertex-ai</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-vector-store-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-vector-store-pgvector</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-vector-store-chroma</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-mcp-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-autoconfigure-mcp-server</artifactId>
</dependency>
在大多数情况下,您不需要显式添加这些自动配置依赖项。当使用相应的starter依赖项时,它们会通过传递性包含在内。 |
In most cases, you won’t need to explicitly add these autoconfiguration dependencies. They are included transitively when using the corresponding starter dependencies. |
Package Name Changes
您的IDE应该协助重构到新的包位置。
Your IDE should assist with refactoring to the new package locations.
-
KeywordMetadataEnricher
和SummaryMetadataEnricher
已从org.springframework.ai.transformer
移动到org.springframework.ai.chat.transformer
。 -
KeywordMetadataEnricher
andSummaryMetadataEnricher
have moved fromorg.springframework.ai.transformer
toorg.springframework.ai.chat.transformer
. -
Content
、MediaContent
和Media
已从org.springframework.ai.model
移动到org.springframework.ai.content
。 -
Content
,MediaContent
, andMedia
have moved fromorg.springframework.ai.model
toorg.springframework.ai.content
.
Module Structure
该项目对其模块和构件结构进行了重大更改。以前, spring-ai-core
包含了所有核心接口,但现在已将其拆分为专门的领域模块,以减少应用程序中不必要的依赖项。
The project has undergone significant changes to its module and artifact structure. Previously, spring-ai-core
contained all central interfaces, but this has now been split into specialized domain modules to reduce unnecessary dependencies in your applications.

spring-ai-commons
不依赖于其他 Spring AI 模块的基础模块。包含:- 核心领域模型 ( Document
, TextSplitter
) - JSON 实用程序和资源处理 - 结构化日志记录和可观测性支持
Base module with no dependencies on other Spring AI modules. Contains:
- Core domain models (Document
, TextSplitter
)
- JSON utilities and resource handling
- Structured logging and observability support
spring-ai-model
提供 AI 能力抽象:- ChatModel
、 EmbeddingModel
和 ImageModel
等接口 - 消息类型和提示模板 - 函数调用框架 ( ToolDefinition
, ToolCallback
) - 内容过滤和观测支持
Provides AI capability abstractions:
- Interfaces like ChatModel
, EmbeddingModel
, and ImageModel
- Message types and prompt templates
- Function-calling framework (ToolDefinition
, ToolCallback
)
- Content filtering and observation support
spring-ai-vector-store
统一向量数据库抽象:- 用于相似性搜索的 VectorStore
接口 - 使用类 SQL 表达式进行高级过滤 - 用于内存使用的 SimpleVectorStore
- 嵌入的批处理支持
Unified vector database abstraction:
- VectorStore
interface for similarity search
- Advanced filtering with SQL-like expressions
- SimpleVectorStore
for in-memory usage
- Batching support for embeddings
spring-ai-client-chat
高级会话 AI API:- ChatClient
接口 - 通过 ChatMemory
进行会话持久化 - 通过 OutputConverter
进行响应转换 - 基于顾问的拦截 - 同步和响应式流支持
High-level conversational AI APIs:
- ChatClient
interface
- Conversation persistence via ChatMemory
- Response conversion with OutputConverter
- Advisor-based interception
- Synchronous and reactive streaming support
spring-ai-advisors-vector-store
将聊天与向量存储桥接以实现 RAG:- QuestionAnswerAdvisor
:将上下文注入提示 - VectorStoreChatMemoryAdvisor
:存储/检索会话历史记录
Bridges chat with vector stores for RAG:
- QuestionAnswerAdvisor
: injects context into prompts
- VectorStoreChatMemoryAdvisor
: stores/retrieves conversation history
spring-ai-model-chat-memory-cassandra
ChatMemory
的 Apache Cassandra 持久化:- CassandraChatMemory
实现 - 使用 Cassandra 的 QueryBuilder 进行类型安全的 CQL ==== spring-ai-model-chat-memory-neo4j
Apache Cassandra persistence for ChatMemory
:
- CassandraChatMemory
implementation
- Type-safe CQL with Cassandra’s QueryBuilder
==== spring-ai-model-chat-memory-neo4j
用于聊天会话的 Neo4j 图数据库持久化。
Neo4j graph database persistence for chat conversations.
spring-ai-rag
用于检索增强生成 (Retrieval Augmented Generation) 的综合框架:- 用于 RAG 管道的模块化架构 - RetrievalAugmentationAdvisor
作为主要入口点 - 具有可组合组件的函数式编程原则
Comprehensive framework for Retrieval Augmented Generation:
- Modular architecture for RAG pipelines
- RetrievalAugmentationAdvisor
as main entry point
- Functional programming principles with composable components
Dependency Structure
依赖关系层次结构可总结为:
The dependency hierarchy can be summarized as:
-
spring-ai-commons
(foundation) -
spring-ai-model
(depends on commons) -
spring-ai-vector-store
和spring-ai-client-chat
(都依赖于模型) -
spring-ai-vector-store
andspring-ai-client-chat
(both depend on model) -
spring-ai-advisors-vector-store
和spring-ai-rag
(都依赖于 client-chat 和 vector-store) -
spring-ai-advisors-vector-store
andspring-ai-rag
(depend on both client-chat and vector-store) -
spring-ai-model-chat-memory-*
模块 (依赖于 client-chat) -
spring-ai-model-chat-memory-*
modules (depend on client-chat)
ToolContext Changes
ToolContext
类已得到增强,以支持显式和隐式工具解析。工具现在可以是:
The ToolContext
class has been enhanced to support both explicit and implicit tool resolution. Tools can now be:
-
Explicitly Included :在提示中明确请求并包含在模型调用中的工具。
-
Explicitly Included: Tools that are explicitly requested in the prompt and included in the call to the model.
-
Implicitly Available : 运行时动态解析可用的工具,但除非明确请求,否则从不包含在对模型的任何调用中。
-
Implicitly Available: Tools that are made available for runtime dynamic resolution, but never included in any call to the model unless explicitly requested.
从 1.0.0-M7 开始,只有当在提示中明确请求或在调用中明确包含工具时,工具才会被包含在对模型的调用中。
Starting with 1.0.0-M7, tools are only included in the call to the model if they are explicitly requested in the prompt or explicitly included in the call.
此外, ToolContext
类现在已被标记为 final,不能再被扩展。它从未打算被子类化。您可以在实例化 ToolContext
时,以 Map<String, Object>
的形式添加所有需要的上下文数据。有关更多信息,请查看 [文档]([role="bare"] [role="bare"]https://docs.spring.io/spring-ai/reference/api/tools.html#_tool_context )。
Additionally, the ToolContext
class has now been marked as final and cannot be extended anymore. It was never supposed to be subclassed. You can add all the contextual data you need when instantiating a ToolContext
, in the form of a Map<String, Object>
. For more information, check the [documentation]([role="bare"]https://docs.spring.io/spring-ai/reference/api/tools.html#_tool_context).
Upgrading to 1.0.0-M6
Changes to Usage Interface and DefaultUsage Implementation
Usage
接口及其默认实现 DefaultUsage
发生了以下变化:
The Usage
interface and its default implementation DefaultUsage
have undergone the following changes:
-
Method Rename:
-
getGenerationTokens()
is nowgetCompletionTokens()
-
-
Type Changes:
-
DefaultUsage
中的所有令牌计数字段从Long
更改为Integer
:-
promptTokens
-
completionTokens
(formerlygenerationTokens
) -
totalTokens
-
-
-
All token count fields in
DefaultUsage
changed fromLong
toInteger
:-
promptTokens
-
completionTokens
(formerlygenerationTokens
) -
totalTokens
-
Required Actions
-
将所有对
getGenerationTokens()
的调用替换为getCompletionTokens()
-
Replace all calls to
getGenerationTokens()
withgetCompletionTokens()
-
Update
DefaultUsage
constructor calls:
// Old (M5) new DefaultUsage(Long promptTokens, Long generationTokens, Long totalTokens) // New (M6) new DefaultUsage(Integer promptTokens, Integer completionTokens, Integer totalTokens)
有关处理用法的更多信息,请参阅 here |
For more information on handling Usage, refer here |
JSON Ser/Deser changes
虽然 M6 保持了 generationTokens
字段的 JSON 反序列化向后兼容性,但此字段将在 M7 中删除。任何使用旧字段名的持久化 JSON 文档都应更新为使用 completionTokens
。
While M6 maintains backward compatibility for JSON deserialization of the generationTokens
field, this field will be removed in M7. Any persisted JSON documents using the old field name should be updated to use completionTokens
.
新 JSON 格式示例:
Example of the new JSON format:
{
"promptTokens": 100,
"completionTokens": 50,
"totalTokens": 150
}
Changes to usage of FunctionCallingOptions for tool calling
每个 ChatModel
实例在构造时都接受一个可选的 ChatOptions
或 FunctionCallingOptions
实例,用于配置调用模型的默认工具。
Each ChatModel
instance, at construction time, accepts an optional ChatOptions
or FunctionCallingOptions
instance
that can be used to configure default tools used for calling the model.
在 1.0.0-M6 之前:
Before 1.0.0-M6:
-
通过默认
FunctionCallingOptions
实例的functions()
方法传递的任何工具都包含在该ChatModel
实例对模型的每次调用中,并可能被运行时选项覆盖。 -
any tool passed via the
functions()
method of the defaultFunctionCallingOptions
instance was included in each call to the model from thatChatModel
instance, possibly overwritten by runtime options. -
通过默认
FunctionCallingOptions
实例的functionCallbacks()
方法传递的任何工具仅可用于运行时动态解析(请参阅 Tool Resolution ),但除非明确请求,否则从不包含在对模型的任何调用中。 -
any tool passed via the
functionCallbacks()
method of the defaultFunctionCallingOptions
instance was only made available for runtime dynamic resolution (see Tool Resolution), but never included in any call to the model unless explicitly requested.
从 1.0.0-M6 开始:
Starting 1.0.0-M6:
-
通过默认
FunctionCallingOptions
实例的functions()
方法或functionCallbacks()
传递的任何工具现在都以相同的方式处理:它包含在该ChatModel
实例对模型的每次调用中,并可能被运行时选项覆盖。通过这种方式,工具包含在对模型的调用中的方式保持一致,并防止由于functionCallbacks()
和所有其他选项之间的行为差异而造成的任何混淆。 -
any tool passed via the
functions()
method or thefunctionCallbacks()
of the defaultFunctionCallingOptions
instance is now handled in the same way: it is included in each call to the model from thatChatModel
instance, possibly overwritten by runtime options. With that, there is consistency in the way tools are included in calls to the model and prevents any confusion due to a difference in behavior betweenfunctionCallbacks()
and all the other options.
如果您希望工具可用于运行时动态解析,并且仅在明确请求时才将其包含在对模型的聊天请求中,您可以使用 Tool Resolution 中描述的一种策略。
If you want to make a tool available for runtime dynamic resolution and include it in a chat request to the model only when explicitly requested, you can use one of the strategies described in Tool Resolution.
1.0.0-M6 引入了用于处理工具调用的新 API。旧 API 在所有场景下都保持向后兼容性,但上述场景除外。旧 API 仍然可用,但它们已被弃用,并将在 1.0.0-M7 中删除。 |
1.0.0-M6 introduced new APIs for handling tool calling. Backward compatibility is maintained for the old APIs across all scenarios, except the one described above. The old APIs are still available, but they are deprecated and will be removed in 1.0.0-M7. |
Removal of deprecated Amazon Bedrock chat models
从 1.0.0-M6 开始,Spring AI 已过渡到使用 Amazon Bedrock 的 Converse API 进行 Spring AI 中的所有聊天对话实现。所有 Amazon Bedrock 聊天模型都已删除,但 Cohere 和 Titan 的 Embedding 模型除外。
Starting 1.0.0-M6, Spring AI transitioned to using Amazon Bedrock’s Converse API for all Chat conversation implementations in Spring AI. All the Amazon Bedrock Chat models are removed except the Embedding models for Cohere and Titan.
有关使用聊天模型的更多信息,请参阅 Bedrock Converse 文档。 |
Refer to Bedrock Converse documentation for using the chat models. |
Changes to use Spring Boot 3.4.2 for dependency management
Spring AI 更新以使用 Spring Boot 3.4.2 进行依赖管理。您可以参考 here 了解 Spring Boot 3.4.2 管理的依赖项。
Spring AI updates to use Spring Boot 3.4.2 for the dependency management. You can refer here for the dependencies managed by Spring Boot 3.4.2
Required Actions
-
如果您要升级到 Spring Boot 3.4.2,请务必参考 this 文档以了解配置 REST 客户端所需的更改。值得注意的是,如果您的类路径中没有 HTTP 客户端库,这可能会导致使用
JdkClientHttpRequestFactory
,而之前会使用SimpleClientHttpRequestFactory
。要切换到使用SimpleClientHttpRequestFactory
,您需要设置spring.http.client.factory=simple
。 -
If you are upgrading to Spring Boot 3.4.2, please make sure to refer to this documentation for the changes required to configure the REST Client. Notably, if you don’t have an HTTP client library on the classpath, this will likely result in the use of
JdkClientHttpRequestFactory
whereSimpleClientHttpRequestFactory
would have been used previously. To switch to useSimpleClientHttpRequestFactory
, you need to setspring.http.client.factory=simple
. -
如果您使用的是不同版本的 Spring Boot(例如 Spring Boot 3.3.x)并且需要特定版本的依赖项,您可以在构建配置中覆盖它。
-
If you are using a different version of Spring Boot (say Spring Boot 3.3.x) and need a specific version of a dependency, you can override it in your build configuration.
Vector Store API changes
在版本 1.0.0-M6 中, VectorStore
接口中的 delete
方法已修改为 void 操作,而不是返回 Optional<Boolean>
。如果您的代码以前检查了删除操作的返回值,则需要删除此检查。现在,如果删除失败,该操作会抛出异常,从而提供更直接的错误处理。
In version 1.0.0-M6, the delete
method in the VectorStore
interface has been modified to be a void operation instead of returning an Optional<Boolean>
.
If your code previously checked the return value of the delete operation, you’ll need to remove this check.
The operation now throws an exception if the deletion fails, providing more direct error handling.
Upgrading to 1.0.0.M5
-
向量构建器已重构以实现一致性。
-
Vector Builders have been refactored for consistency.
-
当前的 VectorStore 实现构造函数已被弃用,请使用构建器模式。
-
Current VectorStore implementation constructors have been deprecated, use the builder pattern.
-
VectorStore 实现包已移动到唯一的包名称中,避免了跨构件的冲突。例如
org.springframework.ai.vectorstore
到org.springframework.ai.pgvector.vectorstore
。 -
VectorStore implementation packages have been moved into unique package names, avoiding conflicts across artifact. For example
org.springframework.ai.vectorstore
toorg.springframework.ai.pgvector.vectorstore
.
Upgrading to 1.0.0.RC3
-
可移植聊天选项(
frequencyPenalty
、presencePenalty
、temperature
、topP
)的类型已从Float
更改为Double
。 -
The type of the portable chat options (
frequencyPenalty
,presencePenalty
,temperature
,topP
) has been changed fromFloat
toDouble
.
Upgrading to 1.0.0.M2
-
Chroma Vector Store 的配置前缀已从
spring.ai.vectorstore.chroma.store
更改为spring.ai.vectorstore.chroma
,以与其他向量存储的命名约定保持一致。 -
The configuration prefix for the Chroma Vector Store has been changes from
spring.ai.vectorstore.chroma.store
tospring.ai.vectorstore.chroma
in order to align with the naming conventions of other vector stores. -
能够初始化模式的向量存储上
initialize-schema
属性的默认值现在设置为false
。这意味着,如果预期在应用程序启动时创建模式,应用程序现在需要明确选择在支持的向量存储上进行模式初始化。并非所有向量存储都支持此属性。有关详细信息,请参阅相应的向量存储文档。以下是当前不支持initialize-schema
属性的向量存储。[style="arabic"]
-
Hana
-
Pinecone
-
Weaviate
-
The default value of the
initialize-schema
property on vector stores capable of initializing a schema is now set tofalse
. This implies that the applications now need to explicitly opt-in for schema initialization on supported vector stores, if the schema is expected to be created at application startup. Not all vector stores support this property. See the corresponding vector store documentation for more details. The following are the vector stores that currently don’t support theinitialize-schema
property.[style="arabic"]
-
Hana
-
Pinecone
-
Weaviate
-
在 Bedrock Jurassic 2 中,聊天选项
countPenalty
、frequencyPenalty
和presencePenalty
已重命名为countPenaltyOptions
、frequencyPenaltyOptions
和presencePenaltyOptions
。此外,聊天选项stopSequences
的类型已从String[]
更改为List<String>
。 -
In Bedrock Jurassic 2, the chat options
countPenalty
,frequencyPenalty
, andpresencePenalty
have been renamed tocountPenaltyOptions
,frequencyPenaltyOptions
, andpresencePenaltyOptions
. Furthermore, the type of the chat optionstopSequences
have been changed fromString[]
toList<String>
. -
在 Azure OpenAI 中,聊天选项
frequencyPenalty
和presencePenalty
的类型已从Double
更改为Float
,与其他所有实现保持一致。 -
In Azure OpenAI, the type of the chat options
frequencyPenalty
andpresencePenalty
has been changed fromDouble
toFloat
, consistently with all the other implementations.
Upgrading to 1.0.0.M1
在迈向 1.0.0 M1 发布的征程中,我们进行了多项重大更改。抱歉,这是为了更好地发展!
On our march to release 1.0.0 M1 we have made several breaking changes. Apologies, it is for the best!
ChatClient changes
进行了一项重大更改,将“旧的” ChatClient
的功能移至 ChatModel
。新的 ChatClient
现在接受 ChatModel
的实例。这样做是为了支持以类似于 Spring 生态系统中其他客户端类(例如 RestClient
、 WebClient
和 JdbcClient
)的样式创建和执行提示的 Fluent API。有关 Fluent API 的更多信息,请参阅 [JavaDoc]([role="bare"] [role="bare"]https://docs.spring.io/spring-ai/docs/api ),适当的参考文档即将发布。
A major change was made that took the 'old' ChatClient
and moved the functionality into ChatModel
. The 'new' ChatClient
now takes an instance of ChatModel
. This was done to support a fluent API for creating and executing prompts in a style similar to other client classes in the Spring ecosystem, such as RestClient
, WebClient
, and JdbcClient
. Refer to the [JavaDoc]([role="bare"]https://docs.spring.io/spring-ai/docs/api) for more information on the Fluent API, proper reference documentation is coming shortly.
我们将“旧的” ModelClient
重命名为 Model
,并重命名了实现类,例如 ImageClient
重命名为 ImageModel
。 Model
实现表示在 Spring AI API 和底层 AI 模型 API 之间进行转换的可移植性层。
We renamed the 'old' ModelClient
to Model
and renamed implementing classes, for example ImageClient
was renamed to ImageModel
. The Model
implementation represents the portability layer that converts between the Spring AI API and the underlying AI Model API.
以下是使用 Gemini 翻译后的文本:一个新的软件包 model
包含了接口和基类,以支持为任何输入/输出数据类型组合创建 AI 模型客户端。目前,聊天和图像模型软件包已经实现了这一点。我们很快会将嵌入式软件包更新到这个新模型。
A new package model
that contains interfaces and base classes to support creating AI Model Clients for any input/output data type combination. At the moment, the chat and image model packages implement this. We will be updating the embedding package to this new model soon.
以下是使用 Gemini 翻译后的文本:一种新的“便携选项”设计模式。我们希望在 ModelCall
中尽可能地实现跨不同基于聊天的 AI 模型的便携性。有一组通用的生成选项,然后是特定于模型提供商的选项。我们采用了一种“鸭子类型”的方法。 ModelOptions
在模型包中是一个标记接口,表示此类的实现将为模型提供选项。请参阅 ImageOptions
,它是一个子接口,定义了所有文本到图像 ImageModel
实现的便携选项。然后 StabilityAiImageOptions
和 OpenAiImageOptions
提供了特定于每个模型提供商的选项。所有选项类都通过流式 API 构建器创建,所有这些都可以传递给便携式 ImageModel
API。这些选项数据类型用于 ImageModel
实现的自动配置/配置属性。
A new "portable options" design pattern. We wanted to provide as much portability in the ModelCall
as possible across different chat based AI Models. There is a common set of generation options and then those that are specific to a model provider. A sort of "duck typing" approach is used. ModelOptions
in the model package is a marker interface indicating implementations of this class will provide the options for a model. See ImageOptions
, a subinterface that defines portable options across all text→image ImageModel
implementations. Then StabilityAiImageOptions
and OpenAiImageOptions
provide the options specific to each model provider. All options classes are created via a fluent API builder, all can be passed into the portable ImageModel
API. These option data types are used in autoconfiguration/configuration properties for the ImageModel
implementations.
Artifact name changes
使用Gemini翻译后的中文如下:已重命名POM制品名称:- spring-ai-qdrant → spring-ai-qdrant-store- spring-ai-cassandra → spring-ai-cassandra-store- spring-ai-pinecone → spring-ai-pinecone-store- spring-ai-redis → spring-ai-redis-store- spring-ai-qdrant → spring-ai-qdrant-store- spring-ai-gemfire → spring-ai-gemfire-store- spring-ai-azure-vector-store-spring-boot-starter → spring-ai-azure-store-spring-boot-starter- spring-ai-redis-spring-boot-starter → spring-ai-starter-vector-store-redis
Renamed POM artifact names: - spring-ai-qdrant → spring-ai-qdrant-store - spring-ai-cassandra → spring-ai-cassandra-store - spring-ai-pinecone → spring-ai-pinecone-store - spring-ai-redis → spring-ai-redis-store - spring-ai-qdrant → spring-ai-qdrant-store - spring-ai-gemfire → spring-ai-gemfire-store - spring-ai-azure-vector-store-spring-boot-starter → spring-ai-azure-store-spring-boot-starter - spring-ai-redis-spring-boot-starter → spring-ai-starter-vector-store-redis
Upgrading to 0.8.1
之前的 spring-ai-vertex-ai
已重命名为 spring-ai-vertex-ai-palm2
,spring-ai-vertex-ai-spring-boot-starter
已重命名为 spring-ai-vertex-ai-palm2-spring-boot-starter
。
Former spring-ai-vertex-ai
has been renamed to spring-ai-vertex-ai-palm2
and spring-ai-vertex-ai-spring-boot-starter
has been renamed to spring-ai-vertex-ai-palm2-spring-boot-starter
.
因此,您需要将依赖项从
So, you need to change the dependency from
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai</artifactId>
</dependency>
更改为
To
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai-palm2</artifactId>
</dependency>
Palm2 模型的关联 Boot starter 已从
and the related Boot starter for the Palm2 model has changed from
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai-spring-boot-starter</artifactId>
</dependency>
更改为
to
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-vertex-ai-palm2-spring-boot-starter</artifactId>
</dependency>
-
Renamed Classes (01.03.2024)
-
VertexAiApi → VertexAiPalm2Api
-
VertexAiClientChat → VertexAiPalm2ChatClient
-
VertexAiEmbeddingClient → VertexAiPalm2EmbeddingClient
-
VertexAiChatOptions → VertexAiPalm2ChatOptions
-
Upgrading to 0.8.0
January 24, 2024 Update
-
将
prompt
、messages
和metadata
包移动到org.springframework.ai.chat
的子包中。 -
Moving the
prompt
andmessages
andmetadata
packages to subpackages oforg.springframework.ai.chat
-
新功能适用于 text to image 客户端。类是
OpenAiImageModel
和StabilityAiImageModel
。有关用法,请参阅集成测试,文档即将推出。 -
New functionality is text to image clients. Classes are
OpenAiImageModel
andStabilityAiImageModel
. See the integration tests for usage, docs are coming soon. -
以下是使用 Gemini 翻译后的文本:一个新的软件包
model
包含了接口和基类,以支持为任何输入/输出数据类型组合创建 AI 模型客户端。目前,聊天和图像模型软件包已经实现了这一点。我们很快会将嵌入式软件包更新到这个新模型。 -
A new package
model
that contains interfaces and base classes to support creating AI Model Clients for any input/output data type combination. At the moment, the chat and image model packages implement this. We will be updating the embedding package to this new model soon. -
一种新的“可移植选项”设计模式。我们希望在
ModelCall
中提供尽可能多的可移植性,以适应不同的基于聊天的 AI 模型。有一组通用的生成选项,然后是特定于模型提供者的选项。采用了一种“鸭子类型”方法。模型包中的ModelOptions
是一个标记接口,表示此类的实现将为模型提供选项。请参阅ImageOptions
,这是一个子接口,定义了所有文本到图像ImageModel
实现中的可移植选项。然后StabilityAiImageOptions
和OpenAiImageOptions
提供特定于每个模型提供者的选项。所有选项类都是通过流式 API 构建器创建的,所有这些都可以传递到可移植的ImageModel
API 中。这些选项数据类型用于ImageModel
实现的自动配置/配置属性。 -
A new "portable options" design pattern. We wanted to provide as much portability in the
ModelCall
as possible across different chat based AI Models. There is a common set of generation options and then those that are specific to a model provider. A sort of "duck typing" approach is used.ModelOptions
in the model package is a marker interface indicating implementations of this class will provide the options for a model. SeeImageOptions
, a subinterface that defines portable options across all text→imageImageModel
implementations. ThenStabilityAiImageOptions
andOpenAiImageOptions
provide the options specific to each model provider. All options classes are created via a fluent API builder, all can be passed into the portableImageModel
API. These option data types are used in autoconfiguration/configuration properties for theImageModel
implementations.
January 13, 2024 Update
以下 OpenAi 自动配置聊天属性已更改
The following OpenAi Autoconfiguration chat properties have changed
-
from
spring.ai.openai.model
tospring.ai.openai.chat.options.model
. -
from
spring.ai.openai.temperature
tospring.ai.openai.chat.options.temperature
.
查找有关 OpenAi 属性的更新文档:[role="bare"] [role="bare"]https://docs.spring.io/spring-ai/reference/api/chat/openai-chat.html
Find updated documentation about the OpenAi properties: [role="bare"]https://docs.spring.io/spring-ai/reference/api/chat/openai-chat.html
December 27, 2023 Update
将 SimplePersistentVectorStore 和 InMemoryVectorStore 合并到 SimpleVectorStore* 中,用 SimpleVectorStore 替换 InMemoryVectorStore
Merge SimplePersistentVectorStore and InMemoryVectorStore into SimpleVectorStore * Replace InMemoryVectorStore with SimpleVectorStore
December 20, 2023 Update
重构 Ollama 客户端和相关类及包名
Refactor the Ollama client and related classes and package names
-
将 org.springframework.ai.ollama.client.OllamaClient 替换为 org.springframework.ai.ollama.OllamaModelCall。
-
Replace the org.springframework.ai.ollama.client.OllamaClient by org.springframework.ai.ollama.OllamaModelCall.
-
OllamaChatClient 方法签名已更改。
-
The OllamaChatClient method signatures have changed.
-
将 org.springframework.ai.autoconfigure.ollama.OllamaProperties 重命名为 org.springframework.ai.model.ollama.autoconfigure.OllamaChatProperties,并将后缀更改为:
spring.ai.ollama.chat
。一些属性也已更改。 -
Rename the org.springframework.ai.autoconfigure.ollama.OllamaProperties into org.springframework.ai.model.ollama.autoconfigure.OllamaChatProperties and change the suffix to:
spring.ai.ollama.chat
. Some of the properties have changed as well.
December 19, 2023 Update
对 AiClient 及相关类和包名进行重命名
Renaming of AiClient and related classes and package names
-
Rename AiClient to ChatClient
-
Rename AiResponse to ChatResponse
-
Rename AiStreamClient to StreamingChatClient
-
将包 org.sf.ai.client 重命名为 org.sf.ai.chat。
-
Rename package org.sf.ai.client to org.sf.ai.chat
重命名构件 ID
Rename artifact ID of
-
transformers-embedding
tospring-ai-transformers
已将 Maven 模块从顶级目录和 embedding-clients
子目录移到单个 models
目录下。
Moved Maven modules from top-level directory and embedding-clients
subdirectory to all be under a single models
directory.
December 1, 2023
我们正在转换该项目的 Group ID:
We are transitioning the project’s Group ID:
-
FROM:
org.springframework.experimental.ai
-
TO:
org.springframework.ai
构件仍将托管在快照存储库中,如下所示。
Artifacts will still be hosted in the snapshot repository as shown below.
主分支将移动到版本 0.8.0-SNAPSHOT
。它将在未来一两周内不稳定。如果您不想在 bleeding edge 上,请使用 0.7.1-SNAPSHOT。
The main branch will move to the version 0.8.0-SNAPSHOT
.
It will be unstable for a week or two.
Please use the 0.7.1-SNAPSHOT if you don’t want to be on the bleeding edge.
您可以像以前一样访问 `0.7.1-SNAPSHOT`工件,还可以访问 0.7.1-SNAPSHOT Documentation。
You can access 0.7.1-SNAPSHOT
artifacts as before and still access 0.7.1-SNAPSHOT Documentation.
0.7.1-SNAPSHOT Dependencies
-
Azure OpenAI[source, xml]
<dependency> <groupId>org.springframework.experimental.ai</groupId> <artifactId>spring-ai-azure-openai-spring-boot-starter</artifactId> <version>0.7.1-SNAPSHOT</version> </dependency>
-
OpenAI[source, xml]
<dependency> <groupId>org.springframework.experimental.ai</groupId> <artifactId>spring-ai-openai-spring-boot-starter</artifactId> <version>0.7.1-SNAPSHOT</version> </dependency>