OpenAIJudgeModel.predict:v0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import weave
import dspy
from pydantic.main import BaseModel
from pydantic.fields import Field
class JudgeMent(BaseModel):
think_out_loud: str = Field(
description="Think out loud about your eventual judgement"
)
score: float = Field(description="A score between 0 and 1")
judgement: str = Field(description="Output either 'correct' or 'incorrect'")
@weave.op()
def predict(self, base_prompt: str, generated_image: str) -> JudgeMent:
with dspy.context(lm=self._judgement_llm):
judgement = judgement_module(base_prompt, generated_image)
return judgement