アップグレードノート

1.0.0.M6 へのアップグレード

使用インターフェースと DefaultUsage 実装の変更

Usage インターフェースとそのデフォルト実装 DefaultUsage には、次の変更が加えられました。

  1. メソッド名の変更:

    • getGenerationTokens() は getCompletionTokens() になりました

  2. 型の変更:

    • DefaultUsage のすべてのトークンカウントフィールドが Long から Integer に変更されました。

      • promptTokens

      • completionTokens (formerly generationTokens)

      • totalTokens

必要なアクション

  • getGenerationTokens() へのすべての呼び出しを getCompletionTokens() に置き換えます

  • DefaultUsage コンストラクター呼び出しを更新します。

// Old (M5)
new DefaultUsage(Long promptTokens, Long generationTokens, Long totalTokens)

// New (M6)
new DefaultUsage(Integer promptTokens, Integer completionTokens, Integer totalTokens)
For more information on handling Usage, refer here

JSON Ser/Deser の変更

M6 は generationTokens フィールドの JSON デシリアライゼーションの下位互換性を維持していますが、このフィールドは M7 で削除されます。古いフィールド名を使用している永続化された JSON ドキュメントは、completionTokens を使用するように更新する必要があります。

新しい JSON 形式の例:

{
  "promptTokens": 100,
  "completionTokens": 50,
  "totalTokens": 150
}

Changes to usage of FunctionCallingOptions for tool calling

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.

Before 1.0.0-M6:

  • any tool passed via the functions() method of the default FunctionCallingOptions instance was included in each call to the model from that ChatModel instance, possibly overwritten by runtime options.

  • any tool passed via the functionCallbacks() method of the default FunctionCallingOptions instance was only made available for runtime dynamic resolution (see Tool Resolution ), but never included in any call to the model unless explicitly requested.

Starting 1.0.0-M6:

  • any tool passed via the functions() method or the functionCallbacks() of the default FunctionCallingOptions instance is now handled in the same way: it is included in each call to the model from that ChatModel 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 between functionCallbacks() and all the other options.

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 introduced new API for handling tool calling. Backward compatibility is maintained for the old API across all scenarios, except the one described above. The old API are still available, but they are deprecated and will be removed in 1.0.0-M7.

Removal of deprecated Amazon Bedrock chat models

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.

Refer to Bedrock Converse documentation for using the chat models.

Changes to use Spring Boot 3.4.2 for dependency management

Spring AI updates to use Spring Boot 3.4.2 for the dependency management. You can refer here [GitHub] (英語) for the dependencies which Spring Boot 3.4.2

必要なアクション

  • If you are upgrading to Spring Boot 3.4.2, please make sure to refer to this [GitHub] (英語) 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 where SimpleClientHttpRequestFactory would have been used previously. To switch to use SimpleClientHttpRequestFactory, you need to set spring.http.client.factory=simple.

  • 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

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.

Before 1.0.0-M6:

Optional<Boolean> result = vectorStore.delete(ids);
if (result.isPresent() && result.get()) {
    // handle successful deletion
}

In 1.0.0-M6 and later:

vectorStore.delete(ids);
// deletion successful if no exception is thrown

1.0.0.M5 へのアップグレード

  • ベクトルビルダーは一貫性を保つためにリファクタリングされました。

  • 現在の VectorStore 実装コンストラクターは非推奨になっています。ビルダーパターンを使用してください。

  • VectorStore 実装パッケージは、アーティファクト間での競合を回避するために、一意のパッケージ名に移動されました。たとえば、org.springframework.ai.vectorstore から org.springframework.ai.pgvector.vectorstore へ。

1.0.0.RC3 へのアップグレード

  • ポータブルチャットオプション(frequencyPenaltypresencePenaltytemperaturetopP)の型が Float から Double に変更されました。

1.0.0.M2 へのアップグレード

  • Chroma ベクトルストアの構成プレフィックスは、他のベクトルストアの命名規則に合わせるために、spring.ai.vectorstore.chroma.store から spring.ai.vectorstore.chroma に変更されました。

  • スキーマを初期化できるベクトルストアの initialize-schema プロパティのデフォルト値が、false に設定されました。つまり、アプリケーションの起動時にスキーマが作成される場合、アプリケーションは、サポートされているベクトルストアでスキーマの初期化を明示的にオプトインする必要があります。すべてのベクトルストアがこのプロパティをサポートしているわけではありません。詳細については、対応するベクトルストアのドキュメントを参照してください。現在 initialize-schema プロパティをサポートしていないベクトルストアは次のとおりです。

    1. Hana

    2. Pinecone

    3. Weaviate

  • Bedrock Jurassic 2 では、チャットオプション countPenaltyfrequencyPenaltypresencePenalty の名前が countPenaltyOptionsfrequencyPenaltyOptionspresencePenaltyOptions に変更されました。さらに、チャットオプション stopSequences の型が String[] から List<String> に変更されました。

  • Azure、OpenAI では、チャットオプション frequencyPenalty および presencePenalty の型が、他のすべての実装と一致するように、Double から Float に変更されました。

