Skip to content

Commit

Permalink
Merge pull request #640 from takahirom/takahirom/fix-AssertionImageTy…
Browse files Browse the repository at this point in the history
…pe-api/2025-01-24

Use Actual image instead of Reference image for image assertion
  • Loading branch information
takahirom authored Jan 24, 2025
2 parents 0d074fe + ffa5e84 commit ab6ba5d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class AiAssertionOptions(
val aiAssertions: List<AiAssertion> = emptyList(),
val assertionImageType: AssertionImageType = AssertionImageType.Comparison(),
val systemPrompt: String = when (assertionImageType) {
is AssertionImageType.Reference -> """Evaluate the new image's fulfillment of the user's requirements.
is AssertionImageType.Actual -> """Evaluate the new image's fulfillment of the user's requirements.
The assessment should be based solely on the provided reference image
and the user's input specifications. Focus on whether the new image
meets all functional and design requirements.
Expand Down Expand Up @@ -60,7 +60,7 @@ INPUT_PROMPT

sealed interface AssertionImageType {
class Comparison : AssertionImageType
class Reference : AssertionImageType
class Actual : AssertionImageType
}

data class AiAssertion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class GeminiAiAssertionModel(
val inputPrompt = aiAssertionOptions.inputPrompt(aiAssertionOptions)
val imageFilePath = when (aiAssertionOptions.assertionImageType) {
is AiAssertionOptions.AssertionImageType.Comparison -> comparisonImageFilePath
is AiAssertionOptions.AssertionImageType.Reference -> referenceImageFilePath
is AiAssertionOptions.AssertionImageType.Actual -> actualImageFilePath
}
val inputContent = content {
image(readByteArrayFromFile(imageFilePath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class OpenAiAiAssertionModel(
val inputPrompt = aiAssertionOptions.inputPrompt(aiAssertionOptions)
val imageFilePath = when (aiAssertionOptions.assertionImageType) {
is AiAssertionOptions.AssertionImageType.Comparison -> comparisonImageFilePath
is AiAssertionOptions.AssertionImageType.Reference -> referenceImageFilePath
is AiAssertionOptions.AssertionImageType.Actual -> actualImageFilePath
}
val imageBytes = readByteArrayFromFile(imageFilePath)
val imageBase64 = imageBytes.encodeBase64()
Expand Down

0 comments on commit ab6ba5d

Please sign in to comment.