From bd582a45410e7abe37a8b1f57282531b1d222dc3 Mon Sep 17 00:00:00 2001 From: takahirom Date: Sun, 3 Nov 2024 21:45:29 +0900 Subject: [PATCH] Fix the naming of `assertPrompt` to `assertionPrompt` --- README.md | 8 ++++---- docs/topics/ai_powered_image_assertion.md | 8 ++++---- .../com/github/takahirom/roborazzi/RoborazziOptions.kt | 7 ++++--- .../com/github/takahirom/roborazzi/AiAssertionOptions.kt | 4 ++-- .../com/github/takahirom/roborazzi/CaptureResult.kt | 2 +- .../com/github/takahirom/roborazzi/GeminiRoborazziAi.kt | 2 +- .../com/github/takahirom/roborazzi/OpenAiRoborazziAi.kt | 2 +- .../github/takahirom/roborazzi/sample/GeminiAiAiTest.kt | 4 ++-- .../com/github/takahirom/roborazzi/sample/OpenAiTest.kt | 4 ++-- .../takahirom/roborazzi/sample/boxed/AiManualTest.kt | 4 ++-- 10 files changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index f0fb2ecd..36fd3c33 100644 --- a/README.md +++ b/README.md @@ -1105,11 +1105,11 @@ fun captureWithAi() { .captureRoboImage( roborazziOptions = provideRoborazziContext().options.addedAiAssertions( AiAssertionOptions.AiAssertion( - assertPrompt = "it should have PREVIOUS button", + assertionPrompt = "it should have PREVIOUS button", requiredFulfillmentPercent = 90, ), AiAssertionOptions.AiAssertion( - assertPrompt = "it should show First Fragment", + assertionPrompt = "it should show First Fragment", requiredFulfillmentPercent = 90, ) ) @@ -1151,7 +1151,7 @@ compareOptions = RoborazziOptions.CompareOptions( return AiAssertionResults( aiAssertionResults = aiAssertionOptions.aiAssertions.map { assertion -> AiAssertionResult( - assertPrompt = assertion.assertPrompt, + assertionPrompt = assertion.assertionPrompt, fulfillmentPercent = fulfillmentPercent, requiredFulfillmentPercent = assertion.requiredFulfillmentPercent, failIfNotFulfilled = assertion.failIfNotFulfilled, @@ -1163,7 +1163,7 @@ compareOptions = RoborazziOptions.CompareOptions( }, aiAssertions = listOf( AiAssertionOptions.AiAssertion( - assertPrompt = "it should have PREVIOUS button", + assertionPrompt = "it should have PREVIOUS button", requiredFulfillmentPercent = 90, ), ), diff --git a/docs/topics/ai_powered_image_assertion.md b/docs/topics/ai_powered_image_assertion.md index 31eb8181..9e708b84 100644 --- a/docs/topics/ai_powered_image_assertion.md +++ b/docs/topics/ai_powered_image_assertion.md @@ -34,11 +34,11 @@ fun captureWithAi() { .captureRoboImage( roborazziOptions = provideRoborazziContext().options.addedAiAssertions( AiAssertionOptions.AiAssertion( - assertPrompt = "it should have PREVIOUS button", + assertionPrompt = "it should have PREVIOUS button", requiredFulfillmentPercent = 90, ), AiAssertionOptions.AiAssertion( - assertPrompt = "it should show First Fragment", + assertionPrompt = "it should show First Fragment", requiredFulfillmentPercent = 90, ) ) @@ -80,7 +80,7 @@ compareOptions = RoborazziOptions.CompareOptions( return AiAssertionResults( aiAssertionResults = aiAssertionOptions.aiAssertions.map { assertion -> AiAssertionResult( - assertPrompt = assertion.assertPrompt, + assertionPrompt = assertion.assertionPrompt, fulfillmentPercent = fulfillmentPercent, requiredFulfillmentPercent = assertion.requiredFulfillmentPercent, failIfNotFulfilled = assertion.failIfNotFulfilled, @@ -92,7 +92,7 @@ compareOptions = RoborazziOptions.CompareOptions( }, aiAssertions = listOf( AiAssertionOptions.AiAssertion( - assertPrompt = "it should have PREVIOUS button", + assertionPrompt = "it should have PREVIOUS button", requiredFulfillmentPercent = 90, ), ), diff --git a/include-build/roborazzi-core/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/RoborazziOptions.kt b/include-build/roborazzi-core/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/RoborazziOptions.kt index 3ba3a2b8..de4aeb33 100644 --- a/include-build/roborazzi-core/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/RoborazziOptions.kt +++ b/include-build/roborazzi-core/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/RoborazziOptions.kt @@ -178,7 +178,8 @@ data class RoborazziOptions( if (conditionResult.fulfillmentPercent < conditionResult.requiredFulfillmentPercent!!) { throw AssertionError( "The generated image did not meet the required prompt fulfillment percentage.\n" + - "prompt:${conditionResult.assertPrompt}\n" + + "assertionPrompt:${conditionResult.assertionPrompt}\n" + + "failIfNotFulfilled:${conditionResult.failIfNotFulfilled}\n" + "aiAssertion.fulfillmentPercent:${conditionResult.fulfillmentPercent}\n" + "requiredFulfillmentPercent:${conditionResult.requiredFulfillmentPercent}\n" + "explanation:${conditionResult.explanation}" @@ -247,12 +248,12 @@ data class RoborazziOptions( @ExperimentalRoborazziApi fun addedAiAssertion( - assert: String, + assertionPrompt: String, requiredFulfillmentPercent: Int ): RoborazziOptions { return addedAiAssertions( AiAssertionOptions.AiAssertion( - assertPrompt = assert, + assertionPrompt = assertionPrompt, requiredFulfillmentPercent = requiredFulfillmentPercent ) ) diff --git a/include-build/roborazzi-core/src/commonMain/kotlin/com/github/takahirom/roborazzi/AiAssertionOptions.kt b/include-build/roborazzi-core/src/commonMain/kotlin/com/github/takahirom/roborazzi/AiAssertionOptions.kt index a58d7f11..d3f0766c 100644 --- a/include-build/roborazzi-core/src/commonMain/kotlin/com/github/takahirom/roborazzi/AiAssertionOptions.kt +++ b/include-build/roborazzi-core/src/commonMain/kotlin/com/github/takahirom/roborazzi/AiAssertionOptions.kt @@ -20,7 +20,7 @@ INPUT_PROMPT val inputPrompt: (AiAssertionOptions) -> String = { aiOptions -> buildString { aiOptions.aiAssertions.forEachIndexed { index, aiAssertion -> - appendLine("Assertion ${index + 1}: ${aiAssertion.assertPrompt}\n") + appendLine("Assertion ${index + 1}: ${aiAssertion.assertionPrompt}\n") } } }, @@ -40,7 +40,7 @@ INPUT_PROMPT } data class AiAssertion( - val assertPrompt: String, + val assertionPrompt: String, val failIfNotFulfilled: Boolean = true, /** * If null, the AI result is not validated. But the fulfillment_percent are still included in the report. diff --git a/include-build/roborazzi-core/src/commonMain/kotlin/com/github/takahirom/roborazzi/CaptureResult.kt b/include-build/roborazzi-core/src/commonMain/kotlin/com/github/takahirom/roborazzi/CaptureResult.kt index 0ad34576..2aee2175 100644 --- a/include-build/roborazzi-core/src/commonMain/kotlin/com/github/takahirom/roborazzi/CaptureResult.kt +++ b/include-build/roborazzi-core/src/commonMain/kotlin/com/github/takahirom/roborazzi/CaptureResult.kt @@ -145,7 +145,7 @@ data class AiAssertionResults( @Serializable data class AiAssertionResult( @SerialName("assert_prompt") - val assertPrompt: String, + val assertionPrompt: String, @SerialName("required_fulfillment_percent") val requiredFulfillmentPercent: Int?, @SerialName("fail_if_not_fulfilled") diff --git a/roborazzi-ai-gemini/src/commonMain/kotlin/com/github/takahirom/roborazzi/GeminiRoborazziAi.kt b/roborazzi-ai-gemini/src/commonMain/kotlin/com/github/takahirom/roborazzi/GeminiRoborazziAi.kt index fa903d85..64482c97 100644 --- a/roborazzi-ai-gemini/src/commonMain/kotlin/com/github/takahirom/roborazzi/GeminiRoborazziAi.kt +++ b/roborazzi-ai-gemini/src/commonMain/kotlin/com/github/takahirom/roborazzi/GeminiRoborazziAi.kt @@ -94,7 +94,7 @@ class GeminiAiAssertionModel( explanation = "AI model did not return a result for this assertion" ) AiAssertionResult( - assertPrompt = condition.assertPrompt, + assertionPrompt = condition.assertionPrompt, requiredFulfillmentPercent = condition.requiredFulfillmentPercent, failIfNotFulfilled = condition.failIfNotFulfilled, fulfillmentPercent = assertResult.fulfillmentPercent, diff --git a/roborazzi-ai-openai/src/commonMain/kotlin/com/github/takahirom/roborazzi/OpenAiRoborazziAi.kt b/roborazzi-ai-openai/src/commonMain/kotlin/com/github/takahirom/roborazzi/OpenAiRoborazziAi.kt index 1b007d43..1f5d848d 100644 --- a/roborazzi-ai-openai/src/commonMain/kotlin/com/github/takahirom/roborazzi/OpenAiRoborazziAi.kt +++ b/roborazzi-ai-openai/src/commonMain/kotlin/com/github/takahirom/roborazzi/OpenAiRoborazziAi.kt @@ -195,7 +195,7 @@ private fun parseOpenAiResponse( val fulfillmentPercent = result?.fulfillmentPercent ?: 0 val explanation = result?.explanation ?: "AI model did not return a result for this assertion" AiAssertionResult( - assertPrompt = condition.assertPrompt, + assertionPrompt = condition.assertionPrompt, requiredFulfillmentPercent = condition.requiredFulfillmentPercent, failIfNotFulfilled = condition.failIfNotFulfilled, fulfillmentPercent = fulfillmentPercent, diff --git a/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/GeminiAiAiTest.kt b/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/GeminiAiAiTest.kt index 44b9117a..4e04d022 100644 --- a/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/GeminiAiAiTest.kt +++ b/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/GeminiAiAiTest.kt @@ -60,11 +60,11 @@ class GeminiAiAiTest { .captureRoboImage( roborazziOptions = provideRoborazziContext().options.addedAiAssertions( AiAssertionOptions.AiAssertion( - assertPrompt = "it should have PREVIOUS button", + assertionPrompt = "it should have PREVIOUS button", requiredFulfillmentPercent = 90, ), AiAssertionOptions.AiAssertion( - assertPrompt = "it should show First Fragment", + assertionPrompt = "it should show First Fragment", requiredFulfillmentPercent = 90, ) ) diff --git a/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/OpenAiTest.kt b/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/OpenAiTest.kt index 188ce835..ae9deb92 100644 --- a/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/OpenAiTest.kt +++ b/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/OpenAiTest.kt @@ -61,11 +61,11 @@ class OpenAiTest { .captureRoboImage( roborazziOptions = provideRoborazziContext().options.addedAiAssertions( AiAssertionOptions.AiAssertion( - assertPrompt = "it should have PREVIOUS button", + assertionPrompt = "it should have PREVIOUS button", requiredFulfillmentPercent = 90, ), AiAssertionOptions.AiAssertion( - assertPrompt = "it should show First Fragment", + assertionPrompt = "it should show First Fragment", requiredFulfillmentPercent = 90, ) ) diff --git a/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/boxed/AiManualTest.kt b/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/boxed/AiManualTest.kt index ad903933..dedfb948 100644 --- a/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/boxed/AiManualTest.kt +++ b/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/boxed/AiManualTest.kt @@ -75,7 +75,7 @@ class AiManualTest { return AiAssertionResults( aiAssertionResults = aiAssertionOptions.aiAssertions.map { assertion -> AiAssertionResult( - assertPrompt = assertion.assertPrompt, + assertionPrompt = assertion.assertionPrompt, fulfillmentPercent = fulfillmentPercent, requiredFulfillmentPercent = assertion.requiredFulfillmentPercent, failIfNotFulfilled = assertion.failIfNotFulfilled, @@ -87,7 +87,7 @@ class AiManualTest { }, aiAssertions = listOf( AiAssertionOptions.AiAssertion( - assertPrompt = "it should have PREVIOUS button", + assertionPrompt = "it should have PREVIOUS button", requiredFulfillmentPercent = 90, ), ),