Skip to content

Commit

Permalink
Merge pull request #535 from takahirom/takahirom/fix-naming-of-assert…
Browse files Browse the repository at this point in the history
…Prompt-to-assertionPrompt/2024-11-03

Fix the naming of `assertPrompt` to `assertionPrompt`
  • Loading branch information
takahirom authored Nov 3, 2024
2 parents 094b6b4 + bd582a4 commit 7d1b417
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 22 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down Expand Up @@ -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,
Expand All @@ -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,
),
),
Expand Down
8 changes: 4 additions & 4 deletions docs/topics/ai_powered_image_assertion.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down Expand Up @@ -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,
Expand All @@ -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,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
},
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -87,7 +87,7 @@ class AiManualTest {
},
aiAssertions = listOf(
AiAssertionOptions.AiAssertion(
assertPrompt = "it should have PREVIOUS button",
assertionPrompt = "it should have PREVIOUS button",
requiredFulfillmentPercent = 90,
),
),
Expand Down

0 comments on commit 7d1b417

Please sign in to comment.