| 此版本仍在开发中,尚未被视为稳定版本。最新的快照版本请使用 Spring AI 1.0.0-SNAPSHOT! | 
升级说明
升级到 1.0.0.M6
对使用接口和 DefaultUsage 实现的更改
这Usageinterface 及其默认实现DefaultUsage进行了以下更改:
- 
方法重命名: - 
getGenerationTokens()现在是getCompletionTokens()
 
- 
- 
类型更改: - 
中的所有令牌计数字段 DefaultUsage从Long自Integer:- 
promptTokens
- 
completionTokens(以前generationTokens)
- 
totalTokens
 
- 
 
- 
所需作
- 
将所有调用 替换为 getGenerationTokens()跟getCompletionTokens()
- 
更新 DefaultUsageconstructor 调用:
// Old (M5) new DefaultUsage(Long promptTokens, Long generationTokens, Long totalTokens) // New (M6) new DefaultUsage(Integer promptTokens, Integer completionTokens, Integer totalTokens)
| 有关处理 Usage 的更多信息,请参阅此处 | 
更改了 FunctionCallingOptions 在工具调用中的用法
每ChatModel实例在构造时接受可选的ChatOptions或FunctionCallingOptions实例
可用于配置用于调用模型的默认工具。
1.0.0-M6 之前:
- 
通过 functions()method 的默认值FunctionCallingOptions实例包含在 从该ChatModel实例,可能会被运行时选项覆盖。
- 
通过 functionCallbacks()method 的默认值FunctionCallingOptions实例仅 可用于运行时动态解析(请参阅工具解析),但从不可用于运行时动态解析 包含在对模型的任何调用中,除非明确请求。
从 1.0.0-M6 开始:
- 
通过 functions()方法或functionCallbacks()的默认值FunctionCallingOptions实例现在以相同的方式处理:它包含在从该ChatModel实例 可能被运行时选项覆盖。因此,调用中包含工具的方式是一致的 添加到模型,并防止由于functionCallbacks()以及所有其他选项。
如果要使工具可用于运行时动态解析,并将其仅包含在对模型的聊天请求中 当明确请求时,您可以使用 Tool Resolution 中描述的策略之一。
| 1.0.0-M6 引入了用于处理工具调用的新 API。保持旧 API 的向后兼容性 所有场景,除了上面描述的场景。旧 API 仍然可用,但它们已被弃用 并将在 1.0.0-M7 中删除。 | 
删除已弃用的 Amazon Bedrock 聊天模型
从 1.0.0-M6 开始,Spring AI 过渡到使用 Amazon Bedrock 的 Converse API 来实现 Spring AI 中的所有聊天对话。 除 Cohere 和 Titan 的嵌入模型外,所有 Amazon Bedrock Chat 模型都将被删除。
| 请参阅 Bedrock Converse 文档以使用聊天模型。 | 
使用 Spring Boot 3.4.2 进行依赖项管理的更改
Spring AI 更新以使用 Spring Boot 3.4.2 进行依赖项管理。Spring Boot 3.4.2 的依赖可以参考这里
所需作
- 
如果要升级到 Spring Boot 3.4.2,请务必参考此文档,了解配置 REST 客户端所需的更改。值得注意的是,如果你在 Classpath 上没有 HTTP 客户端库,这可能会导致使用 JdkClientHttpRequestFactory哪里SimpleClientHttpRequestFactory之前会使用。切换到使用SimpleClientHttpRequestFactory,您需要设置spring.http.client.factory=simple.
- 
如果您使用的是不同版本的 Spring Boot(例如 Spring Boot 3.3.x)并且需要特定版本的依赖项,则可以在构建配置中覆盖它。 
Vector Store API 更改
在版本 1.0.0-M6 中,delete方法中的VectorStoreinterface 已修改为 void作,而不是返回Optional<Boolean>.
如果您的代码之前检查了 delete作的返回值,则需要删除此检查。
现在,如果删除失败,该作将引发异常,从而提供更直接的错误处理。
升级到 1.0.0.M5
- 
为了保持一致性,对 Vector Builder 进行了重构。 
- 
当前的 VectorStore 实现构造函数已被弃用,请使用 builder 模式。 
- 
VectorStore 实现包已移至唯一的包名称中,从而避免了跨构件的冲突。例如 org.springframework.ai.vectorstore自org.springframework.ai.pgvector.vectorstore.
升级到 1.0.0.M2
- 
Chroma矢量存储的配置前缀已从 spring.ai.vectorstore.chroma.store自spring.ai.vectorstore.chroma为了与其他 Vector Store 的命名约定保持一致。
- 
的 initialize-schema能够初始化 Schema 的 vector store 上的属性现在设置为false. 这意味着,如果需要在应用程序启动时创建架构,则应用程序现在需要在支持的向量存储上显式选择加入架构初始化。 并非所有 vector store 都支持此属性。 有关更多详细信息,请参阅相应的 vector store 文档。 以下是目前不支持initialize-schema财产。- 
汉娜 
- 
Pinecone 
- 
Weaviate 
 
