diff --git a/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxRetryTests.java b/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxRetryTests.java index a9847114b..b20bada56 100644 --- a/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxRetryTests.java +++ b/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxRetryTests.java @@ -120,11 +120,11 @@ public class MiniMaxRetryTests { } @Test - public void miniMaxChatNonTransientError() { - when(miniMaxApi.chatCompletionEntity(isA(ChatCompletionRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); - assertThrows(RuntimeException.class, () -> chatModel.call(new Prompt("text"))); - } + public void miniMaxChatNonTransientError() { + when(miniMaxApi.chatCompletionEntity(isA(ChatCompletionRequest.class))) + .thenThrow(new RuntimeException("Non Transient Error")); + assertThrows(RuntimeException.class, () -> chatModel.call(new Prompt("text"))); + } @Test public void miniMaxChatStreamTransientError() { @@ -148,11 +148,11 @@ public class MiniMaxRetryTests { } @Test - public void miniMaxChatStreamNonTransientError() { - when(miniMaxApi.chatCompletionStream(isA(ChatCompletionRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); - assertThrows(RuntimeException.class, () -> chatModel.stream(new Prompt("text")).collectList().block()); - } + public void miniMaxChatStreamNonTransientError() { + when(miniMaxApi.chatCompletionStream(isA(ChatCompletionRequest.class))) + .thenThrow(new RuntimeException("Non Transient Error")); + assertThrows(RuntimeException.class, () -> chatModel.stream(new Prompt("text")).collectList().block()); + } @Test public void miniMaxEmbeddingTransientError() { @@ -174,11 +174,10 @@ public class MiniMaxRetryTests { } @Test - public void miniMaxEmbeddingNonTransientError() { - when(miniMaxApi.embeddings(isA(EmbeddingRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); - assertThrows(RuntimeException.class, () -> embeddingModel - .call(new org.springframework.ai.embedding.EmbeddingRequest(List.of("text1", "text2"), null))); - } + public void miniMaxEmbeddingNonTransientError() { + when(miniMaxApi.embeddings(isA(EmbeddingRequest.class))).thenThrow(new RuntimeException("Non Transient Error")); + assertThrows(RuntimeException.class, () -> embeddingModel + .call(new org.springframework.ai.embedding.EmbeddingRequest(List.of("text1", "text2"), null))); + } } diff --git a/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiRetryTests.java b/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiRetryTests.java index 8e2d4a7dd..28b29fcd3 100644 --- a/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiRetryTests.java +++ b/models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/MistralAiRetryTests.java @@ -131,7 +131,7 @@ public class MistralAiRetryTests { @Test public void mistralAiChatNonTransientError() { when(mistralAiApi.chatCompletionEntity(isA(ChatCompletionRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); + .thenThrow(new RuntimeException("Non Transient Error")); assertThrows(RuntimeException.class, () -> chatModel.call(new Prompt("text"))); } @@ -161,7 +161,7 @@ public class MistralAiRetryTests { @Disabled("Currently stream() does not implement retry") public void mistralAiChatStreamNonTransientError() { when(mistralAiApi.chatCompletionStream(isA(ChatCompletionRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); + .thenThrow(new RuntimeException("Non Transient Error")); assertThrows(RuntimeException.class, () -> chatModel.stream(new Prompt("text"))); } @@ -188,9 +188,9 @@ public class MistralAiRetryTests { @Test public void mistralAiEmbeddingNonTransientError() { when(mistralAiApi.embeddings(isA(EmbeddingRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); + .thenThrow(new RuntimeException("Non Transient Error")); assertThrows(RuntimeException.class, () -> embeddingModel - .call(new org.springframework.ai.embedding.EmbeddingRequest(List.of("text1", "text2"), null))); + .call(new org.springframework.ai.embedding.EmbeddingRequest(List.of("text1", "text2"), null))); } } diff --git a/models/spring-ai-moonshot/src/test/java/org/springframework/ai/moonshot/MoonshotRetryTests.java b/models/spring-ai-moonshot/src/test/java/org/springframework/ai/moonshot/MoonshotRetryTests.java index 6463fec5a..4e1df77fa 100644 --- a/models/spring-ai-moonshot/src/test/java/org/springframework/ai/moonshot/MoonshotRetryTests.java +++ b/models/spring-ai-moonshot/src/test/java/org/springframework/ai/moonshot/MoonshotRetryTests.java @@ -116,7 +116,7 @@ public class MoonshotRetryTests { @Test public void moonshotChatNonTransientError() { when(moonshotApi.chatCompletionEntity(isA(ChatCompletionRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); + .thenThrow(new RuntimeException("Non Transient Error")); assertThrows(RuntimeException.class, () -> chatModel.call(new Prompt("text"))); } @@ -144,7 +144,7 @@ public class MoonshotRetryTests { @Test public void moonshotChatStreamNonTransientError() { when(moonshotApi.chatCompletionStream(isA(ChatCompletionRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); + .thenThrow(new RuntimeException("Non Transient Error")); assertThrows(RuntimeException.class, () -> chatModel.stream(new Prompt("text")).collectList().block()); } diff --git a/models/spring-ai-vertex-ai-embedding/src/test/java/org/springframework/ai/vertexai/embedding/text/VertexAiTextEmbeddingRetryTests.java b/models/spring-ai-vertex-ai-embedding/src/test/java/org/springframework/ai/vertexai/embedding/text/VertexAiTextEmbeddingRetryTests.java index e6de28579..2638e97e7 100644 --- a/models/spring-ai-vertex-ai-embedding/src/test/java/org/springframework/ai/vertexai/embedding/text/VertexAiTextEmbeddingRetryTests.java +++ b/models/spring-ai-vertex-ai-embedding/src/test/java/org/springframework/ai/vertexai/embedding/text/VertexAiTextEmbeddingRetryTests.java @@ -148,12 +148,11 @@ public class VertexAiTextEmbeddingRetryTests { @Test public void vertexAiEmbeddingNonTransientError() { // Setup the mock PredictionServiceClient to throw a non-transient error - when(mockPredictionServiceClient.predict(any())) - .thenThrow(new RuntimeException("Non Transient Error")); + when(mockPredictionServiceClient.predict(any())).thenThrow(new RuntimeException("Non Transient Error")); // Assert that a RuntimeException is thrown and not retried - assertThrows(RuntimeException.class, () -> embeddingModel - .call(new EmbeddingRequest(List.of("text1", "text2"), null))); + assertThrows(RuntimeException.class, + () -> embeddingModel.call(new EmbeddingRequest(List.of("text1", "text2"), null))); // Verify that predict was called only once (no retries for non-transient errors) verify(mockPredictionServiceClient, times(1)).predict(any()); diff --git a/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiRetryTests.java b/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiRetryTests.java index 3bee40ae6..387d25501 100644 --- a/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiRetryTests.java +++ b/models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiRetryTests.java @@ -130,7 +130,7 @@ public class VertexAiGeminiRetryTests { public void vertexAiGeminiChatNonTransientError() throws Exception { // Set up the mock GenerativeModel to throw a non-transient RuntimeException when(mockGenerativeModel.generateContent(any(List.class))) - .thenThrow(new RuntimeException("Non Transient Error")); + .thenThrow(new RuntimeException("Non Transient Error")); // Assert that a RuntimeException is thrown when calling the chat model assertThrows(RuntimeException.class, () -> chatModel.call(new Prompt("test prompt"))); diff --git a/models/spring-ai-zhipuai/src/test/java/org/springframework/ai/zhipuai/api/ZhiPuAiRetryTests.java b/models/spring-ai-zhipuai/src/test/java/org/springframework/ai/zhipuai/api/ZhiPuAiRetryTests.java index 4e50093d8..aa76c1be8 100644 --- a/models/spring-ai-zhipuai/src/test/java/org/springframework/ai/zhipuai/api/ZhiPuAiRetryTests.java +++ b/models/spring-ai-zhipuai/src/test/java/org/springframework/ai/zhipuai/api/ZhiPuAiRetryTests.java @@ -135,7 +135,7 @@ public class ZhiPuAiRetryTests { @Test public void zhiPuAiChatNonTransientError() { when(zhiPuAiApi.chatCompletionEntity(isA(ChatCompletionRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); + .thenThrow(new RuntimeException("Non Transient Error")); assertThrows(RuntimeException.class, () -> chatModel.call(new Prompt("text"))); } @@ -163,7 +163,7 @@ public class ZhiPuAiRetryTests { @Test public void zhiPuAiChatStreamNonTransientError() { when(zhiPuAiApi.chatCompletionStream(isA(ChatCompletionRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); + .thenThrow(new RuntimeException("Non Transient Error")); assertThrows(RuntimeException.class, () -> chatModel.stream(new Prompt("text")).collectList().block()); } @@ -189,10 +189,9 @@ public class ZhiPuAiRetryTests { @Test public void zhiPuAiEmbeddingNonTransientError() { - when(zhiPuAiApi.embeddings(isA(EmbeddingRequest.class))) - .thenThrow(new RuntimeException("Non Transient Error")); + when(zhiPuAiApi.embeddings(isA(EmbeddingRequest.class))).thenThrow(new RuntimeException("Non Transient Error")); assertThrows(RuntimeException.class, () -> embeddingModel - .call(new org.springframework.ai.embedding.EmbeddingRequest(List.of("text1", "text2"), null))); + .call(new org.springframework.ai.embedding.EmbeddingRequest(List.of("text1", "text2"), null))); } @Test @@ -216,7 +215,7 @@ public class ZhiPuAiRetryTests { @Test public void zhiPuAiImageNonTransientError() { when(zhiPuAiImageApi.createImage(isA(ZhiPuAiImageRequest.class))) - .thenThrow(new RuntimeException("Transient Error 1")); + .thenThrow(new RuntimeException("Transient Error 1")); assertThrows(RuntimeException.class, () -> imageModel.call(new ImagePrompt(List.of(new ImageMessage("Image Message"))))); } diff --git a/pom.xml b/pom.xml index b3af8247d..2a79d29d1 100644 --- a/pom.xml +++ b/pom.xml @@ -221,7 +221,7 @@ 4.0.0-M13 3.4.5 3.3.0 - 0.0.39 + 0.0.43 diff --git a/spring-ai-core/src/test/java/org/springframework/ai/chat/client/ChatClientTest.java b/spring-ai-core/src/test/java/org/springframework/ai/chat/client/ChatClientTest.java index f5cfba4a6..b5c0427c9 100644 --- a/spring-ai-core/src/test/java/org/springframework/ai/chat/client/ChatClientTest.java +++ b/spring-ai-core/src/test/java/org/springframework/ai/chat/client/ChatClientTest.java @@ -468,7 +468,8 @@ public class ChatClientTest { when(chatModel.call(promptCaptor.capture())) .thenReturn(new ChatResponse(List.of(new Generation(new AssistantMessage("response"))))); - var media = new Media(MimeTypeUtils.IMAGE_JPEG, new DefaultResourceLoader().getResource("classpath:/bikes.json")); + var media = new Media(MimeTypeUtils.IMAGE_JPEG, + new DefaultResourceLoader().getResource("classpath:/bikes.json")); UserMessage message = new UserMessage("User prompt", List.of(media)); Prompt prompt = new Prompt(message); diff --git a/spring-ai-core/src/test/java/org/springframework/ai/embedding/AbstractEmbeddingModelTests.java b/spring-ai-core/src/test/java/org/springframework/ai/embedding/AbstractEmbeddingModelTests.java index 327732c9e..88ff94632 100644 --- a/spring-ai-core/src/test/java/org/springframework/ai/embedding/AbstractEmbeddingModelTests.java +++ b/spring-ai-core/src/test/java/org/springframework/ai/embedding/AbstractEmbeddingModelTests.java @@ -87,7 +87,7 @@ public class AbstractEmbeddingModelTests { @Test public void testUnknownModelDimension() { - when(embeddingModel.embed(eq("Hello world!"))).thenReturn(new float[]{0.1f, 0.1f, 0.1f}); + when(embeddingModel.embed(eq("Hello world!"))).thenReturn(new float[] { 0.1f, 0.1f, 0.1f }); assertThat(AbstractEmbeddingModel.dimensions(embeddingModel, "unknown_model", "Hello world!")).isEqualTo(3); } diff --git a/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/MilvusEmbeddingDimensionsTests.java b/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/MilvusEmbeddingDimensionsTests.java index 132d3673e..78538ee8f 100644 --- a/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/MilvusEmbeddingDimensionsTests.java +++ b/vector-stores/spring-ai-milvus-store/src/test/java/org/springframework/ai/vectorstore/MilvusEmbeddingDimensionsTests.java @@ -70,8 +70,8 @@ public class MilvusEmbeddingDimensionsTests { MilvusVectorStoreConfig config = MilvusVectorStoreConfig.builder().build(); - var dim = new MilvusVectorStore(milvusClient, embeddingModel, config ,true, new TokenCountBatchingStrategy()) - .embeddingDimensions(); + var dim = new MilvusVectorStore(milvusClient, embeddingModel, config, true, new TokenCountBatchingStrategy()) + .embeddingDimensions(); assertThat(dim).isEqualTo(969); @@ -83,9 +83,9 @@ public class MilvusEmbeddingDimensionsTests { when(embeddingModel.dimensions()).thenThrow(new RuntimeException()); - var dim = new MilvusVectorStore(milvusClient, embeddingModel, - MilvusVectorStoreConfig.builder().build() ,true, new TokenCountBatchingStrategy()) - .embeddingDimensions(); + var dim = new MilvusVectorStore(milvusClient, embeddingModel, MilvusVectorStoreConfig.builder().build(), true, + new TokenCountBatchingStrategy()) + .embeddingDimensions(); assertThat(dim).isEqualTo(MilvusVectorStore.OPENAI_EMBEDDING_DIMENSION_SIZE); verify(embeddingModel, only()).dimensions();