dspy
dspy copied to clipboard
Field descriptions for individual items in a Pydantic model
from pydantic import BaseModel, Field
from dspy.functional import TypedPredictor
class TravelInformation(BaseModel):
origin: str = Field(pattern=r"^[A-Z]{3}$")
destination: str = Field(pattern=r"^[A-Z]{3}$")
date: datetime.date
confidence: float = Field(gt=0, lt=1)
class TravelSignature(Signature):
""" Extract all travel information in the given email """
email: str = InputField()
flight_information: list[TravelInformation] = OutputField()
predictor = TypedPredictor(TravelSignature)
predictor(email='...')
The README contains this example for using Pydantic types within a Signature. Is there a way to provide descriptions for individual properties in the Pydantic model that will be used by the prompt?