Easter Eggs
Tips and tricks to explore for advanced users.
Function client SDKs contain a number of undocumented features, usually targeted towards maximizing performance or improving the developer experience.
Monkey Patching in Python
Instead of calling the fxn.predictions.create
method, the Python SDK provides an @fxn.beta.predict
decorator
which monkey-patches an existing function to instead make a prediction:
Creating a Prediction
Apply the @fxn.beta.predict
decorator to a function. When the function is called, it will instead create a prediction
with the provided tag and return the results:
Streaming a Prediction
To instead stream the prediction, add an Iterable
or Generator
return type annotation to the function:
Parsing Pydantic Models
The decorator also supports parsing output objects into Pydantic models by specifying a return type annotation: