extract function finds and pulls out specific pieces of information. It transforms str → list[T], making it easy to collect:
- Contact details (“email: alice@example.com” → [“alice@example.com”])
- Measurements (“The room is 20.5 feet wide” → [20.5])
- Dates (“Meeting on Jan 15th” → [datetime(2024, 1, 15)])
- Structured data (“Alice (25) and Bob (30)” → [Person(name=“Alice”, age=25), Person(name=“Bob”, age=30)])
extract function is a convenient wrapper around Marvin’s task system - see Tasks for more details.
Usage
Pull email addresses from text:Parameters
data: The input data to extract from (any type)target: The type of data to extract (defaults tostr)instructions: Required when target isstrto specify what to extractagent: Optional custom agent to usethread: Optional thread for conversation contextcontext: Optional additional context
