pub struct Signature { /* private fields */ }Expand description
A signature defines the input/output contract for a prediction.
Build with Signature::builder. Field ordering is preserved and deterministic.
Implementations§
Source§impl Signature
impl Signature
Sourcepub fn builder(instructions: impl Into<String>) -> SignatureBuilder
pub fn builder(instructions: impl Into<String>) -> SignatureBuilder
Create a builder for constructing a signature.
Sourcepub fn instructions(&self) -> &str
pub fn instructions(&self) -> &str
The task instructions that guide the language model.
Sourcepub fn input_fields(&self) -> impl Iterator<Item = &FieldDef>
pub fn input_fields(&self) -> impl Iterator<Item = &FieldDef>
Iterate over input fields in declaration order.
Sourcepub fn output_fields(&self) -> impl Iterator<Item = &FieldDef>
pub fn output_fields(&self) -> impl Iterator<Item = &FieldDef>
Iterate over output fields in declaration order.
Sourcepub fn dump_state(&self) -> Result<String>
pub fn dump_state(&self) -> Result<String>
Serialize this signature to a JSON string.
§Errors
Returns a PredictError wrapping a serde_json error if serialization
fails (not expected for valid Signature values).
Sourcepub fn set_instructions(&mut self, instructions: impl Into<String>)
pub fn set_instructions(&mut self, instructions: impl Into<String>)
Update the task instructions.
Sourcepub fn with_prepended_output(&self, field: FieldDef) -> Self
pub fn with_prepended_output(&self, field: FieldDef) -> Self
Return a new signature with an output field prepended before existing outputs.
Used by Predict::chain_of_thought to
inject a reasoning field ahead of the declared outputs.
Sourcepub fn load_state(json: &str) -> Result<Self>
pub fn load_state(json: &str) -> Result<Self>
Deserialize a signature from a JSON string.
§Errors
Returns a PredictError when the JSON is malformed or describes a
signature with no input or output fields.