pub struct FieldDef {
pub name: String,
pub description: String,
pub field_type: FieldType,
pub kind: FieldKind,
pub cacheable: bool,
pub examples: Vec<Value>,
}Expand description
A top-level field definition within a Signature.
Fields§
§name: StringThe field name.
description: StringA human-readable description of the field.
field_type: FieldTypeThe type of this field.
kind: FieldKindWhether this is an input or output field.
cacheable: boolWhether this input field’s value is stable across calls within a
conversation and therefore eligible to sit inside the cacheable
prefix of the user message. Default false (backwards-compatible):
only fields a application explicitly declares stable are cached. The
ChatAdapter places a cache breakpoint after
the last cacheable input field; meaningless on output fields.
examples: Vec<Value>Concrete example values for this field, sourced from the
JSON Schema examples keyword on the originating schema. Rendered
in the system prompt under the field’s description so the model
sees “what good output looks like” without bloating the
instructions string. Defaults to empty; the schema converter
caps at the first three examples to bound prompt size.
Implementations§
Source§impl FieldDef
impl FieldDef
Sourcepub fn input(
name: impl Into<String>,
field_type: FieldType,
description: impl Into<String>,
) -> Self
pub fn input( name: impl Into<String>, field_type: FieldType, description: impl Into<String>, ) -> Self
Create an input field definition.
field_type sits between the two String args by design: it’s the
only non-string positional arg, so callers cannot silently
transpose name and description without a compile error from
the misplaced FieldType enum value.
Sourcepub fn output(
name: impl Into<String>,
field_type: FieldType,
description: impl Into<String>,
) -> Self
pub fn output( name: impl Into<String>, field_type: FieldType, description: impl Into<String>, ) -> Self
Create an output field definition. See Self::input for the
rationale behind the arg order (field_type between the two
String args).
Sourcepub fn with_examples(self, examples: Vec<Value>) -> Self
pub fn with_examples(self, examples: Vec<Value>) -> Self
Attach concrete example values to this field. Builder-style for
test ergonomics — production paths populate Self::examples
directly via the JSON Schema converter in schema.rs.