- 
- 
在 Bedrock Jurassic 2 中,聊天选项 countPenalty,frequencyPenalty和presencePenalty已重命名为countPenaltyOptions,frequencyPenaltyOptions和presencePenaltyOptions. 此外,聊天选项的类型stopSequences已从String[]自List<String>.
- 
在 Azure OpenAI 中,聊天选项的类型 frequencyPenalty和presencePenalty已从Double自Float,与所有其他实现一致。
升级到 1.0.0.M1
在发布 1.0.0 M1 的过程中,我们进行了几项重大更改。抱歉,这是最好的!
ChatClient 更改
进行了一次重大更改,将“旧的”ChatClient并将功能移至ChatModel.“新”ChatClient现在采用ChatModel.这样做是为了支持一个 Fluent API,用于以类似于 Spring 生态系统中其他客户端类的样式创建和执行提示,例如RestClient,WebClient和JdbcClient.有关 Fluent API 的更多信息,请参阅 [JavaDoc](docs.spring.io/spring-ai/docs/api),适当的参考文档即将发布。
我们将 'old' 重命名为ModelClient自Model并重命名了实现类,例如ImageClient已重命名为ImageModel.这Modelimplementation 表示在 Spring AI API 和底层 AI 模型 API 之间进行转换的可移植性层。
适应变化
| 这 ChatClientclass 现在位于软件包中org.springframework.ai.chat.client | 
方法 1
现在,无需获取 AutoconfiguredChatClient实例,您将获得一个ChatModel实例。这call重命名后的方法签名保持不变。
要适应您的代码,您应该重构您的代码以更改ChatClient自ChatModel以下是更改前的现有代码示例
@RestController
public class OldSimpleAiController {
    private final ChatClient chatClient;
    public OldSimpleAiController(ChatClient chatClient) {
        this.chatClient = chatClient;
    }
    @GetMapping("/ai/simple")
    Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
        return Map.of("generation", this.chatClient.call(message));
    }
}现在,在更改之后,这将是
@RestController
public class SimpleAiController {
    private final ChatModel chatModel;
    public SimpleAiController(ChatModel chatModel) {
        this.chatModel = chatModel;
    }
    @GetMapping("/ai/simple")
    Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
        return Map.of("generation", this.chatModel.call(message));
    }
}| 重命名也适用于类
* StreamingChatClient→StreamingChatModel*EmbeddingClient→EmbeddingModel*ImageClient→ImageModel*SpeechClient→SpeechModel* 和其他类似<XYZ>Client类 | 
方法 2
在此方法中,您将使用“new”上提供的新 Fluent APIChatClient
以下是更改前的现有代码示例
@RestController
class OldSimpleAiController {
    ChatClient chatClient;
    OldSimpleAiController(ChatClient chatClient) {
        this.chatClient = chatClient;
	}
	@GetMapping("/ai/simple")
	Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
		return Map.of(
                "generation",
				this.chatClient.call(message)
        );
	}
}现在,在更改之后,这将是
@RestController
class SimpleAiController {
    private final ChatClient chatClient;
    SimpleAiController(ChatClient.Builder builder) {
      this.chatClient = builder.build();
    }
    @GetMapping("/ai/simple")
    Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
        return Map.of(
                "generation",
				this.chatClient.prompt().user(message).call().content()
        );
    }
}| 这 ChatModel实例 通过 Autoconfiguration 提供给您。 | 
方法 3
GitHub 存储库中有一个名为 [v1.0.0-SNAPSHOT-before-chatclient-changes](github.com/spring-projects/spring-ai/tree/v1.0.0-SNAPSHOT-before-chatclient-changes) 的标记,您可以签出该标记并执行本地构建,以避免在准备好迁移代码库之前更新任何代码。
git checkout tags/v1.0.0-SNAPSHOT-before-chatclient-changes
./mvnw clean install -DskipTests构件名称更改
重命名了 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-redis-store-spring-boot-starter
升级到 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.
因此,您需要将依赖项从
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-vertex-ai</artifactId>
</dependency>自
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-vertex-ai-palm2</artifactId>
</dependency>并且 Palm2 型号的相关 Boot starter 已从
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-vertex-ai-spring-boot-starter</artifactId>
</dependency>自
<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-vertex-ai-palm2-spring-boot-starter</artifactId>
</dependency>- 
重命名的类 (01.03.2024) - 
VertexAiApi → VertexAiPalm2Api 
- 
VertexAiClientChat → VertexAiPalm2ChatClient 
- 
VertexAiEmbeddingClient → VertexAiPalm2EmbeddingClient 
- 
VertexAiChatOptions → VertexAiPalm2ChatOptions 
 
