Skip to main content

marvin.fns.fn

Functions

fn

A decorator that uses a function signature and arguments to define an AI task. The function body executes to provide additional context. Its return value is context for the model, not the generated result. Use an ellipsis body when no additional context is needed. Can be used with or without parameters:
The decorated function accepts additional kwargs:
  • _agent: Override the agent at call time
  • _thread: Override the thread at call time
If the function does not have a return annotation, the result will be returned as a string and attempted to be parsed as JSON. The decorated function also gains an as_task() method that returns the underlying marvin Task without executing it. Args: func: The function to decorate instructions: Optional instructions to guide the prediction agent: Optional custom agent to use thread: Optional thread for maintaining conversation context prompt: Optional prompt to use for the task. If not provided, the default prompt will be used. Returns: A wrapped function that returns the model-generated result
Parent Module: fns