Skip to content

Commit dcaee54

Browse files
authored
Fix typos in comments and improve documentation (#3936)
- Fix typo: 'wrapps' → 'wraps' in TODO comments across multiple files - Fix typo: 'uitlity' → 'utility' in AnthropicChatModel comment - Fix typo: 'occasionall' → 'occasionally' in OpenAiChatModelObservationIT comment - Add comprehensive documentation to spring-ai-test README with usage examples Signed-off-by: 전민오 <[email protected]>
1 parent d7db943 commit dcaee54

File tree

7 files changed

+57
-11
lines changed

7 files changed

+57
-11
lines changed

models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicChatModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousCha
267267
// FIXME: bounded elastic needs to be used since tool calling
268268
// is currently only synchronous
269269
return Flux.deferContextual((ctx) -> {
270-
// TODO: factor out the tool execution logic with setting context into a uitlity.
270+
// TODO: factor out the tool execution logic with setting context into a utility.
271271
ToolExecutionResult toolExecutionResult;
272272
try {
273273
ToolCallReactiveContextHolder.setContext(ctx);

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/client/AnthropicChatClientIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ void multiModalityEmbeddedImage(String modelName) throws IOException {
306306
@ValueSource(strings = { "claude-3-7-sonnet-latest", "claude-sonnet-4-0" })
307307
void multiModalityImageUrl(String modelName) throws IOException {
308308

309-
// TODO: add url method that wrapps the checked exception.
309+
// TODO: add url method that wraps the checked exception.
310310
URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png");
311311

312312
// @formatter:off

models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiChatModelIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void beanStreamOutputConverterRecords() {
251251
@Test
252252
void multiModalityImageUrl() throws IOException {
253253

254-
// TODO: add url method that wrapps the checked exception.
254+
// TODO: add url method that wraps the checked exception.
255255
URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png");
256256

257257
// @formatter:off

models/spring-ai-bedrock-converse/src/test/java/org/springframework/ai/bedrock/converse/BedrockConverseChatClientIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ void multiModalityEmbeddedImage(String modelName) throws IOException {
381381
@ValueSource(strings = { "anthropic.claude-3-5-sonnet-20240620-v1:0" })
382382
void multiModalityImageUrl2(String modelName) throws IOException {
383383

384-
// TODO: add url method that wrapps the checked exception.
384+
// TODO: add url method that wraps the checked exception.
385385
URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png");
386386

387387
// @formatter:off
@@ -401,7 +401,7 @@ void multiModalityImageUrl2(String modelName) throws IOException {
401401
@ValueSource(strings = { "anthropic.claude-3-5-sonnet-20240620-v1:0" })
402402
void multiModalityImageUrl(String modelName) throws IOException {
403403

404-
// TODO: add url method that wrapps the checked exception.
404+
// TODO: add url method that wraps the checked exception.
405405
URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png");
406406

407407
// @formatter:off
@@ -420,7 +420,7 @@ void multiModalityImageUrl(String modelName) throws IOException {
420420
@Test
421421
void streamingMultiModalityImageUrl() throws IOException {
422422

423-
// TODO: add url method that wrapps the checked exception.
423+
// TODO: add url method that wraps the checked exception.
424424
URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png");
425425

426426
// @formatter:off

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatModelObservationIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private void validate(ChatResponseMetadata responseMetadata) {
130130
.doesNotHaveAnyRemainingCurrentObservation()
131131
.hasObservationWithNameEqualTo(DefaultChatModelObservationConvention.DEFAULT_NAME)
132132
.that()
133-
// TODO - this condition occasionall fails.
133+
// TODO - this condition occasionally fails.
134134
// .hasContextualNameEqualTo("chat " +
135135
// OpenAiApi.ChatModel.GPT_4_O_MINI.getValue())
136136
.hasLowCardinalityKeyValue(LowCardinalityKeyNames.AI_OPERATION_TYPE.asString(),

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/client/OpenAiChatClientIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ void multiModalityEmbeddedImage(String modelName) throws IOException {
324324
@ValueSource(strings = { "gpt-4o" })
325325
void multiModalityImageUrl(String modelName) throws IOException {
326326

327-
// TODO: add url method that wrapps the checked exception.
327+
// TODO: add url method that wraps the checked exception.
328328
URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png");
329329

330330
// @formatter:off
@@ -343,7 +343,7 @@ void multiModalityImageUrl(String modelName) throws IOException {
343343
@Test
344344
void streamingMultiModalityImageUrl() throws IOException {
345345

346-
// TODO: add url method that wrapps the checked exception.
346+
// TODO: add url method that wraps the checked exception.
347347
URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png");
348348

349349
// @formatter:off

spring-ai-test/README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,48 @@
1-
TODO:
2-
Documentation and sample tests using the `BasicEvaluationTest`.
1+
# Spring AI Test
2+
3+
The Spring AI Test module provides utilities and base classes for testing AI applications built with Spring AI.
4+
5+
## Features
6+
7+
- **BasicEvaluationTest**: A base test class for evaluating question-answer quality using AI models
8+
- **Vector Store Testing**: Utilities for testing vector store implementations
9+
- **Audio Testing**: Utilities for testing audio-related functionality
10+
11+
## BasicEvaluationTest
12+
13+
The `BasicEvaluationTest` class provides a framework for evaluating the quality and relevance of AI-generated answers to questions.
14+
15+
### Usage
16+
17+
Extend the `BasicEvaluationTest` class in your test classes:
18+
19+
```java
20+
@SpringBootTest
21+
public class MyAiEvaluationTest extends BasicEvaluationTest {
22+
23+
@Test
24+
public void testQuestionAnswerAccuracy() {
25+
String question = "What is the capital of France?";
26+
String answer = "The capital of France is Paris.";
27+
28+
// Evaluate if the answer is accurate and related to the question
29+
evaluateQuestionAndAnswer(question, answer, true);
30+
}
31+
}
32+
```
33+
34+
### Configuration
35+
36+
The test requires:
37+
- A `ChatModel` bean (typically OpenAI)
38+
- Evaluation prompt templates located in `classpath:/prompts/spring/test/evaluation/`
39+
40+
### Evaluation Types
41+
42+
- **Fact-based evaluation**: Use `factBased = true` for questions requiring factual accuracy
43+
- **General evaluation**: Use `factBased = false` for more subjective questions
44+
45+
The evaluation process:
46+
1. Checks if the answer is related to the question
47+
2. Evaluates the accuracy/appropriateness of the answer
48+
3. Fails the test with detailed feedback if the answer is inadequate

0 commit comments

Comments
 (0)