Skip to content

latent.optimize.dspy.signatures

DSPy Signature construction from ScoredModel and BaseAgent.

Functions

agent_signature

agent_signature(name: str, description: str, output_type: type[BaseModel] | None = None) -> Any

Build a generic dspy.Signature for a BaseAgent subclass.

Args: name: Agent name (used as signature class name). description: Agent description (used as docstring / instructions). output_type: Optional Pydantic output model. If provided, delegates to scored_model_to_signature.

Returns: A dspy.Signature subclass.

scored_model_to_signature

scored_model_to_signature(output_type: type[BaseModel]) -> Any

Build a dspy.Signature class from a ScoredModel output type.

Creates: - One InputField: text (the text to evaluate) - One OutputField per scored field - One OutputField per {field}_rationale field

Args: output_type: Pydantic model (typically ScoredModel subclass) with Annotated score fields.

Returns: A dspy.Signature subclass.