Update spring-javaformat to version 0.0.43
- Ran ./mvnw spring-javaformat:apply that made some new formatting changes
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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")));
|
||||
|
||||
@@ -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")))));
|
||||
}
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -221,7 +221,7 @@
|
||||
<maven-site-plugin.version>4.0.0-M13</maven-site-plugin.version>
|
||||
<maven-project-info-reports-plugin.version>3.4.5</maven-project-info-reports-plugin.version>
|
||||
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
|
||||
<spring-javaformat-maven-plugin.version>0.0.39</spring-javaformat-maven-plugin.version>
|
||||
<spring-javaformat-maven-plugin.version>0.0.43</spring-javaformat-maven-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user