Skip to main content

Validating inputs

You can validate the inputs to your inference function using Pydantic's validate_call decorator and Python's type hints.

The validation will run every time the deployment is called. Here's an example inference function using validate_call and type hints:

from pydantic import validate_call
from typing import Dict, List

def example_deployment(count: int, names: Dict[str, List[float]]):


In the example, validate_call will ensure that the first argument is an integer and the second is a dictionary with strings as keys and lists of floats as values.

The validate_call wrapper also handles type conversion, when possible. If the string "1" was sent as the first argument to example above then it would get converted from a string to the number 1.