1.0.0.M1 へのアップグレード

1.0.0 M1 のリリースに向けて、いくつかの重大な変更を加えました。申し訳ありませんが、これは最善の策です。

ChatClient の変更点

大きな変更が行われ、' 古い ' ChatClient の機能が ChatModel に移動されました。' 新しい ' ChatClient は、ChatModel のインスタンスを使用するようになりました。これは、Spring エコシステム内の他のクライアントクラス ( RestClientWebClientJdbcClient など) と同様のスタイルでプロンプトを作成および実行するための Fluent API をサポートするために行われました。Fluent API の詳細については、[JavaDoc]( ドキュメント ) を参照してください。適切なリファレンスドキュメントはまもなく公開される予定です。

「古い」 ModelClient の名前を Model に変更し、実装クラスの名前も変更しました。たとえば、ImageClient は ImageModel に名前が変更されました。Model 実装は、Spring AI API と基礎となる AI モデル API 間の変換を行う移植性レイヤーを表します。

変化への適応

ChatClient クラスはパッケージ org.springframework.ai.chat.client に含まれるようになりました

アプローチ 1

自動構成された ChatClient インスタンスではなく、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

このアプローチでは、「新しい」 ChatClient で利用可能な新しい Fluent API を使用します。

変更前の既存コードの例を以下に示します

@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 インスタンスは自動構成を通じて利用可能になります。

アプローチ 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>

To

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-vertex-ai-palm2</artifactId>
</dependency>

Palm2 モデルに関連する Boot スターター

<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>
  • 名前変更されたクラス (01.03.2024)

    • VertexAiApi → VertexAiPalm2Api

    • VertexAiClientChat → VertexAiPalm2ChatClient

    • VertexAiEmbeddingClient → VertexAiPalm2EmbeddingClient

    • VertexAiChatOptions → VertexAiPalm2ChatOptions

0.8.0 へのアップグレード

2024 年 1 月 24 日更新

  • promptmessagesmetadata パッケージを org.sf.ai.chat のサブパッケージに移動する

  • 新しい機能は、テキストからイメージへのクライアントです。クラスは OpenAiImageModel および StabilityAiImageModel です。使用箇所については統合テストを参照してください。ドキュメントは近日公開予定です。

  • 任意の入力 / 出力データ型の組み合わせに対する AI モデルクライアントの作成をサポートするインターフェースと基本クラスが含まれる新しいパッケージ model。現時点では、チャットモデルパッケージとイメージモデルパッケージがこれを実装しています。近々、埋め込みパッケージをこの新しいモデルに更新する予定です。

  • 新しい「ポータブルオプション」デザインパターン。さまざまなチャットベースの AI モデル間で ModelCall に可能な限りの移植性を提供したいと考えました。生成オプションの共通のセットと、モデルプロバイダーに固有の生成オプションのセットがあります。一種の「ダックタイピング」アプローチが使用されます。モデルパッケージ内の ModelOptions は、このクラスの実装がモデルのオプションを提供することを示すマーカーインターフェースです。すべての text → image ImageModel 実装にわたってポータブルオプションを定義するサブインターフェースである ImageOptions を参照してください。次に、StabilityAiImageOptions および OpenAiImageOptions は、各モデルプロバイダーに固有のオプションを提供します。すべてのオプションクラスは、流れるような API ビルダーを介して作成され、ポータブルな ImageModel API に渡すことができます。これらのオプションデータ型は、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 プロパティに関する更新されたドキュメントを検索します: 参照: 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 に変更します

アーティファクト ID の名前を変更します

  • transformers-embedding から spring-ai-transformers

Maven モジュールを最上位ディレクトリと embedding-clients サブディレクトリからすべて 1 つの models ディレクトリに移動しました。

2023 年 12 月 1 日

プロジェクトのグループ ID を移行しています。

  • FROMorg.springframework.experimental.ai

  • TOorg.springframework.ai

以下に示すように、アーティファクトは引き続きスナップショットリポジトリでホストされます。

メインの ブランチはバージョン 0.8.0-SNAPSHOT に移行します。1 ~ 2 週間は不安定になります。最新の状態を望まない場合は、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 のサポートが削除されました。