Skip to content

Commit 7d77767

Browse files
committed
Merge branch 'main' into fix-issue-4472
# Conflicts: # models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/api/StreamHelperTests.java
2 parents 927aa9a + 93cf476 commit 7d77767

File tree

5 files changed

+52
-4
lines changed

5 files changed

+52
-4
lines changed

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/api/StreamHelperTests.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ void testMultipleErrorEventsHandling() {
7676
assertThat(response2).isNotNull();
7777
}
7878

79+
@Test
80+
void testPingEventHandling() {
81+
StreamHelper streamHelper = new StreamHelper();
82+
AtomicReference<ChatCompletionResponseBuilder> contentBlockReference = new AtomicReference<>();
83+
84+
AnthropicApi.PingEvent pingEvent = new AnthropicApi.PingEvent(AnthropicApi.EventType.PING);
85+
86+
AnthropicApi.ChatCompletionResponse response = streamHelper.eventToChatCompletionResponse(pingEvent,
87+
contentBlockReference);
88+
89+
assertThat(response).isNotNull();
90+
}
91+
7992
@Test
8093
void testMessageStartEvent() {
8194
StreamHelper streamHelper = new StreamHelper();

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat-memory.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ If you'd rather create the `CassandraChatMemoryRepository` manually, you can do
222222
[source,java]
223223
----
224224
ChatMemoryRepository chatMemoryRepository = CassandraChatMemoryRepository
225-
.create(CassandraChatMemoryConfig.builder().withCqlSession(cqlSession));
225+
.create(CassandraChatMemoryRepositoryConfig.builder().withCqlSession(cqlSession));
226226
227227
ChatMemory chatMemory = MessageWindowChatMemory.builder()
228228
.chatMemoryRepository(chatMemoryRepository)

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/multimodality.adoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ For most of the multimodal LLMs, the Spring AI code would look something like th
4141
----
4242
var imageResource = new ClassPathResource("/multimodal.test.png");
4343
44-
var userMessage = new UserMessage(
45-
"Explain what do you see in this picture?", // content
46-
new Media(MimeTypeUtils.IMAGE_PNG, this.imageResource)); // media
44+
var userMessage = UserMessage.builder()
45+
.text("Explain what do you see in this picture?") // content
46+
.media(new Media(MimeTypeUtils.IMAGE_PNG, this.imageResource)) // media
47+
.build();
4748
4849
ChatResponse response = chatModel.call(new Prompt(this.userMessage));
4950
----

spring-ai-rag/src/test/java/org/springframework/ai/rag/QueryTests.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,22 @@ void whenCompareQueryToNullThenNotEqual() {
7878
assertThat(query).isNotEqualTo(null);
7979
}
8080

81+
@Test
82+
void whenCompareQueryToDifferentTypeThenNotEqual() {
83+
Query query = new Query("Test query");
84+
String notAQuery = "Test query";
85+
86+
assertThat(query).isNotEqualTo(notAQuery);
87+
}
88+
89+
@Test
90+
void toStringReturnsExpectedFormat() {
91+
Query query = new Query("Test query text");
92+
String toString = query.toString();
93+
94+
assertThat(toString).contains("Query");
95+
assertThat(toString).contains("text");
96+
assertThat(toString).contains("Test query text");
97+
}
98+
8199
}

spring-ai-rag/src/test/java/org/springframework/ai/rag/preretrieval/query/expansion/MultiQueryExpanderTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.springframework.ai.chat.prompt.PromptTemplate;
2323

2424
import static org.assertj.core.api.Assertions.assertThatThrownBy;
25+
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
2526
import static org.mockito.Mockito.mock;
2627

2728
/**
@@ -69,4 +70,19 @@ void whenPromptHasMissingQueryPlaceholderThenThrow() {
6970
.hasMessageContaining("query");
7071
}
7172

73+
@Test
74+
void whenBuilderIsNullThenThrow() {
75+
assertThatThrownBy(() -> MultiQueryExpander.builder().build()).isInstanceOf(IllegalArgumentException.class)
76+
.hasMessageContaining("chatClientBuilder cannot be null");
77+
}
78+
79+
@Test
80+
void whenPromptTemplateIsNullThenUseDefault() {
81+
MultiQueryExpander queryExpander = MultiQueryExpander.builder()
82+
.chatClientBuilder(mock(ChatClient.Builder.class))
83+
.promptTemplate(null)
84+
.build();
85+
assertThat(queryExpander).isNotNull();
86+
}
87+
7288
}

0 commit comments

Comments
 (0)