前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >聊聊Spring AI 1.0.0-SNAPSHOT的变更

聊聊Spring AI 1.0.0-SNAPSHOT的变更

作者头像
code4it
发布于 2025-05-08 05:53:00
发布于 2025-05-08 05:53:00
7700
代码可运行
举报
文章被收录于专栏:码匠的流水账码匠的流水账
运行总次数:0
代码可运行

本文主要研究一下Spring AI 1.0.0-SNAPSHOT的变更

Artifact ID变更

  • Model starters: spring-ai-{model}-spring-boot-starter → spring-ai-starter-model-{model}
  • Vector Store starters: spring-ai-{store}-store-spring-boot-starter → spring-ai-starter-vector-store-{store}
  • MCP starters: spring-ai-mcp-{type}-spring-boot-starter → spring-ai-starter-mcp-{type}

示例

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<!-- 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>

Spring AI Autoconfiguration从单体模块变更为每个model、vector-store等独立的autoconfiguration,拆开的目的就是避免引入没必要的依赖,减少冲突风险:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<!-- NO LONGER AVAILABLE -->
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-spring-boot-autoconfigure</artifactId>
    <version>${project.version}</version>
</dependency>

取而代之的是:

  • Model autoconfiguration: spring-ai-autoconfigure-model-{model}
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<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>
  • Vector Store autoconfiguration: spring-ai-autoconfigure-vector-store-{store}
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<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>
  • MCP autoconfiguration: spring-ai-autoconfigure-mcp-{type}
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<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>

Package Name变更

  • KeywordMetadataEnricher以及SummaryMetadataEnricher从org.springframework.ai.transformer变更到org.springframework.ai.chat.transformer
  • Content, MediaContent以及Media从org.springframework.ai.model变更到org.springframework.ai.content

Module变更

之前是所有的都在spring-ai-core,现在拆分到具体的领域模块来减少不必要的依赖,如下:

  • spring-ai-commons包含了核心的model比如DocumentTextSplitter
  • spring-ai-model包含了AI能力的相关抽象,比如ChatModelEmbeddingModelImageModelToolDefinitionToolCallback
  • spring-ai-vector-store统一了向量数据库的抽象VectorStore,提供了SimpleVectorStore便于内存使用
  • spring-ai-client-chat提供了high-level的AI会话API,比如ChatClientChatMemoryOutputConverter
  • spring-ai-advisors-vector-store为RAG衔接了chat和向量数据库,比如QuestionAnswerAdvisorVectorStoreChatMemoryAdvisor
  • spring-ai-model-chat-memory-cassandra提供了CassandraChatMemory
  • spring-ai-rag提供了RAG的pipelines,比如RetrievalAugmentationAdvisor

Dependency Structure变更如下:

  • spring-ai-commons (foundation)
  • spring-ai-model (depends on commons)
  • spring-ai-vector-store and spring-ai-client-chat (both depend on model)
  • spring-ai-advisors-vector-store and spring-ai-rag (depend on both client-chat and vector-store)
  • spring-ai-model-chat-memory-* modules (depend on client-chat)

小结

Spring AI 1.0.0-SNAPSHOT主要是涉及了Artifact ID, Package, Module的变更;Spring AI Autoconfiguration从单体模块变更为每个model、vector-store等独立的autoconfiguration,拆开的目的就是避免引入没必要的依赖,减少冲突风险;KeywordMetadataEnricher、SummaryMetadataEnricher、Content、MediaContent以及Media涉及了包名的变更;模块的变更将spring-ai-core拆分到具体的领域模块来减少不必要的依赖。

doc

  • Upgrading to 1.0.0-SNAPSHOT
  • common-artifact-id-changes
  • common-package-changes
  • common-module-structure
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2025-05-06,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 码匠的流水账 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Artifact ID变更
  • Package Name变更
  • Module变更
  • 小结
  • doc
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档