Specifying the Function Signature
The prediction function must be a module-level function, and must have parameter and return type annotations:Supported Parameter Types
Muna supports a fixed set of predictor input and output value types. Below are supported type annotations:Floating Point Values
Floating Point Values
Floating-point input and return values should be annotated with the For control over the binary width of the number, use the
float built-in type.numpy.float[16,32,64] types:Integer Values
Integer Values
Integer input and return values should be annotated with the For control over the binary width of the integer, use the
int built-in type.numpy.int[8,16,32,64] types:Boolean Values
Boolean Values
Boolean input and return values must be annotated with the
bool built-in type.Tensor Values
Tensor Values
Tensor input and return values must be annotated with the NumPy Below are the supported element types:
numpy.typing.NDArray[T] type, where T is
the tensor element type.| Numpy data type | Muna data type |
|---|---|
np.float16 | float16 |
np.float32 | float32 |
np.float64 | float64 |
np.int8 | int8 |
np.int16 | int16 |
np.int32 | int32 |
np.int64 | int64 |
np.uint8 | uint8 |
np.uint16 | uint16 |
np.uint32 | uint32 |
np.uint64 | uint64 |
bool | bool |
String Values
String Values
String input and return values must be annotated with the
str built-in type.List Values
List Values
List input and return values must be annotated with the
list[T] built-in type, where T is the element type.Providing an element type
T is optional but strongly recommended because it is used to generate a schema for the parameter or
return value.Dictionary Values
Dictionary Values
Dictionary input and return values can be annotated in one of two ways:
- Using a Pydantic
BaseModelsubclass. - Using the
dict[str, T]built-in type.
Image Values
Image Values
Image input and return values must be annotated with the Pillow
PIL.Image.Image type.Binary Values
Binary Values
Binary input and return values can be annotated in one of three ways:
- Using the
bytesbuilt-in type. - Using the
bytearraybuilt-in type. - Using the
io.BytesIOtype.
Using Parameter Annotations
Muna supports attaching additional annotations to the function’s parameter and return types:- They help users know what input data to provide to the predictor and how to use output data from the predictor, via the parameter
description. - They help users search for predictors using highly detailed queries (e.g. MCP clients).
- They help the Muna client automatically provide familiar interfaces around your prediction function, e.g. with the OpenAI interface.
- They help the Muna website automatically create interactive
visualizersfor your prediction function.
Generic Annotation
Generic Annotation
Use the Below is the full
Parameter.Generic annotation to provide information about a general input or output parameters:predictor.py
Parameter.Generic annotation definition:Numeric Annotation
Numeric Annotation
Use the Below is the full
Parameter.Numeric annotation to specify numeric input or output parameters:calculate_area.py
Parameter.Numeric annotation definition:Audio Annotation
Audio Annotation
Use the Below is the full
Parameter.Audio annotation to specify audio parameters:transcribe_audio.py
Parameter.Audio annotation definition:Audio Speed Annotation
Audio Speed Annotation
Use the Below is the full
Parameter.AudioSpeed annotation to specify audio speed parameters in audio generation predictors:generate_speech.py
Parameter.AudioSpeed annotation definition:Audio Voice Annotation
Audio Voice Annotation
Use the Below is the full
Parameter.AudioVoice annotation to specify audio voice parameters in audio generation predictors:generate_speech.py
Parameter.AudioVoice annotation definition:Bounding Box Annotation
Bounding Box Annotation
Use the Below is the full
Parameter.BoundingBox or Parameter.BoundingBoxes annotations to specify
bounding box parameters in object detection predictors:Parameter.BoundingBox annotation definition:Depth Map Annotation
Depth Map Annotation
Use the Below is the full
Parameter.DepthMap annotation to specify depth map parameters in depth estimation predictors:estimate_depth.py
Parameter.DepthMap annotation definition:Embedding Annotation
Embedding Annotation
Use the Below is the full
Parameter.Embedding annotation to specify vector embedding parameters in embedding predictors:embed_text.py
Parameter.Embedding annotation definition:Embedding Dimensions Annotation
Embedding Dimensions Annotation
Use the Below is the full
Parameter.EmbeddingDims annotation to specify an embedding
Matryoshka dimension parameter in embedding predictors:embed_text.py
Parameter.EmbeddingDims annotation definition:Writing the Function Body
The function body can contain arbitrary Python code. Given that the Muna compiler is currently a proof of concept, it has limited coverage for Python language features. Below is a list of Python language features that we either partially support, or do not support at all:Functions
Functions
| Statement | Status | Notes |
|---|---|---|
| Recursive functions | 🔨 | Recursive functions must have a return type annotation. |
| Lambda expressions | 🚧 | Lambda expressions can be invoked, but cannot be used as objects. |
Literals
Literals
| Collection | Status | Notes |
|---|---|---|
| List literals | 🚧 | List must contain primitive members (e.g. int, str). |
| Dictionary literals | 🚧 | Dictionary must contain primitive members (e.g. int, str). |
| Set literals | 🚧 | Set must contain primitive members (e.g. int, str). |
| Tuple literals | 🚧 | Tuple must contain primitive members (e.g. int, str). |
Classes
Classes
Tracing through classes is not yet supported.
Exceptions
Exceptions
| Statement | Status | Notes |
|---|---|---|
raise statements | 🔨 | |
try..except statement | 🔨 |
Over time the list of unsupported language features will shrink and eventually, will be empty.
Library Coverage
We are adding support for popular libraries, across tensor frameworks, scientific computing, and more:Supported Libraries
Supported Libraries
Below are libraries currently supported by our compiler: