From a0be91dee1ef2c18533fb2730ea64a02bb94f30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=84=EB=AF=BC=EC=98=A4?= Date: Tue, 29 Jul 2025 13:46:01 +0900 Subject: [PATCH] Fix typos in comments and improve documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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: 전민오 --- .../ai/anthropic/AnthropicChatModel.java | 2 +- .../client/AnthropicChatClientIT.java | 2 +- .../azure/openai/AzureOpenAiChatModelIT.java | 2 +- .../converse/BedrockConverseChatClientIT.java | 6 +-- .../chat/OpenAiChatModelObservationIT.java | 2 +- .../chat/client/OpenAiChatClientIT.java | 4 +- spring-ai-test/README.md | 50 ++++++++++++++++++- 7 files changed, 57 insertions(+), 11 deletions(-) diff --git a/models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicChatModel.java b/models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicChatModel.java index 2ded856a05f..2d36014a719 100644 --- a/models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicChatModel.java +++ b/models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicChatModel.java @@ -267,7 +267,7 @@ public Flux internalStream(Prompt prompt, ChatResponse previousCha // FIXME: bounded elastic needs to be used since tool calling // is currently only synchronous return Flux.deferContextual((ctx) -> { - // TODO: factor out the tool execution logic with setting context into a uitlity. + // TODO: factor out the tool execution logic with setting context into a utility. ToolExecutionResult toolExecutionResult; try { ToolCallReactiveContextHolder.setContext(ctx); diff --git a/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/client/AnthropicChatClientIT.java b/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/client/AnthropicChatClientIT.java index 3117d56fb74..f11e19af093 100644 --- a/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/client/AnthropicChatClientIT.java +++ b/models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/client/AnthropicChatClientIT.java @@ -306,7 +306,7 @@ void multiModalityEmbeddedImage(String modelName) throws IOException { @ValueSource(strings = { "claude-3-7-sonnet-latest", "claude-sonnet-4-0" }) void multiModalityImageUrl(String modelName) throws IOException { - // TODO: add url method that wrapps the checked exception. + // TODO: add url method that wraps the checked exception. URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png"); // @formatter:off diff --git a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiChatModelIT.java b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiChatModelIT.java index 1c8fb392df5..b53da6a56bb 100644 --- a/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiChatModelIT.java +++ b/models/spring-ai-azure-openai/src/test/java/org/springframework/ai/azure/openai/AzureOpenAiChatModelIT.java @@ -251,7 +251,7 @@ void beanStreamOutputConverterRecords() { @Test void multiModalityImageUrl() throws IOException { - // TODO: add url method that wrapps the checked exception. + // TODO: add url method that wraps the checked exception. URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png"); // @formatter:off diff --git a/models/spring-ai-bedrock-converse/src/test/java/org/springframework/ai/bedrock/converse/BedrockConverseChatClientIT.java b/models/spring-ai-bedrock-converse/src/test/java/org/springframework/ai/bedrock/converse/BedrockConverseChatClientIT.java index fa5a292a535..6980b6b2859 100644 --- a/models/spring-ai-bedrock-converse/src/test/java/org/springframework/ai/bedrock/converse/BedrockConverseChatClientIT.java +++ b/models/spring-ai-bedrock-converse/src/test/java/org/springframework/ai/bedrock/converse/BedrockConverseChatClientIT.java @@ -381,7 +381,7 @@ void multiModalityEmbeddedImage(String modelName) throws IOException { @ValueSource(strings = { "anthropic.claude-3-5-sonnet-20240620-v1:0" }) void multiModalityImageUrl2(String modelName) throws IOException { - // TODO: add url method that wrapps the checked exception. + // TODO: add url method that wraps the checked exception. URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png"); // @formatter:off @@ -401,7 +401,7 @@ void multiModalityImageUrl2(String modelName) throws IOException { @ValueSource(strings = { "anthropic.claude-3-5-sonnet-20240620-v1:0" }) void multiModalityImageUrl(String modelName) throws IOException { - // TODO: add url method that wrapps the checked exception. + // TODO: add url method that wraps the checked exception. URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png"); // @formatter:off @@ -420,7 +420,7 @@ void multiModalityImageUrl(String modelName) throws IOException { @Test void streamingMultiModalityImageUrl() throws IOException { - // TODO: add url method that wrapps the checked exception. + // TODO: add url method that wraps the checked exception. URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png"); // @formatter:off diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatModelObservationIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatModelObservationIT.java index 52b4bc89b05..3b73adf7f0b 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatModelObservationIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiChatModelObservationIT.java @@ -130,7 +130,7 @@ private void validate(ChatResponseMetadata responseMetadata) { .doesNotHaveAnyRemainingCurrentObservation() .hasObservationWithNameEqualTo(DefaultChatModelObservationConvention.DEFAULT_NAME) .that() - // TODO - this condition occasionall fails. + // TODO - this condition occasionally fails. // .hasContextualNameEqualTo("chat " + // OpenAiApi.ChatModel.GPT_4_O_MINI.getValue()) .hasLowCardinalityKeyValue(LowCardinalityKeyNames.AI_OPERATION_TYPE.asString(), diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/client/OpenAiChatClientIT.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/client/OpenAiChatClientIT.java index f98da332ba0..f73ed796572 100644 --- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/client/OpenAiChatClientIT.java +++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/client/OpenAiChatClientIT.java @@ -324,7 +324,7 @@ void multiModalityEmbeddedImage(String modelName) throws IOException { @ValueSource(strings = { "gpt-4o" }) void multiModalityImageUrl(String modelName) throws IOException { - // TODO: add url method that wrapps the checked exception. + // TODO: add url method that wraps the checked exception. URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png"); // @formatter:off @@ -343,7 +343,7 @@ void multiModalityImageUrl(String modelName) throws IOException { @Test void streamingMultiModalityImageUrl() throws IOException { - // TODO: add url method that wrapps the checked exception. + // TODO: add url method that wraps the checked exception. URL url = new URL("https://docs.spring.io/spring-ai/reference/_images/multimodal.test.png"); // @formatter:off diff --git a/spring-ai-test/README.md b/spring-ai-test/README.md index feae3b35cb2..e502a7defa9 100644 --- a/spring-ai-test/README.md +++ b/spring-ai-test/README.md @@ -1,2 +1,48 @@ -TODO: - Documentation and sample tests using the `BasicEvaluationTest`. \ No newline at end of file +# Spring AI Test + +The Spring AI Test module provides utilities and base classes for testing AI applications built with Spring AI. + +## Features + +- **BasicEvaluationTest**: A base test class for evaluating question-answer quality using AI models +- **Vector Store Testing**: Utilities for testing vector store implementations +- **Audio Testing**: Utilities for testing audio-related functionality + +## BasicEvaluationTest + +The `BasicEvaluationTest` class provides a framework for evaluating the quality and relevance of AI-generated answers to questions. + +### Usage + +Extend the `BasicEvaluationTest` class in your test classes: + +```java +@SpringBootTest +public class MyAiEvaluationTest extends BasicEvaluationTest { + + @Test + public void testQuestionAnswerAccuracy() { + String question = "What is the capital of France?"; + String answer = "The capital of France is Paris."; + + // Evaluate if the answer is accurate and related to the question + evaluateQuestionAndAnswer(question, answer, true); + } +} +``` + +### Configuration + +The test requires: +- A `ChatModel` bean (typically OpenAI) +- Evaluation prompt templates located in `classpath:/prompts/spring/test/evaluation/` + +### Evaluation Types + +- **Fact-based evaluation**: Use `factBased = true` for questions requiring factual accuracy +- **General evaluation**: Use `factBased = false` for more subjective questions + +The evaluation process: +1. Checks if the answer is related to the question +2. Evaluates the accuracy/appropriateness of the answer +3. Fails the test with detailed feedback if the answer is inadequate \ No newline at end of file