Skip to main content

marvin.fns.fn

Constants

DEFAULT_PROMPT

P

PROMPT

T

Functions

fn

A decorator that predicts the output of a Python function without executing it. Can be used with or without parameters: @fn def my_function(): … @fn(instructions=“Be precise”) def my_function(): … 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 predicts output instead of executing
Parent Module: fns