Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 44 additions & 10 deletions aixplain/base/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,33 @@

@dataclass
class Parameter:
"""A class representing a single parameter with its properties.

Attributes:
name (str): The name of the parameter.
required (bool): Whether the parameter is required or optional.
value (Optional[Any]): The value of the parameter. Defaults to None.
"""
name: str
required: bool
value: Optional[Any] = None


class BaseParameters:
"""A base class for managing a collection of parameters.

This class provides functionality to store, access, and manipulate parameters
in a structured way. Parameters can be accessed using attribute syntax or
dictionary-style access.

Attributes:
parameters (Dict[str, Parameter]): Dictionary storing Parameter objects.
"""
def __init__(self) -> None:
"""Initialize base parameters class"""
"""Initialize the BaseParameters class.

The initialization creates an empty dictionary to store parameters.
"""
self.parameters: Dict[str, Parameter] = {}

def get_parameter(self, name: str) -> Optional[Parameter]:
Expand All @@ -34,10 +53,14 @@ def to_dict(self) -> Dict[str, Dict[str, Any]]:
return {param.name: {"required": param.required, "value": param.value} for param in self.parameters.values()}

def to_list(self) -> List[str]:
"""Convert parameters back to list format.
"""Convert parameters to a list format.

This method creates a list of dictionaries containing the name and value
of each parameter that has a value set.

Returns:
List[str]: List representation of parameters
List[str]: A list of dictionaries, each containing 'name' and 'value'
keys for parameters that have values set.
"""
return [{"name": param.name, "value": param.value} for param in self.parameters.values() if param.value is not None]

Expand All @@ -59,11 +82,18 @@ def __str__(self) -> str:
return "\n".join(lines)

def __setattr__(self, name: str, value: Any) -> None:
"""Allow setting parameters using attribute syntax (e.g., params.text = "Hello").
"""Allow setting parameters using attribute syntax.

This special method enables setting parameter values using attribute syntax
(e.g., params.text = "Hello"). It only works for parameters that have been
previously defined.

Args:
name (str): Name of the parameter
value (Any): Value to set for the parameter
name (str): Name of the parameter to set.
value (Any): Value to assign to the parameter.

Raises:
AttributeError: If attempting to set a parameter that hasn't been defined.
"""
if name == "parameters": # Allow setting the parameters dict normally
super().__setattr__(name, value)
Expand All @@ -75,16 +105,20 @@ def __setattr__(self, name: str, value: Any) -> None:
raise AttributeError(f"Parameter '{name}' is not defined")

def __getattr__(self, name: str) -> Any:
"""Allow getting parameter values using attribute syntax (e.g., params.text).
"""Allow getting parameter values using attribute syntax.

This special method enables accessing parameter values using attribute syntax
(e.g., params.text). It only works for parameters that have been previously
defined.

Args:
name (str): Name of the parameter
name (str): Name of the parameter to access.

Returns:
Any: Value of the parameter
Any: The value of the requested parameter.

Raises:
AttributeError: If parameter is not defined
AttributeError: If attempting to access a parameter that hasn't been defined.
"""
if name in self.parameters:
return self.parameters[name].value
Expand Down
20 changes: 20 additions & 0 deletions aixplain/decorators/api_key_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@


def check_api_key(method):
"""Decorator to verify that an API key is set before executing the method.

This decorator checks if either TEAM_API_KEY or AIXPLAIN_API_KEY is set in the
configuration. If neither key is set, it raises an exception.

Args:
method (callable): The method to be decorated.

Returns:
callable: The wrapped method that includes API key verification.

Raises:
Exception: If neither TEAM_API_KEY nor AIXPLAIN_API_KEY is set.

Example:
@check_api_key
def my_api_method():
# Method implementation
pass
"""
def wrapper(*args, **kwargs):
if config.TEAM_API_KEY == "" and config.AIXPLAIN_API_KEY == "":
raise Exception(
Expand Down
26 changes: 26 additions & 0 deletions aixplain/enums/asset_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@


class AssetStatus(Text, Enum):
"""Enumeration of possible status values for an asset in the aiXplain system.

This enum defines all possible states that an asset can be in throughout its lifecycle,
from creation to deletion. Each enum value corresponds to a specific state in the
asset's lifecycle.

Attributes:
DRAFT (str): Initial state for a newly created asset.
HIDDEN (str): Asset is hidden from public view.
SCHEDULED (str): Asset is scheduled for processing.
ONBOARDING (str): Asset is in the process of being onboarded.
ONBOARDED (str): Asset has been successfully onboarded.
PENDING (str): Asset is waiting for processing.
FAILED (str): Asset processing has failed.
TRAINING (str): Asset is currently in training.
REJECTED (str): Asset has been rejected.
ENABLING (str): Asset is in the process of being enabled.
DELETING (str): Asset is in the process of being deleted.
DISABLED (str): Asset has been disabled.
DELETED (str): Asset has been deleted.
IN_PROGRESS (str): Asset is currently being processed.
COMPLETED (str): Asset has completed processing.
CANCELING (str): Asset operation is being canceled.
CANCELED (str): Asset operation has been canceled.
DEPRECATED_DRAFT (str): Draft state that has been deprecated.
"""
DRAFT = "draft"
HIDDEN = "hidden"
SCHEDULED = "scheduled"
Expand Down
17 changes: 15 additions & 2 deletions aixplain/enums/code_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@


class CodeInterpreterModel(str, Enum):
"""Code Interpreter Model IDs"""
"""Enumeration of available Code Interpreter model identifiers.

This enum defines the unique identifiers for different code interpreter models
available in the system. Each value represents a specific model's ID that can
be used for code interpretation tasks.

