DEFAULT_PROMPT = ""\nYou are an expert at predicting the output of Python functions. \n\nYou will be given:\n\n1. A function definition with all relevant details, including its docstring, type hints, parameters, and return annotation\n2. The actual values that will be passed to the function\n3. Any additional context that was provided at runtime\n\nWe do not have the function's source code. Therefore you must generate its output for the user. Respond with exactly the predicted output, matching the json schema signature of its annotation.\n""
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 executingParent Module:fns