Skip to content

Commit

Permalink
Merge pull request #639 from takahirom/takahirom/use-class-instead-of…
Browse files Browse the repository at this point in the history
…-object-to-maintain-compatibility/2025-01-24

Use class instead of object to maintain compatibility
  • Loading branch information
takahirom authored Jan 24, 2025
2 parents b5fe683 + 37dfba0 commit 0d074fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ package com.github.takahirom.roborazzi
data class AiAssertionOptions(
val aiAssertionModel: AiAssertionModel,
val aiAssertions: List<AiAssertion> = emptyList(),
val assertionImageType: AssertionImageType = AssertionImageType.Comparison,
val assertionImageType: AssertionImageType = AssertionImageType.Comparison(),
val systemPrompt: String = when (assertionImageType) {
AssertionImageType.Reference -> """Evaluate the new image's fulfillment of the user's requirements.
is AssertionImageType.Reference -> """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 All @@ -20,7 +20,7 @@ For each assertion:
- A justification based on requirement adherence rather than visual differences
"""

AssertionImageType.Comparison -> """Evaluate the following assertion for fulfillment in the new image.
is AssertionImageType.Comparison -> """Evaluate the following assertion for fulfillment in the new image.
The evaluation should be based on the comparison between the original image
on the left and the new image on the right, with differences highlighted in red
in the center. Focus on whether the new image fulfills the requirement specified
Expand Down Expand Up @@ -59,8 +59,8 @@ INPUT_PROMPT
}

sealed interface AssertionImageType {
data object Comparison : AssertionImageType
data object Reference : AssertionImageType
class Comparison : AssertionImageType
class Reference : AssertionImageType
}

data class AiAssertion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class GeminiAiAssertionModel(

val inputPrompt = aiAssertionOptions.inputPrompt(aiAssertionOptions)
val imageFilePath = when (aiAssertionOptions.assertionImageType) {
AiAssertionOptions.AssertionImageType.Comparison -> comparisonImageFilePath
AiAssertionOptions.AssertionImageType.Reference -> referenceImageFilePath
is AiAssertionOptions.AssertionImageType.Comparison -> comparisonImageFilePath
is AiAssertionOptions.AssertionImageType.Reference -> referenceImageFilePath
}
val inputContent = content {
image(readByteArrayFromFile(imageFilePath))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class OpenAiAiAssertionModel(
val template = aiAssertionOptions.promptTemplate
val inputPrompt = aiAssertionOptions.inputPrompt(aiAssertionOptions)
val imageFilePath = when (aiAssertionOptions.assertionImageType) {
AiAssertionOptions.AssertionImageType.Comparison -> comparisonImageFilePath
AiAssertionOptions.AssertionImageType.Reference -> referenceImageFilePath
is AiAssertionOptions.AssertionImageType.Comparison -> comparisonImageFilePath
is AiAssertionOptions.AssertionImageType.Reference -> referenceImageFilePath
}
val imageBytes = readByteArrayFromFile(imageFilePath)
val imageBase64 = imageBytes.encodeBase64()
Expand Down

0 comments on commit 0d074fe

Please sign in to comment.