Include property value of a Pydantic model in Instructor Response
Hi I want to include one of the defined parameter on a BaseModel in the instructor response. Is it possible to include this?
Here is my Model:
class KeyActivity(BaseModel):
activity: str = Field(description="activity phrase.")
unit_type: UnitType = Field(description="The type of unit that the activity can be measured in.")
quantity: float = Field(description="Typical quantity required for the given text.")
@property
def unit(self) -> Literal:
if self.unit_type == 'weight':
return ['g', 'kg', 't', 'lb', 'ton']
elif self.unit_type == 'money':
return ['bhd', 'afn', 'dzd', 'ars']
else:
return [None]
How do I include this unit to provide either of these str value from the options or give None?
2
3 comments
Koushik Debroy
3
Include property value of a Pydantic model in Instructor Response
Data Alchemy
skool.com/data-alchemy
Your Community to Master the Fundamentals of Working with Data and AI — by Datalumina®
Leaderboard (30-day)
powered by