1.0.3
Spring AI 1.0.3 正式发布,累计合并 30 个提交,涉及 239 个文件(+2,524 / -532 行),主要聚焦于稳定性增强、IDE 开发体验改进及多项缺陷修复。
核心变更
BedrockChatOptions —— 类型化配置
Bedrock Converse 新增独立的 BedrockChatOptions 类,支持 Builder 模式,字段涵盖 model、temperature、maxTokens、topP、topK、stopSequences、frequencyPenalty、presencePenalty 等。Bedrock 用户现可通过类型化 Options 对象替代内联属性进行聊天配置。
OpenAiApi 可注入为 Spring Bean
OpenAiChatAutoConfiguration 将 OpenAiApi 作为独立的 @Bean 暴露,用户可直接注入 OpenAiApi 实例,用于配置多个 OpenAI 兼容的 ChatClient。
@Autowired
private OpenAiApi openAiApi;
// 基于同一 API 实例创建多个不同配置的 ChatClient
ChatClient client1 = ChatClient.builder(
OpenAiChatModel.builder().openAiApi(openAiApi).build()
).build();
IDE 自动补全增强
重构了 32 个自动配置属性类中的 @NestedConfigurationProperty 字段,将所有嵌套属性改为 final 并移除 setter,使 IDE 在 application.properties / application.yml 中的配置项补全完全正确。
GemFire VectorStore —— 过滤器支持
新增 GemFireAiSearchFilterExpressionConverter,可将 Spring AI Filter 表达式转换为 GemFire OQL WHERE 子句,支持按元数据属性进行向量搜索过滤。
Bug Fix 汇总
| 问题 | 修复 |
|---|---|
| OpenAI 流式工具调用合并时数组越界 | 修复 ArrayIndexOutOfBoundsException |
| PromptTemplate Resource 参数处理不一致 | render(Map) 现在正确解析 Resource 变量 |
JsonSchemaGenerator 生成多余 format 属性 | 移除 OpenAPI format 字段,兼容 Mistral AI |
| Anthropic StreamHelper 健壮性 | 增强 mergeToolUseEvents 非预期事件处理,修复 thinkingBlock.signature() |
| Jackson 模块加载失败 | 不再使用 Thread Context ClassLoader 加载 Jackson 模块 |
| 工具执行异常返回空白消息 | 新增兜底消息机制,避免静默失败 |
| ChatMemory 文档示例错误 | 修正 CassandraChatMemoryRepository 示例代码 |
基础设施
- AOT / GraalVM Native ——
AbstractEmbeddingModel重构以提升 AOT 兼容性,OpenAiRuntimeHints完善原生镜像提示注册 - CosmosDB VectorStore —— 重构
initializeContainer方法,移除冗余参数 - DeepSeekChatModel —— 修正 Builder 模式初始化
Spring AI 1.0.3 延续了维护分支的稳定节奏,在 IDE 体验、Bedrock 类型安全和流式工具调用可靠性方面更进一步。