Skip to main content
Version: v2.0

aixplain.v2.code_utils

Code parsing utilities for v2 utility models.

Adapted from aixplain.modules.model.utils to avoid v1 import chain that triggers env var validation.

UtilityModelInput Objects

@dataclass
class UtilityModelInput()

[view_source]

Input parameter for a utility model.

Attributes:

  • name - The name of the input parameter.
  • description - A description of what this input parameter represents.
  • type - The data type of the input parameter.

validate

def validate()

[view_source]

Validate that the input type is one of TEXT, BOOLEAN, or NUMBER.

to_dict

def to_dict()

[view_source]

Convert to dictionary representation.

parse_code

def parse_code(
code: Union[Text, Callable],
api_key: Optional[Text] = None,
backend_url: Optional[Text] = None) -> Tuple[Text, List, Text, Text]

[view_source]

Parse and process code for utility model creation.

Arguments:

  • code - The code to parse (callable, file path, URL, or raw code string).
  • api_key - API key for authentication when uploading code.
  • backend_url - Backend URL for file upload.

Returns:

Tuple of (code_url, inputs, description, name).

parse_code_decorated

def parse_code_decorated(
code: Union[Text, Callable],
api_key: Optional[Text] = None,
backend_url: Optional[Text] = None) -> Tuple[Text, List, Text, Text]

[view_source]

Parse and process code that may be decorated with @utility_tool.

Arguments:

  • code - The code to parse (decorated/non-decorated callable, file path, URL, or raw string).
  • api_key - API key for authentication when uploading code.
  • backend_url - Backend URL for file upload.

Returns:

Tuple of (code_url, inputs, description, name).