Attributes:
PYTHON_AZURE (str): Model ID for the Python code interpreter running on Azure.
"""

PYTHON_AZURE = "67476fa16eb563d00060ad62"

def __str__(self):
def __str__(self) -> str:
"""Return the string representation of the model ID.

Returns:
str: The model ID value as a string.
"""
return self._value_
10 changes: 10 additions & 0 deletions aixplain/enums/data_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@


class DataSplit(Enum):
"""Enumeration of dataset split types.

This enum defines the standard dataset split types used for machine learning tasks,
including training, validation, and testing splits.

Attributes:
TRAIN (str): Training dataset split used for model training.
VALIDATION (str): Validation dataset split used for model tuning.
TEST (str): Test dataset split used for final model evaluation.
"""
TRAIN = "train"
VALIDATION = "validation"
TEST = "test"
22 changes: 21 additions & 1 deletion aixplain/enums/data_subtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@


class DataSubtype(Enum):
"""Enumeration of data subtypes for categorizing and organizing data.

This enum defines various subtypes that can be used to further categorize
data points within the system, particularly useful for demographic and
content-based categorization.

Attributes:
AGE (str): Age category subtype.
GENDER (str): Gender category subtype.
INTERVAL (str): Time interval subtype.
OTHER (str): Miscellaneous/other subtype.
RACE (str): Race/ethnicity category subtype.
SPLIT (str): Data split category subtype.
TOPIC (str): Content topic subtype.
"""
AGE = "age"
GENDER = "gender"
INTERVAL = "interval"
Expand All @@ -33,5 +48,10 @@ class DataSubtype(Enum):
SPLIT = "split"
TOPIC = "topic"

def __str__(self):
def __str__(self) -> str:
"""Return the string representation of the data subtype.

Returns:
str: The data subtype value as a string.
"""
return self._value_
25 changes: 24 additions & 1 deletion aixplain/enums/data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@


class DataType(str, Enum):
"""Enumeration of supported data types in the aiXplain system.

This enum defines all the data types that can be processed by the system,
including various media types and basic data types.

Attributes:
AUDIO (str): Audio data type.
FLOAT (str): Floating-point number data type.
IMAGE (str): Image data type.
INTEGER (str): Integer number data type.
LABEL (str): Label/category data type.
TENSOR (str): Tensor/multi-dimensional array data type.
TEXT (str): Text data type.
VIDEO (str): Video data type.
EMBEDDING (str): Vector embedding data type.
NUMBER (str): Generic number data type.
BOOLEAN (str): Boolean data type.
"""
AUDIO = "audio"
FLOAT = "float"
IMAGE = "image"
Expand All @@ -37,5 +55,10 @@ class DataType(str, Enum):
NUMBER = "number"
BOOLEAN = "boolean"

def __str__(self):
def __str__(self) -> str:
"""Return the string representation of the data type.

Returns:
str: The data type value as a string.
"""
return self._value_
11 changes: 10 additions & 1 deletion aixplain/enums/database_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@


class DatabaseSourceType(Enum):
"""Enum for database source types"""
"""Enumeration of supported database source types.

This enum defines the different types of database sources that can be used
for data storage and retrieval in the system.

Attributes:
POSTGRESQL (str): PostgreSQL database source type.
SQLITE (str): SQLite database source type.
CSV (str): CSV file source type.
"""

POSTGRESQL = "postgresql"
SQLITE = "sqlite"
Expand Down
18 changes: 17 additions & 1 deletion aixplain/enums/embedding_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,26 @@


class EmbeddingModel(str, Enum):
"""Enumeration of available embedding models in the aiXplain system.

This enum defines the unique identifiers for different embedding models that can
be used to generate vector representations of data.

Attributes:
OPENAI_ADA002 (str): OpenAI's Ada-002 text embedding model ID.
JINA_CLIP_V2_MULTIMODAL (str): Jina CLIP v2 multimodal embedding model ID.
MULTILINGUAL_E5_LARGE (str): Multilingual E5 Large text embedding model ID.
BGE_M3 (str): BGE-M3 embedding model ID.
"""
OPENAI_ADA002 = "6734c55df127847059324d9e"
JINA_CLIP_V2_MULTIMODAL = "67c5f705d8f6a65d6f74d732"
MULTILINGUAL_E5_LARGE = "67efd0772a0a850afa045af3"
BGE_M3 = "67efd4f92a0a850afa045af7"

def __str__(self):
def __str__(self) -> str:
"""Return the string representation of the embedding model ID.

Returns:
str: The model ID value as a string.
"""
return self._value_
23 changes: 23 additions & 0 deletions aixplain/enums/file_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@


class FileType(Enum):
"""Enumeration of supported file types in the aiXplain system.

This enum defines the file extensions for various file formats that can be
processed by the system, including document, audio, image, and video formats.

Attributes:
CSV (str): Comma-separated values file (.csv).
JSON (str): JSON document file (.json).
TXT (str): Plain text file (.txt).
XML (str): XML document file (.xml).
FLAC (str): Free Lossless Audio Codec file (.flac).
MP3 (str): MP3 audio file (.mp3).
WAV (str): Waveform audio file (.wav).
JPEG (str): JPEG image file (.jpeg).
PNG (str): Portable Network Graphics file (.png).
JPG (str): JPEG image file (.jpg).
GIF (str): Graphics Interchange Format file (.gif).
WEBP (str): WebP image file (.webp).
AVI (str): Audio Video Interleave file (.avi).
MP4 (str): MPEG-4 video file (.mp4).
MOV (str): QuickTime movie file (.mov).
MPEG4 (str): MPEG-4 video file (.mpeg4).
"""
CSV = ".csv"
JSON = ".json"
TXT = ".txt"
Expand Down
Loading