- 
升级到 0.8.0
2024 年 1 月 24 日更新
- 
将 prompt和messages和metadatapackages 的子软件包org.sf.ai.chat
- 
新功能是文本到图像客户端。类是 OpenAiImageModel和StabilityAiImageModel.有关用法,请参阅集成测试,文档即将推出。
- 
新软件包 model其中包含接口和基类,以支持为任何输入/输出数据类型组合创建 AI 模型客户端。目前,chat 和 image model 包实现了这一点。我们很快就会将 embedding 包更新到这个新模型。
- 
新的 “portable options” 设计模式。我们希望在 ModelCall尽可能跨不同的基于聊天的 AI 模型。有一组通用的生成选项,然后是特定于模型提供程序的选项。使用了一种 “duck typing” 方法。ModelOptions在 model 包中是一个 marker 接口,指示此类的实现将为模型提供选项。看ImageOptions,一个定义所有 text→image 的可移植选项的子接口ImageModel实现。然后StabilityAiImageOptions和OpenAiImageOptions提供特定于每个模型提供程序的选项。所有选项类都是通过 Fluent API 构建器创建的,都可以传递到可移植的ImageModel应用程序接口。这些选项数据类型在 autoconfiguration/configuration 属性中使用ImageModel实现。
2024 年 1 月 13 日更新
以下 OpenAi 自动配置聊天属性已更改
- 
从 spring.ai.openai.model自spring.ai.openai.chat.options.model.
- 
从 spring.ai.openai.temperature自spring.ai.openai.chat.options.temperature.
查找有关 OpenAi 属性的更新文档:docs.spring.io/spring-ai/reference/api/chat/openai-chat.html
2023 年 12 月 27 日更新
将 SimplePersistentVectorStore 和 InMemoryVectorStore 合并到 SimpleVectorStore 中 * 将 InMemoryVectorStore 替换为 SimpleVectorStore
2023 年 12 月 20 日更新
重构 Ollama 客户端和相关类和包名称
- 
将org.springframework.ai.ollama.client.OllamaClient替换为org.springframework.ai.ollama.OllamaModelCall。 
- 
OllamaChatClient 方法签名已更改。 
- 
将org.springframework.ai.autoconfigure.ollama.OllamaProperties重命名为org.springframework.ai.autoconfigure.ollama.OllamaChatProperties,并将后缀更改为: spring.ai.ollama.chat.一些属性也发生了变化。
2023 年 12 月 19 日更新
重命名 AiClient 和相关类和包名
- 
将 AiClient 重命名为 ChatClient 
- 
将 AiResponse 重命名为 ChatResponse 
- 
将 AiStreamClient 重命名为 StreamingChatClient 
- 
将包 org.sf.ai.client 重命名为 org.sf.ai.chat 
重命名 artifact ID of
- 
transformers-embedding自spring-ai-transformers
将 Maven 模块从顶级目录和embedding-clients子目录下的所有models目录。
12月 1, 2023
我们正在转换项目的组 ID:
- 
出发地: org.springframework.experimental.ai
- 
收件人: org.springframework.ai
构件仍将托管在快照存储库中,如下所示。
main 分支将移动到版本0.8.0-SNAPSHOT.
它会不稳定一两周。
如果您不想处于最前沿,请使用 0.7.1-SNAPSHOT。
您可以访问0.7.1-SNAPSHOT工件,并且仍然可以访问 0.7.1-SNAPSHOT 文档。
0.7.1-SNAPSHOT 依赖项
- 
Azure OpenAI <dependency> <groupId>org.springframework.experimental.ai</groupId> <artifactId>spring-ai-azure-openai-spring-boot-starter</artifactId> <version>0.7.1-SNAPSHOT</version> </dependency>
- 
OpenAI <dependency> <groupId>org.springframework.experimental.ai</groupId> <artifactId>spring-ai-openai-spring-boot-starter</artifactId> <version>0.7.1-SNAPSHOT</version> </dependency>
升级到 1.0.0.M4
- 
删除 PaLM API 支持 
作为弃用 PaLM API 的公告的后续行动,已删除 PaLM API 支持。