cast
function is your bridge between natural language and structured data types. It transforms str → T
while preserving meaning, making it easy to convert:
- Natural numbers (“three point five” → 3.5)
- Casual responses (“sounds good” → True)
- Time expressions (“next Tuesday” → datetime)
- Rich descriptions (“John is 25” → Person(name=“John”, age=25))
cast
function is a convenient wrapper around Marvin’s task system - see Tasks for more details.
Usage
Convert natural language descriptions of numbers into their numeric representation:Parameters
data
: The input data to convert (any type)target
: The target type to convert to (defaults tostr
)instructions
: Optional instructions to guide the conversionagent
: Optional custom agent to usethread
: Optional thread for conversation contextcontext
: Optional additional context