├── .env.example ├── .github └── workflows │ └── main.yaml ├── .gitignore ├── .pre-commit-config.yaml ├── LICENSE ├── README.md ├── aixplain ├── __init__.py ├── base │ └── parameters.py ├── cli_groups.py ├── decorators │ ├── __init__.py │ └── api_key_checker.py ├── enums │ ├── __init__.py │ ├── asset_status.py │ ├── code_interpreter.py │ ├── data_split.py │ ├── data_subtype.py │ ├── data_type.py │ ├── database_source.py │ ├── embedding_model.py │ ├── error_handler.py │ ├── evolve_type.py │ ├── file_type.py │ ├── function.py │ ├── function_type.py │ ├── index_stores.py │ ├── language.py │ ├── license.py │ ├── onboard_status.py │ ├── ownership_type.py │ ├── privacy.py │ ├── response_status.py │ ├── sort_by.py │ ├── sort_order.py │ ├── splitting_options.py │ ├── status.py │ ├── storage_type.py │ └── supplier.py ├── exceptions │ ├── __init__.py │ └── types.py ├── factories │ ├── __init__.py │ ├── agent_factory │ │ ├── __init__.py │ │ └── utils.py │ ├── api_key_factory.py │ ├── asset_factory.py │ ├── benchmark_factory.py │ ├── cli │ │ └── model_factory_cli.py │ ├── corpus_factory.py │ ├── data_factory.py │ ├── dataset_factory.py │ ├── file_factory.py │ ├── finetune_factory │ │ ├── __init__.py │ │ └── prompt_validator.py │ ├── index_factory │ │ ├── __init__.py │ │ └── utils.py │ ├── integration_factory.py │ ├── metric_factory.py │ ├── model_factory │ │ ├── __init__.py │ │ ├── mixins │ │ │ ├── __init__.py │ │ │ ├── model_getter.py │ │ │ └── model_list.py │ │ └── utils.py │ ├── pipeline_factory │ │ ├── __init__.py │ │ └── utils.py │ ├── script_factory.py │ ├── team_agent_factory │ │ ├── __init__.py │ │ ├── inspector_factory.py │ │ └── utils.py │ ├── tool_factory.py │ └── wallet_factory.py ├── modules │ ├── __init__.py │ ├── agent │ │ ├── __init__.py │ │ ├── agent_response.py │ │ ├── agent_response_data.py │ │ ├── agent_task.py │ │ ├── evolve_param.py │ │ ├── model_with_params.py │ │ ├── output_format.py │ │ ├── tool │ │ │ ├── __init__.py │ │ │ ├── custom_python_code_tool.py │ │ │ ├── model_tool.py │ │ │ ├── pipeline_tool.py │ │ │ ├── python_interpreter_tool.py │ │ │ └── sql_tool.py │ │ └── utils.py │ ├── api_key.py │ ├── asset.py │ ├── benchmark.py │ ├── benchmark_job.py │ ├── content_interval.py │ ├── corpus.py │ ├── data.py │ ├── dataset.py │ ├── file.py │ ├── finetune │ │ ├── __init__.py │ │ ├── cost.py │ │ ├── hyperparameters.py │ │ └── status.py │ ├── metadata.py │ ├── metric.py │ ├── mixins.py │ ├── model │ │ ├── __init__.py │ │ ├── connection.py │ │ ├── index_model.py │ │ ├── integration.py │ │ ├── llm_model.py │ │ ├── mcp_connection.py │ │ ├── model_parameters.py │ │ ├── model_response_streamer.py │ │ ├── record.py │ │ ├── response.py │ │ ├── utility_model.py │ │ └── utils.py │ ├── pipeline │ │ ├── __init__.py │ │ ├── asset.py │ │ ├── default.py │ │ ├── designer │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── base.py │ │ │ ├── enums.py │ │ │ ├── mixins.py │ │ │ ├── nodes.py │ │ │ ├── pipeline.py │ │ │ └── utils.py │ │ ├── pipeline.py │ │ └── response.py │ ├── team_agent │ │ ├── __init__.py │ │ ├── evolver_response_data.py │ │ └── inspector.py │ └── wallet.py ├── processes │ ├── __init__.py │ └── data_onboarding │ │ ├── __init__.py │ │ ├── onboard_functions.py │ │ ├── process_media_files.py │ │ └── process_text_files.py ├── utils │ ├── __init__.py │ ├── asset_cache.py │ ├── cache_utils.py │ ├── config.py │ ├── convert_datatype_utils.py │ ├── evolve_utils.py │ ├── file_utils.py │ ├── llm_utils.py │ ├── request_utils.py │ └── validation_utils.py └── v2 │ ├── __init__.py │ ├── agent.py │ ├── api_key.py │ ├── benchmark.py │ ├── client.py │ ├── core.py │ ├── corpus.py │ ├── data.py │ ├── dataset.py │ ├── enums.py │ ├── enums_include.py │ ├── file.py │ ├── finetune.py │ ├── metric.py │ ├── model.py │ ├── pipeline.py │ ├── resource.py │ ├── script.py │ ├── team_agent.py │ └── wallet.py ├── docs ├── README.md ├── api-reference │ └── python │ │ ├── aixplain │ │ ├── base │ │ │ └── parameters.md │ │ ├── cli_groups.md │ │ ├── decorators │ │ │ ├── api_key_checker.md │ │ │ └── init.md │ │ ├── enums │ │ │ ├── asset_status.md │ │ │ ├── code_interpreter.md │ │ │ ├── data_split.md │ │ │ ├── data_subtype.md │ │ │ ├── data_type.md │ │ │ ├── database_source.md │ │ │ ├── embedding_model.md │ │ │ ├── error_handler.md │ │ │ ├── evolve_type.md │ │ │ ├── file_type.md │ │ │ ├── function.md │ │ │ ├── function_type.md │ │ │ ├── index_stores.md │ │ │ ├── init.md │ │ │ ├── language.md │ │ │ ├── license.md │ │ │ ├── onboard_status.md │ │ │ ├── ownership_type.md │ │ │ ├── privacy.md │ │ │ ├── response_status.md │ │ │ ├── sort_by.md │ │ │ ├── sort_order.md │ │ │ ├── splitting_options.md │ │ │ ├── status.md │ │ │ ├── storage_type.md │ │ │ └── supplier.md │ │ ├── exceptions │ │ │ ├── init.md │ │ │ └── types.md │ │ ├── factories │ │ │ ├── agent_factory │ │ │ │ ├── init.md │ │ │ │ └── utils.md │ │ │ ├── api_key_factory.md │ │ │ ├── asset_factory.md │ │ │ ├── benchmark_factory.md │ │ │ ├── cli │ │ │ │ └── model_factory_cli.md │ │ │ ├── corpus_factory.md │ │ │ ├── data_factory.md │ │ │ ├── dataset_factory.md │ │ │ ├── file_factory.md │ │ │ ├── finetune_factory │ │ │ │ ├── init.md │ │ │ │ └── prompt_validator.md │ │ │ ├── index_factory │ │ │ │ ├── init.md │ │ │ │ └── utils.md │ │ │ ├── init.md │ │ │ ├── integration_factory.md │ │ │ ├── metric_factory.md │ │ │ ├── model_factory │ │ │ │ ├── init.md │ │ │ │ ├── mixins │ │ │ │ │ ├── init.md │ │ │ │ │ ├── model_getter.md │ │ │ │ │ └── model_list.md │ │ │ │ └── utils.md │ │ │ ├── pipeline_factory │ │ │ │ ├── init.md │ │ │ │ └── utils.md │ │ │ ├── script_factory.md │ │ │ ├── team_agent_factory │ │ │ │ ├── init.md │ │ │ │ ├── inspector_factory.md │ │ │ │ └── utils.md │ │ │ ├── tool_factory.md │ │ │ └── wallet_factory.md │ │ ├── init.md │ │ ├── modules │ │ │ ├── agent │ │ │ │ ├── agent_response.md │ │ │ │ ├── agent_response_data.md │ │ │ │ ├── agent_task.md │ │ │ │ ├── evolve_param.md │ │ │ │ ├── init.md │ │ │ │ ├── model_with_params.md │ │ │ │ ├── output_format.md │ │ │ │ ├── tool │ │ │ │ │ ├── custom_python_code_tool.md │ │ │ │ │ ├── init.md │ │ │ │ │ ├── model_tool.md │ │ │ │ │ ├── pipeline_tool.md │ │ │ │ │ ├── python_interpreter_tool.md │ │ │ │ │ └── sql_tool.md │ │ │ │ └── utils.md │ │ │ ├── api_key.md │ │ │ ├── asset.md │ │ │ ├── benchmark.md │ │ │ ├── benchmark_job.md │ │ │ ├── content_interval.md │ │ │ ├── corpus.md │ │ │ ├── data.md │ │ │ ├── dataset.md │ │ │ ├── file.md │ │ │ ├── finetune │ │ │ │ ├── cost.md │ │ │ │ ├── hyperparameters.md │ │ │ │ ├── init.md │ │ │ │ └── status.md │ │ │ ├── init.md │ │ │ ├── metadata.md │ │ │ ├── metric.md │ │ │ ├── mixins.md │ │ │ ├── model │ │ │ │ ├── connection.md │ │ │ │ ├── index_model.md │ │ │ │ ├── init.md │ │ │ │ ├── integration.md │ │ │ │ ├── llm_model.md │ │ │ │ ├── mcp_connection.md │ │ │ │ ├── model_parameters.md │ │ │ │ ├── model_response_streamer.md │ │ │ │ ├── record.md │ │ │ │ ├── response.md │ │ │ │ ├── utility_model.md │ │ │ │ └── utils.md │ │ │ ├── pipeline │ │ │ │ ├── asset.md │ │ │ │ ├── default.md │ │ │ │ ├── designer │ │ │ │ │ ├── base.md │ │ │ │ │ ├── enums.md │ │ │ │ │ ├── init.md │ │ │ │ │ ├── mixins.md │ │ │ │ │ ├── nodes.md │ │ │ │ │ ├── pipeline.md │ │ │ │ │ └── utils.md │ │ │ │ ├── init.md │ │ │ │ ├── pipeline.md │ │ │ │ └── response.md │ │ │ ├── team_agent │ │ │ │ ├── evolver_response_data.md │ │ │ │ ├── init.md │ │ │ │ └── inspector.md │ │ │ └── wallet.md │ │ ├── processes │ │ │ ├── data_onboarding │ │ │ │ ├── init.md │ │ │ │ ├── onboard_functions.md │ │ │ │ ├── process_media_files.md │ │ │ │ └── process_text_files.md │ │ │ └── init.md │ │ ├── utils │ │ │ ├── asset_cache.md │ │ │ ├── cache_utils.md │ │ │ ├── config.md │ │ │ ├── convert_datatype_utils.md │ │ │ ├── evolve_utils.md │ │ │ ├── file_utils.md │ │ │ ├── init.md │ │ │ ├── llm_utils.md │ │ │ ├── request_utils.md │ │ │ └── validation_utils.md │ │ └── v2 │ │ │ ├── agent.md │ │ │ ├── api_key.md │ │ │ ├── benchmark.md │ │ │ ├── client.md │ │ │ ├── core.md │ │ │ ├── corpus.md │ │ │ ├── data.md │ │ │ ├── dataset.md │ │ │ ├── enums.md │ │ │ ├── enums_include.md │ │ │ ├── file.md │ │ │ ├── finetune.md │ │ │ ├── init.md │ │ │ ├── metric.md │ │ │ ├── model.md │ │ │ ├── pipeline.md │ │ │ ├── resource.md │ │ │ ├── script.md │ │ │ ├── team_agent.md │ │ │ └── wallet.md │ │ └── api_sidebar.js └── assets │ ├── aixplain-brandmark-line.png │ └── aixplain-workflow-teamagent.png ├── generate.py ├── pipeline_test2.ipynb ├── post_process_docs.py ├── pydoc-markdown.yml ├── pyproject.toml ├── pytest.ini ├── ruff.toml ├── setup.cfg └── tests ├── __init__.py ├── conftest.py ├── functional ├── agent │ ├── agent_functional_test.py │ ├── agent_mcp_deploy_test.py │ └── data │ │ └── agent_test_end2end.json ├── apikey │ ├── README.md │ ├── apikey.json │ └── test_api.py ├── benchmark │ ├── benchmark_functional_test.py │ └── data │ │ ├── benchmark_module_test_data.json │ │ ├── benchmark_test_run_data.json │ │ └── benchmark_test_with_parameters.json ├── data_asset │ ├── __init__.py │ ├── corpus_onboarding_test.py │ ├── dataset_onboarding_test.py │ └── input │ │ ├── audio-en_url.csv │ │ ├── audio-en_with_invalid_split_url.csv │ │ └── audio-en_with_split_url.csv ├── file_asset │ ├── __init__.py │ ├── file_create_test.py │ └── input │ │ └── test.csv ├── finetune │ ├── __init__.py │ ├── data │ │ ├── finetune_test_cost_estimation.json │ │ ├── finetune_test_end2end.json │ │ ├── finetune_test_list_data.json │ │ └── finetune_test_prompt_validator.json │ └── finetune_functional_test.py ├── general_assets │ ├── asset_functional_test.py │ └── data │ │ └── asset_run_test_data.json ├── model │ ├── data │ │ ├── test_file_parser_input.pdf │ │ └── test_input.txt │ ├── run_connect_model_test.py │ ├── run_model_test.py │ └── run_utility_model_test.py ├── pipelines │ ├── create_test.py │ ├── data │ │ ├── pipeline.json │ │ └── script.py │ ├── designer_test.py │ └── run_test.py └── team_agent │ ├── data │ └── team_agent_test_end2end.json │ ├── evolver_test.py │ ├── inspector_functional_test.py │ ├── team_agent_functional_test.py │ └── test_utils.py ├── mock_responses ├── create_asset_repo_response.json ├── list_functions_response.json ├── list_host_machines_response.json ├── list_image_repo_tags_response.json └── login_response.json ├── test_deletion_utils.py ├── test_requests └── create_asset_request.json ├── test_utils.py └── unit ├── agent ├── agent_factory_utils_test.py ├── agent_test.py ├── evolve_param_test.py ├── model_tool_test.py ├── sql_tool_test.py ├── test_agent_evolve.py └── test_evolver_llm_utils.py ├── api_key_test.py ├── benchmark_test.py ├── corpus_test.py ├── data └── create_finetune_percentage_exception.json ├── dataset_test.py ├── designer_unit_test.py ├── finetune_test.py ├── hyperparameters_test.py ├── image_upload_test.py ├── index_model_test.py ├── llm_test.py ├── mock_responses ├── cost_estimation_response.json ├── finetune_response.json ├── finetune_status_response.json ├── finetune_status_response_2.json ├── list_models_response.json └── model_response.json ├── model_test.py ├── pipeline_test.py ├── team_agent ├── inspector_test.py └── team_agent_test.py ├── utility_test.py ├── utility_tool_decorator_test.py ├── v2 ├── test_core.py └── test_resource.py └── wallet_test.py /.env.example: -------------------------------------------------------------------------------- 1 | BACKEND_URL=https://platform-api.aixplain.com 2 | MODELS_RUN_URL=https://models.aixplain.com/api/v1/execute 3 | PIPELINE_API_KEY= 4 | MODEL_API_KEY= 5 | LOG_LEVEL=DEBUG 6 | TEAM_API_KEY= -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v5.0.0 # Use the latest version 4 | hooks: 5 | - id: trailing-whitespace 6 | - id: end-of-file-fixer 7 | - id: check-merge-conflict 8 | - id: check-added-large-files 9 | 10 | - repo: https://github.com/astral-sh/ruff-pre-commit 11 | rev: v0.12.12 12 | hooks: 13 | - id: ruff 14 | args: [--fix] 15 | - id: ruff-format 16 | 17 | - repo: local 18 | hooks: 19 | - id: pytest-check 20 | name: pytest-check 21 | entry: coverage run --source=. -m pytest tests/unit 22 | language: python 23 | pass_filenames: false 24 | types: [python] 25 | always_run: true 26 | -------------------------------------------------------------------------------- /aixplain/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | aiXplain SDK Library. 3 | --- 4 | 5 | aiXplain SDK enables python programmers to add AI functions 6 | to their software. 7 | 8 | Copyright 2022 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | 23 | import os 24 | import logging 25 | from dotenv import load_dotenv 26 | 27 | load_dotenv() 28 | 29 | from .v2.core import Aixplain # noqa 30 | 31 | LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO").upper() 32 | logging.basicConfig(level=LOG_LEVEL) 33 | 34 | 35 | aixplain_v2 = None 36 | try: 37 | aixplain_v2 = Aixplain() 38 | except Exception: 39 | pass 40 | 41 | 42 | __all__ = ["Aixplain", "aixplain_v2"] 43 | -------------------------------------------------------------------------------- /aixplain/cli_groups.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2022 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: Michael Lam 19 | Date: September 18th 2023 20 | Description: 21 | CLI Runner 22 | """ 23 | import click 24 | from aixplain.factories.cli.model_factory_cli import ( 25 | list_host_machines, 26 | list_functions, 27 | create_asset_repo, 28 | asset_repo_login, 29 | onboard_model, 30 | deploy_huggingface_model, 31 | get_huggingface_model_status, 32 | list_gpus, 33 | ) 34 | 35 | 36 | @click.group("cli") 37 | def cli(): 38 | pass 39 | 40 | 41 | @click.group("list") 42 | def list(): 43 | pass 44 | 45 | 46 | @click.group("get") 47 | def get(): 48 | pass 49 | 50 | 51 | @click.group("create") 52 | def create(): 53 | pass 54 | 55 | 56 | @click.group("onboard") 57 | def onboard(): 58 | pass 59 | 60 | 61 | cli.add_command(list) 62 | cli.add_command(get) 63 | cli.add_command(create) 64 | cli.add_command(onboard) 65 | 66 | create.add_command(create_asset_repo) 67 | list.add_command(list_host_machines) 68 | list.add_command(list_functions) 69 | list.add_command(list_gpus) 70 | get.add_command(asset_repo_login) 71 | get.add_command(get_huggingface_model_status) 72 | onboard.add_command(onboard_model) 73 | onboard.add_command(deploy_huggingface_model) 74 | 75 | 76 | def run_cli(): 77 | cli() 78 | -------------------------------------------------------------------------------- /aixplain/decorators/__init__.py: -------------------------------------------------------------------------------- 1 | from .api_key_checker import check_api_key 2 | -------------------------------------------------------------------------------- /aixplain/decorators/api_key_checker.py: -------------------------------------------------------------------------------- 1 | """API key validation decorator for aiXplain SDK.""" 2 | 3 | from aixplain.utils.config import check_api_keys_available 4 | 5 | 6 | def check_api_key(method): 7 | """Decorator to verify that an API key is set before executing the method. 8 | 9 | This decorator uses the centralized API key validation logic from config.py 10 | to ensure consistent behavior across the entire SDK. 11 | 12 | Args: 13 | method (callable): The method to be decorated. 14 | 15 | Returns: 16 | callable: The wrapped method that includes API key verification. 17 | 18 | Raises: 19 | Exception: If neither TEAM_API_KEY nor AIXPLAIN_API_KEY is set. 20 | 21 | Example: 22 | @check_api_key 23 | def my_api_method(): 24 | # Method implementation 25 | pass 26 | """ 27 | 28 | def wrapper(*args, **kwargs): 29 | # Use centralized validation - single source of truth 30 | check_api_keys_available() 31 | return method(*args, **kwargs) 32 | 33 | return wrapper 34 | -------------------------------------------------------------------------------- /aixplain/enums/__init__.py: -------------------------------------------------------------------------------- 1 | # flake8: noqa: F401 // to ignore the F401 (unused import) 2 | from .data_split import DataSplit 3 | from .data_subtype import DataSubtype 4 | from .data_type import DataType 5 | from .error_handler import ErrorHandler 6 | from .file_type import FileType 7 | from .function import Function, FunctionInputOutput 8 | from .language import Language 9 | from .license import License 10 | from .onboard_status import OnboardStatus 11 | from .ownership_type import OwnershipType 12 | from .privacy import Privacy 13 | from .storage_type import StorageType 14 | from .supplier import Supplier 15 | from .sort_by import SortBy 16 | from .sort_order import SortOrder 17 | from .response_status import ResponseStatus 18 | from .database_source import DatabaseSourceType 19 | from .embedding_model import EmbeddingModel 20 | from .asset_status import AssetStatus 21 | from .index_stores import IndexStores 22 | from .function_type import FunctionType 23 | from .evolve_type import EvolveType 24 | from .code_interpreter import CodeInterpreterModel 25 | -------------------------------------------------------------------------------- /aixplain/enums/code_interpreter.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class CodeInterpreterModel(str, Enum): 5 | """Enumeration of available Code Interpreter model identifiers. 6 | 7 | This enum defines the unique identifiers for different code interpreter models 8 | available in the system. Each value represents a specific model's ID that can 9 | be used for code interpretation tasks. 10 | 11 | Attributes: 12 | PYTHON_AZURE (str): Model ID for the Python code interpreter running on Azure. 13 | """ 14 | 15 | PYTHON_AZURE = "67476fa16eb563d00060ad62" 16 | 17 | def __str__(self) -> str: 18 | """Return the string representation of the model ID. 19 | 20 | Returns: 21 | str: The model ID value as a string. 22 | """ 23 | return self._value_ 24 | -------------------------------------------------------------------------------- /aixplain/enums/data_split.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: March 20th 2023 20 | Description: 21 | Data Split Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class DataSplit(Enum): 28 | """Enumeration of dataset split types. 29 | 30 | This enum defines the standard dataset split types used for machine learning tasks, 31 | including training, validation, and testing splits. 32 | 33 | Attributes: 34 | TRAIN (str): Training dataset split used for model training. 35 | VALIDATION (str): Validation dataset split used for model tuning. 36 | TEST (str): Test dataset split used for final model evaluation. 37 | """ 38 | TRAIN = "train" 39 | VALIDATION = "validation" 40 | TEST = "test" 41 | -------------------------------------------------------------------------------- /aixplain/enums/data_subtype.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: May 3rd 2023 20 | Description: 21 | Data Subtype Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class DataSubtype(Enum): 28 | """Enumeration of data subtypes for categorizing and organizing data. 29 | 30 | This enum defines various subtypes that can be used to further categorize 31 | data points within the system, particularly useful for demographic and 32 | content-based categorization. 33 | 34 | Attributes: 35 | AGE (str): Age category subtype. 36 | GENDER (str): Gender category subtype. 37 | INTERVAL (str): Time interval subtype. 38 | OTHER (str): Miscellaneous/other subtype. 39 | RACE (str): Race/ethnicity category subtype. 40 | SPLIT (str): Data split category subtype. 41 | TOPIC (str): Content topic subtype. 42 | """ 43 | AGE = "age" 44 | GENDER = "gender" 45 | INTERVAL = "interval" 46 | OTHER = "other" 47 | RACE = "race" 48 | SPLIT = "split" 49 | TOPIC = "topic" 50 | 51 | def __str__(self) -> str: 52 | """Return the string representation of the data subtype. 53 | 54 | Returns: 55 | str: The data subtype value as a string. 56 | """ 57 | return self._value_ 58 | -------------------------------------------------------------------------------- /aixplain/enums/data_type.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: March 20th 2023 20 | Description: 21 | Data Type Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class DataType(str, Enum): 28 | """Enumeration of supported data types in the aiXplain system. 29 | 30 | This enum defines all the data types that can be processed by the system, 31 | including various media types and basic data types. 32 | 33 | Attributes: 34 | AUDIO (str): Audio data type. 35 | FLOAT (str): Floating-point number data type. 36 | IMAGE (str): Image data type. 37 | INTEGER (str): Integer number data type. 38 | LABEL (str): Label/category data type. 39 | TENSOR (str): Tensor/multi-dimensional array data type. 40 | TEXT (str): Text data type. 41 | VIDEO (str): Video data type. 42 | EMBEDDING (str): Vector embedding data type. 43 | NUMBER (str): Generic number data type. 44 | BOOLEAN (str): Boolean data type. 45 | """ 46 | AUDIO = "audio" 47 | FLOAT = "float" 48 | IMAGE = "image" 49 | INTEGER = "integer" 50 | LABEL = "label" 51 | TENSOR = "tensor" 52 | TEXT = "text" 53 | VIDEO = "video" 54 | EMBEDDING = "embedding" 55 | NUMBER = "number" 56 | BOOLEAN = "boolean" 57 | 58 | def __str__(self) -> str: 59 | """Return the string representation of the data type. 60 | 61 | Returns: 62 | str: The data type value as a string. 63 | """ 64 | return self._value_ 65 | -------------------------------------------------------------------------------- /aixplain/enums/database_source.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2024 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: Lucas Pavanelli and Thiago Castro Ferreira and Ahmet Gunduz 19 | Date: March 7th 2025 20 | Description: 21 | Database Source Type Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class DatabaseSourceType(Enum): 28 | """Enumeration of supported database source types. 29 | 30 | This enum defines the different types of database sources that can be used 31 | for data storage and retrieval in the system. 32 | 33 | Attributes: 34 | POSTGRESQL (str): PostgreSQL database source type. 35 | SQLITE (str): SQLite database source type. 36 | CSV (str): CSV file source type. 37 | """ 38 | 39 | POSTGRESQL = "postgresql" 40 | SQLITE = "sqlite" 41 | CSV = "csv" 42 | 43 | @classmethod 44 | def from_string(cls, source_type: str) -> "DatabaseSourceType": 45 | """Convert string to DatabaseSourceType enum 46 | 47 | Args: 48 | source_type (str): Source type string 49 | 50 | Returns: 51 | DatabaseSourceType: Corresponding enum value 52 | """ 53 | try: 54 | return cls[source_type.upper()] 55 | except KeyError: 56 | raise ValueError(f"Invalid source type: {source_type}") 57 | -------------------------------------------------------------------------------- /aixplain/enums/embedding_model.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | Author: aiXplain team 15 | Date: February 17th 2025 16 | Description: 17 | Embedding Model Enum 18 | """ 19 | 20 | from enum import Enum 21 | 22 | 23 | class EmbeddingModel(str, Enum): 24 | """Enumeration of available embedding models in the aiXplain system. 25 | 26 | This enum defines the unique identifiers for different embedding models that can 27 | be used to generate vector representations of data. 28 | 29 | Attributes: 30 | OPENAI_ADA002 (str): OpenAI's Ada-002 text embedding model ID. 31 | JINA_CLIP_V2_MULTIMODAL (str): Jina CLIP v2 multimodal embedding model ID. 32 | MULTILINGUAL_E5_LARGE (str): Multilingual E5 Large text embedding model ID. 33 | BGE_M3 (str): BGE-M3 embedding model ID. 34 | """ 35 | OPENAI_ADA002 = "6734c55df127847059324d9e" 36 | JINA_CLIP_V2_MULTIMODAL = "67c5f705d8f6a65d6f74d732" 37 | MULTILINGUAL_E5_LARGE = "67efd0772a0a850afa045af3" 38 | BGE_M3 = "67efd4f92a0a850afa045af7" 39 | 40 | def __str__(self) -> str: 41 | """Return the string representation of the embedding model ID. 42 | 43 | Returns: 44 | str: The model ID value as a string. 45 | """ 46 | return self._value_ 47 | -------------------------------------------------------------------------------- /aixplain/enums/error_handler.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: May 26th 2023 20 | Description: 21 | Error Handler Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class ErrorHandler(Enum): 28 | """ 29 | Enumeration class defining different error handler strategies. 30 | 31 | Attributes: 32 | SKIP (str): skip failed rows. 33 | FAIL (str): raise an exception. 34 | """ 35 | 36 | SKIP = "skip" 37 | FAIL = "fail" 38 | -------------------------------------------------------------------------------- /aixplain/enums/evolve_type.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class EvolveType(str, Enum): 5 | """Enumeration of evolution types for team agents. 6 | 7 | This enum defines the available evolution strategies that can be applied 8 | to team agents during the evolution process. Each type represents a 9 | different approach to improving agent performance. 10 | 11 | Attributes: 12 | TEAM_TUNING (str): Evolution strategy focused on tuning team-level 13 | configurations and interactions between agents. 14 | INSTRUCTION_TUNING (str): Evolution strategy focused on refining 15 | individual agent instructions and prompts. 16 | 17 | """ 18 | TEAM_TUNING = "team_tuning" 19 | INSTRUCTION_TUNING = "instruction_tuning" 20 | -------------------------------------------------------------------------------- /aixplain/enums/file_type.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: March 20th 2023 20 | Description: 21 | File Type Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class FileType(Enum): 28 | """Enumeration of supported file types in the aiXplain system. 29 | 30 | This enum defines the file extensions for various file formats that can be 31 | processed by the system, including document, audio, image, and video formats. 32 | 33 | Attributes: 34 | CSV (str): Comma-separated values file (.csv). 35 | JSON (str): JSON document file (.json). 36 | TXT (str): Plain text file (.txt). 37 | XML (str): XML document file (.xml). 38 | FLAC (str): Free Lossless Audio Codec file (.flac). 39 | MP3 (str): MP3 audio file (.mp3). 40 | WAV (str): Waveform audio file (.wav). 41 | JPEG (str): JPEG image file (.jpeg). 42 | PNG (str): Portable Network Graphics file (.png). 43 | JPG (str): JPEG image file (.jpg). 44 | GIF (str): Graphics Interchange Format file (.gif). 45 | WEBP (str): WebP image file (.webp). 46 | AVI (str): Audio Video Interleave file (.avi). 47 | MP4 (str): MPEG-4 video file (.mp4). 48 | MOV (str): QuickTime movie file (.mov). 49 | MPEG4 (str): MPEG-4 video file (.mpeg4). 50 | """ 51 | CSV = ".csv" 52 | JSON = ".json" 53 | TXT = ".txt" 54 | XML = ".xml" 55 | FLAC = ".flac" 56 | MP3 = ".mp3" 57 | WAV = ".wav" 58 | JPEG = ".jpeg" 59 | PNG = ".png" 60 | JPG = ".jpg" 61 | GIF = ".gif" 62 | WEBP = ".webp" 63 | AVI = ".avi" 64 | MP4 = ".mp4" 65 | MOV = ".mov" 66 | MPEG4 = ".mpeg4" 67 | -------------------------------------------------------------------------------- /aixplain/enums/function_type.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: May 22th 2025 20 | Description: 21 | Function Type Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class FunctionType(Enum): 28 | """Enumeration of function types in the aiXplain system. 29 | 30 | This enum defines the different types of functions and services available 31 | in the system, including AI models, data processing utilities, and 32 | integration components. 33 | 34 | Attributes: 35 | AI (str): Artificial Intelligence function type. 36 | SEGMENTOR (str): Data segmentation function type. 37 | RECONSTRUCTOR (str): Data reconstruction function type. 38 | UTILITY (str): Utility function type. 39 | METRIC (str): Metric/evaluation function type. 40 | SEARCH (str): Search function type. 41 | INTEGRATION (str): Integration connector function type. # i.e. slack 42 | CONNECTION (str): Connection function type. # slack - action 43 | MCP_CONNECTION (str): MCP connection function type. 44 | MCPSERVER (str): MCP server is for on-prem solution. It should be treated like a model. # ONPREM_MCP_MODEL 45 | """ 46 | AI = "ai" 47 | SEGMENTOR = "segmentor" 48 | RECONSTRUCTOR = "reconstructor" 49 | UTILITY = "utility" 50 | METRIC = "metric" 51 | SEARCH = "search" 52 | INTEGRATION = "connector" 53 | CONNECTION = "connection" 54 | MCP_CONNECTION = "mcpconnection" 55 | MCPSERVER = "mcpserver" 56 | -------------------------------------------------------------------------------- /aixplain/enums/index_stores.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class IndexStores(Enum): 5 | """Enumeration of available index store providers in the aiXplain system. 6 | 7 | This enum defines the different index store providers that can be used for 8 | storing and retrieving indexed data, along with their identifiers. 9 | 10 | Attributes: 11 | AIR (dict): AIR index store configuration with name and ID. 12 | VECTARA (dict): Vectara index store configuration with name and ID. 13 | GRAPHRAG (dict): GraphRAG index store configuration with name and ID. 14 | ZERO_ENTROPY (dict): Zero Entropy index store configuration with name and ID. 15 | """ 16 | AIR = {"name": "air", "id": "66eae6656eb56311f2595011"} 17 | VECTARA = {"name": "vectara", "id": "655e20f46eb563062a1aa301"} 18 | GRAPHRAG = {"name": "graphrag", "id": "67dd6d487cbf0a57cf4b72f3"} 19 | ZERO_ENTROPY = {"name": "zeroentropy", "id": "6807949168e47e7844c1f0c5"} 20 | 21 | def __str__(self) -> str: 22 | """Return the name of the index store. 23 | 24 | Returns: 25 | str: The name value from the index store configuration. 26 | """ 27 | return self.value["name"] 28 | 29 | def get_model_id(self) -> str: 30 | """Return the model ID of the index store. 31 | 32 | Returns: 33 | str: The ID value from the index store configuration. 34 | """ 35 | return self.value["id"] 36 | -------------------------------------------------------------------------------- /aixplain/enums/onboard_status.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: March 22th 2023 20 | Description: 21 | Onboard Status Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class OnboardStatus(Enum): 28 | """Enumeration of possible onboarding status values. 29 | 30 | This enum defines all possible states that an onboarding process can be in, 31 | from initial onboarding to completed or failed states. 32 | 33 | Attributes: 34 | ONBOARDING (str): Initial onboarding state. 35 | ONBOARDED (str): Successful onboarding state. 36 | FAILED (str): Failed onboarding state. 37 | DELETED (str): Deleted onboarding state. 38 | """ 39 | ONBOARDING = "onboarding" 40 | ONBOARDED = "onboarded" 41 | FAILED = "failed" 42 | DELETED = "deleted" 43 | -------------------------------------------------------------------------------- /aixplain/enums/ownership_type.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: November 22nd 2023 20 | Description: 21 | Asset Ownership Type 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class OwnershipType(Enum): 28 | """Enumeration of possible ownership types. 29 | 30 | This enum defines the different types of ownership that can be associated with 31 | an asset or resource, including subscribed and owned ownership. 32 | 33 | Attributes: 34 | SUBSCRIBED (str): Subscribed ownership type. 35 | OWNED (str): Owned ownership type. 36 | """ 37 | SUBSCRIBED = "SUBSCRIBED" 38 | OWNED = "OWNED" 39 | 40 | def __str__(self): 41 | """Return the string representation of the ownership type. 42 | 43 | Returns: 44 | str: The ownership type value as a string. 45 | """ 46 | return self._value_ 47 | -------------------------------------------------------------------------------- /aixplain/enums/privacy.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: March 20th 2023 20 | Description: 21 | Privacy Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class Privacy(Enum): 28 | """Enumeration of possible privacy levels. 29 | 30 | This enum defines the different levels of privacy that can be associated with 31 | an asset or resource, including public, private, and restricted privacy levels. 32 | 33 | Attributes: 34 | PUBLIC (str): Public privacy level. 35 | PRIVATE (str): Private privacy level. 36 | RESTRICTED (str): Restricted privacy level. 37 | """ 38 | PUBLIC = "Public" 39 | PRIVATE = "Private" 40 | RESTRICTED = "Restricted" 41 | -------------------------------------------------------------------------------- /aixplain/enums/response_status.py: -------------------------------------------------------------------------------- 1 | __author__ = "thiagocastroferreira" 2 | 3 | """ 4 | Copyright 2024 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 19 | Date: February 21st 2024 20 | Description: 21 | Asset Enum 22 | """ 23 | 24 | from enum import Enum 25 | from typing import Text 26 | 27 | 28 | class ResponseStatus(Text, Enum): 29 | """Enumeration of possible response status values. 30 | 31 | This enum defines the different statuses that a response can be in, including 32 | in progress, success, and failure. 33 | 34 | Attributes: 35 | IN_PROGRESS (str): Response is in progress. 36 | SUCCESS (str): Response was successful. 37 | FAILED (str): Response failed. 38 | """ 39 | IN_PROGRESS = "IN_PROGRESS" 40 | SUCCESS = "SUCCESS" 41 | FAILED = "FAILED" 42 | 43 | def __str__(self): 44 | """Return the string representation of the response status. 45 | 46 | Returns: 47 | str: The response status value as a string. 48 | """ 49 | return self.value 50 | -------------------------------------------------------------------------------- /aixplain/enums/sort_by.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: March 20th 2023 20 | Description: 21 | Sort By Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class SortBy(Enum): 28 | """Enumeration of possible sorting criteria. 29 | 30 | This enum defines the different criteria that can be used to sort assets, 31 | including creation date, price, and popularity. 32 | 33 | Attributes: 34 | CREATION_DATE (str): Sort by creation date. 35 | PRICE (str): Sort by normalized price. 36 | POPULARITY (str): Sort by total number of subscriptions. 37 | """ 38 | CREATION_DATE = "createdAt" 39 | PRICE = "normalizedPrice" 40 | POPULARITY = "totalSubscribed" 41 | -------------------------------------------------------------------------------- /aixplain/enums/sort_order.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: March 20th 2023 20 | Description: 21 | Sort By Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class SortOrder(Enum): 28 | """Enumeration of possible sorting orders. 29 | 30 | This enum defines the different directions that can be used to sort assets, 31 | including ascending and descending order. 32 | 33 | Attributes: 34 | ASCENDING (int): Sort in ascending order. 35 | DESCENDING (int): Sort in descending order. 36 | """ 37 | ASCENDING = 1 38 | DESCENDING = -1 39 | -------------------------------------------------------------------------------- /aixplain/enums/splitting_options.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: May 30th 2025 20 | Description: 21 | Splitting Options Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class SplittingOptions(str, Enum): 28 | """Enumeration of possible splitting options. 29 | 30 | This enum defines the different ways that text can be split into chunks, 31 | including by word, sentence, passage, page, and line. 32 | 33 | Attributes: 34 | WORD (str): Split by word. 35 | SENTENCE (str): Split by sentence. 36 | PASSAGE (str): Split by passage. 37 | PAGE (str): Split by page. 38 | LINE (str): Split by line. 39 | """ 40 | WORD = "word" 41 | SENTENCE = "sentence" 42 | PASSAGE = "passage" 43 | PAGE = "page" 44 | LINE = "line" 45 | 46 | def __str__(self): 47 | """Return the string representation of the splitting option. 48 | 49 | Returns: 50 | str: The splitting option value as a string. 51 | """ 52 | return self._value_ 53 | -------------------------------------------------------------------------------- /aixplain/enums/status.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | from typing import Text 3 | 4 | 5 | class Status(Text, Enum): 6 | """Enumeration of possible status values. 7 | 8 | This enum defines the different statuses that a task or operation can be in, 9 | including failed, in progress, and success. 10 | 11 | Attributes: 12 | FAILED (str): Task failed. 13 | IN_PROGRESS (str): Task is in progress. 14 | SUCCESS (str): Task was successful. 15 | """ 16 | FAILED = "failed" 17 | IN_PROGRESS = "in_progress" 18 | SUCCESS = "success" 19 | -------------------------------------------------------------------------------- /aixplain/enums/storage_type.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2023 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain team 19 | Date: March 20th 2023 20 | Description: 21 | Storage Type Enum 22 | """ 23 | 24 | from enum import Enum 25 | 26 | 27 | class StorageType(Enum): 28 | """Enumeration of possible storage types. 29 | 30 | This enum defines the different types of storage that can be used to store 31 | assets, including text, URL, and file. 32 | 33 | Attributes: 34 | TEXT (str): Text storage type. 35 | URL (str): URL storage type. 36 | FILE (str): File storage type. 37 | """ 38 | TEXT = "text" 39 | URL = "url" 40 | FILE = "file" 41 | 42 | def __str__(self): 43 | """Return the string representation of the storage type. 44 | 45 | Returns: 46 | str: The storage type value as a string. 47 | """ 48 | return self._value_ 49 | -------------------------------------------------------------------------------- /aixplain/factories/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | aiXplain SDK Library. 3 | --- 4 | 5 | aiXplain SDK enables python programmers to add AI functions 6 | to their software. 7 | 8 | Copyright 2022 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | from .asset_factory import AssetFactory 23 | from .agent_factory import AgentFactory 24 | from .team_agent_factory import TeamAgentFactory 25 | from .benchmark_factory import BenchmarkFactory 26 | from .corpus_factory import CorpusFactory 27 | from .data_factory import DataFactory 28 | from .dataset_factory import DatasetFactory 29 | from .file_factory import FileFactory 30 | from .metric_factory import MetricFactory 31 | from .model_factory import ModelFactory 32 | from .pipeline_factory import PipelineFactory 33 | from .finetune_factory import FinetuneFactory 34 | from .wallet_factory import WalletFactory 35 | from .api_key_factory import APIKeyFactory 36 | from .index_factory import IndexFactory 37 | from .tool_factory import ToolFactory 38 | from .integration_factory import IntegrationFactory 39 | -------------------------------------------------------------------------------- /aixplain/factories/asset_factory.py: -------------------------------------------------------------------------------- 1 | __author__ = "aiXplain" 2 | 3 | """ 4 | Copyright 2022 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 19 | Date: December 27th 2022 20 | Description: 21 | Asset Factory Class 22 | """ 23 | 24 | from abc import abstractmethod 25 | from typing import Text 26 | from aixplain.modules.asset import Asset 27 | from aixplain.utils import config 28 | 29 | 30 | class AssetFactory: 31 | """Base class for asset factories. 32 | 33 | This class provides a common interface for creating and retrieving assets 34 | from the aiXplain platform. Subclasses should implement the abstract methods 35 | to define specific asset types. 36 | 37 | Attributes: 38 | backend_url (str): Base URL for the aiXplain backend API. 39 | """ 40 | 41 | backend_url = config.BACKEND_URL 42 | @abstractmethod 43 | def get(self, asset_id: Text) -> Asset: 44 | """Create a 'Asset' object from id 45 | 46 | Args: 47 | asset_id (str): ID of required asset. 48 | 49 | Returns: 50 | Asset: Created 'Asset' object 51 | """ 52 | pass 53 | -------------------------------------------------------------------------------- /aixplain/factories/model_factory/mixins/__init__.py: -------------------------------------------------------------------------------- 1 | from aixplain.factories.model_factory.mixins.model_getter import ModelGetterMixin 2 | from aixplain.factories.model_factory.mixins.model_list import ModelListMixin 3 | 4 | __all__ = ["ModelGetterMixin", "ModelListMixin"] 5 | -------------------------------------------------------------------------------- /aixplain/factories/script_factory.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | from typing import Tuple 4 | 5 | import requests 6 | 7 | from aixplain.utils import config 8 | 9 | 10 | class ScriptFactory: 11 | """A factory class for handling script file operations. 12 | 13 | This class provides functionality for uploading script files to the backend 14 | and managing their metadata. 15 | """ 16 | @classmethod 17 | def upload_script(cls, script_path: str) -> Tuple[str, str]: 18 | """Uploads a script file to the backend and returns its ID and metadata. 19 | 20 | Args: 21 | script_path (str): The file system path to the script file to be uploaded. 22 | 23 | Returns: 24 | Tuple[str, str]: A tuple containing: 25 | - file_id (str): The unique identifier assigned to the uploaded file. 26 | - metadata (str): JSON string containing file metadata (name and size). 27 | 28 | Raises: 29 | Exception: If the upload fails or the file cannot be accessed. 30 | """ 31 | try: 32 | url = f"{config.BACKEND_URL}/sdk/pipelines/script" 33 | headers = {"Authorization": f"Token {config.TEAM_API_KEY}"} 34 | r = requests.post(url, headers=headers, files={"file": open(script_path, "rb")}) 35 | if 200 <= r.status_code < 300: 36 | response = r.json() 37 | else: 38 | raise Exception() 39 | except Exception: 40 | response = {"fileId": ""} 41 | 42 | # get metadata info 43 | fname = os.path.splitext(os.path.basename(script_path))[0] 44 | file_size = int(os.path.getsize(script_path)) 45 | metadata = json.dumps({"name": fname, "size": file_size}) 46 | return response["fileId"], metadata 47 | -------------------------------------------------------------------------------- /aixplain/factories/wallet_factory.py: -------------------------------------------------------------------------------- 1 | import aixplain.utils.config as config 2 | from aixplain.modules.wallet import Wallet 3 | from aixplain.utils.request_utils import _request_with_retry 4 | import logging 5 | from typing import Text 6 | 7 | 8 | class WalletFactory: 9 | """A factory class for retrieving wallet information. 10 | 11 | This class provides functionality to fetch wallet details including total 12 | and reserved balance information from the backend API. 13 | 14 | Attributes: 15 | backend_url: The URL endpoint for the backend API. 16 | """ 17 | backend_url = config.BACKEND_URL 18 | 19 | @classmethod 20 | def get(cls, api_key: Text = config.TEAM_API_KEY) -> Wallet: 21 | """Retrieves the current wallet information from the backend. 22 | 23 | This method fetches the wallet details including total balance and reserved balance 24 | using the provided API key. 25 | 26 | Args: 27 | api_key (Text, optional): The API key for authentication. Defaults to config.TEAM_API_KEY. 28 | 29 | Returns: 30 | Wallet: A Wallet object containing the total and reserved balance information. 31 | 32 | Raises: 33 | Exception: If the wallet information cannot be retrieved from the backend. 34 | """ 35 | try: 36 | resp = None 37 | url = f"{cls.backend_url}/sdk/billing/wallet" 38 | headers = {"Authorization": f"Token {api_key}", "Content-Type": "application/json"} 39 | logging.info(f"Start fetching billing information from - {url} - {headers}") 40 | headers = {"Content-Type": "application/json", "x-api-key": api_key} 41 | r = _request_with_retry("get", url, headers=headers) 42 | resp = r.json() 43 | total_balance = float(resp.get("totalBalance", 0.0)) 44 | reserved_balance = float(resp.get("reservedBalance", 0.0)) 45 | 46 | return Wallet(total_balance=total_balance, reserved_balance=reserved_balance) 47 | except Exception as e: 48 | raise Exception(f"Failed to get the wallet credit information. Error: {str(e)}") 49 | -------------------------------------------------------------------------------- /aixplain/modules/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | aiXplain SDK Library. 3 | --- 4 | 5 | aiXplain SDK enables python programmers to add AI functions 6 | to their software. 7 | 8 | Copyright 2022 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | from .asset import Asset 23 | from .corpus import Corpus 24 | from .data import Data 25 | from .dataset import Dataset 26 | from .file import File 27 | from .metadata import MetaData 28 | from .metric import Metric 29 | from .model import Model 30 | from .model.llm_model import LLM 31 | from .pipeline import Pipeline 32 | from .finetune import Finetune, FinetuneCost 33 | from .finetune.status import FinetuneStatus 34 | from .benchmark import Benchmark 35 | from .benchmark_job import BenchmarkJob 36 | from .agent import Agent 37 | from .agent.tool import Tool 38 | from .team_agent import TeamAgent 39 | from .api_key import APIKey, APIKeyLimits, APIKeyUsageLimit 40 | from .model.index_model import IndexModel 41 | -------------------------------------------------------------------------------- /aixplain/modules/agent/output_format.py: -------------------------------------------------------------------------------- 1 | __author__ = "thiagocastroferreira" 2 | 3 | """ 4 | Copyright 2024 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 19 | Date: February 21st 2024 20 | Description: 21 | Asset Enum 22 | """ 23 | 24 | from enum import Enum 25 | from typing import Text 26 | 27 | 28 | class OutputFormat(Text, Enum): 29 | """Enum representing different output formats for AI agent responses. 30 | 31 | This enum defines the possible output formats that can be used by AI agents. 32 | Each format is represented by a string constant. 33 | 34 | Attributes: 35 | MARKDOWN (Text): Markdown format for formatted text output. 36 | TEXT (Text): Plain text output. 37 | JSON (Text): JSON format for structured data output. 38 | """ 39 | MARKDOWN = "markdown" 40 | TEXT = "text" 41 | JSON = "json" 42 | -------------------------------------------------------------------------------- /aixplain/modules/finetune/cost.py: -------------------------------------------------------------------------------- 1 | __author__ = "lucaspavanelli" 2 | 3 | """ 4 | Copyright 2022 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 19 | Date: June 14th 2023 20 | Description: 21 | FinetuneCost Class 22 | """ 23 | 24 | from typing import Dict 25 | 26 | 27 | class FinetuneCost: 28 | """A class representing the cost structure for a fine-tuning job. 29 | 30 | This class encapsulates the cost information for training, inference, and hosting 31 | components of a fine-tuning job. It provides methods to convert the cost data 32 | into a dictionary format for serialization. 33 | 34 | Attributes: 35 | training (Dict): Dictionary containing training cost information. 36 | inference (Dict): Dictionary containing inference cost information. 37 | hosting (Dict): Dictionary containing hosting cost information. 38 | """ 39 | 40 | def __init__( 41 | self, 42 | training: Dict, 43 | inference: Dict, 44 | hosting: Dict, 45 | ) -> None: 46 | """Create a FinetuneCost object with training, inference, and hosting cost information. 47 | 48 | Args: 49 | training (Dict): Dictionary containing training cost information. 50 | inference (Dict): Dictionary containing inference cost information. 51 | hosting (Dict): Dictionary containing hosting cost information. 52 | """ 53 | self.training = training 54 | self.inference = inference 55 | self.hosting = hosting 56 | 57 | def to_dict(self) -> Dict: 58 | """Convert the FinetuneCost object to a dictionary. 59 | 60 | Returns: 61 | Dict: A dictionary representation of the FinetuneCost object. 62 | """ 63 | return {"trainingCost": self.training, "inferenceCost": self.inference, "hostingCost": self.hosting} 64 | -------------------------------------------------------------------------------- /aixplain/modules/finetune/status.py: -------------------------------------------------------------------------------- 1 | __author__ = "thiagocastroferreira" 2 | 3 | """ 4 | Copyright 2024 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 19 | Date: February 21st 2024 20 | Description: 21 | FinetuneCost Class 22 | """ 23 | 24 | from aixplain.enums.asset_status import AssetStatus 25 | from dataclasses import dataclass 26 | from dataclasses_json import dataclass_json 27 | from typing import Optional, Text 28 | 29 | 30 | @dataclass_json 31 | @dataclass 32 | class FinetuneStatus(object): 33 | """Status information for a fine-tuning job. 34 | 35 | This class encapsulates the status of a fine-tuning job, including the overall 36 | status of the job, the status of the model, and various training metrics. 37 | 38 | Attributes: 39 | status (AssetStatus): Overall status of the fine-tuning job. 40 | model_status (AssetStatus): Status of the fine-tuned model. 41 | epoch (Optional[float]): Current training epoch. 42 | training_loss (Optional[float]): Training loss at the current epoch. 43 | validation_loss (Optional[float]): Validation loss at the current epoch. 44 | """ 45 | status: "AssetStatus" 46 | model_status: "AssetStatus" 47 | epoch: Optional[float] = None 48 | training_loss: Optional[float] = None 49 | validation_loss: Optional[float] = None 50 | -------------------------------------------------------------------------------- /aixplain/modules/model/model_parameters.py: -------------------------------------------------------------------------------- 1 | from typing import Dict, Any 2 | from aixplain.base.parameters import BaseParameters, Parameter 3 | 4 | 5 | class ModelParameters(BaseParameters): 6 | def __init__(self, input_params: Dict[str, Dict[str, Any]]) -> None: 7 | """Initialize ModelParameters with input parameters dictionary. 8 | 9 | Args: 10 | input_params (Dict[str, Dict[str, Any]]): Dictionary containing parameter configurations 11 | """ 12 | super().__init__() 13 | for param_name, param_config in input_params.items(): 14 | self.parameters[param_name] = Parameter(name=param_name, required=param_config["required"]) 15 | -------------------------------------------------------------------------------- /aixplain/modules/model/model_response_streamer.py: -------------------------------------------------------------------------------- 1 | import json 2 | from typing import Iterator 3 | 4 | from aixplain.modules.model.response import ModelResponse, ResponseStatus 5 | 6 | 7 | class ModelResponseStreamer: 8 | """A class representing a streamer for model responses. 9 | 10 | This class provides an iterator interface for streaming model responses. 11 | It handles the conversion of JSON-like strings into ModelResponse objects 12 | and manages the response status. 13 | """ 14 | 15 | def __init__(self, iterator: Iterator): 16 | """Initialize a new ModelResponseStreamer instance. 17 | 18 | Args: 19 | iterator (Iterator): An iterator that yields JSON-like strings. 20 | """ 21 | self.iterator = iterator 22 | self.status = ResponseStatus.IN_PROGRESS 23 | 24 | def __next__(self): 25 | """Return the next chunk of the response. 26 | 27 | Returns: 28 | ModelResponse: A ModelResponse object containing the next chunk of the response. 29 | """ 30 | line = next(self.iterator).replace("data: ", "") 31 | try: 32 | data = json.loads(line) 33 | except json.JSONDecodeError: 34 | data = {"data": line} 35 | content = data.get("data", "") 36 | if content == "[DONE]": 37 | self.status = ResponseStatus.SUCCESS 38 | content = "" 39 | return ModelResponse(status=self.status, data=content) 40 | 41 | def __iter__(self): 42 | """Return the iterator for the ModelResponseStreamer. 43 | 44 | Returns: 45 | Iterator: The iterator for the ModelResponseStreamer. 46 | """ 47 | return self 48 | -------------------------------------------------------------------------------- /aixplain/modules/pipeline/__init__.py: -------------------------------------------------------------------------------- 1 | from .pipeline import Pipeline 2 | 3 | __all__ = ["Pipeline"] 4 | -------------------------------------------------------------------------------- /aixplain/modules/pipeline/default.py: -------------------------------------------------------------------------------- 1 | from .asset import Pipeline as PipelineAsset 2 | from .designer import DesignerPipeline 3 | from enum import Enum 4 | 5 | 6 | class DefaultPipeline(PipelineAsset, DesignerPipeline): 7 | """ 8 | DefaultPipeline is a subclass of PipelineAsset and DesignerPipeline. 9 | """ 10 | def __init__(self, *args, **kwargs): 11 | """ 12 | Initialize the DefaultPipeline. 13 | """ 14 | PipelineAsset.__init__(self, *args, **kwargs) 15 | DesignerPipeline.__init__(self) 16 | 17 | def save(self, *args, **kwargs): 18 | """ 19 | Save the DefaultPipeline. 20 | """ 21 | self.auto_infer() 22 | self.validate() 23 | super().save(*args, **kwargs) 24 | 25 | def to_dict(self) -> dict: 26 | """ 27 | Convert the DefaultPipeline to a dictionary. 28 | """ 29 | return self.serialize() 30 | -------------------------------------------------------------------------------- /aixplain/modules/pipeline/designer/__init__.py: -------------------------------------------------------------------------------- 1 | from .nodes import ( 2 | AssetNode, 3 | Decision, 4 | Script, 5 | Input, 6 | Output, 7 | Route, 8 | Router, 9 | BaseReconstructor, 10 | BaseSegmentor, 11 | BaseMetric, 12 | BareAsset, 13 | BareMetric, 14 | BareSegmentor, 15 | BareReconstructor, 16 | ) 17 | from .pipeline import DesignerPipeline 18 | from .base import ( 19 | Node, 20 | Link, 21 | Param, 22 | ParamProxy, 23 | InputParam, 24 | OutputParam, 25 | Inputs, 26 | Outputs, 27 | TI, 28 | TO, 29 | ) 30 | from .enums import ( 31 | ParamType, 32 | RouteType, 33 | Operation, 34 | NodeType, 35 | AssetType, 36 | FunctionType, 37 | ) 38 | from .mixins import LinkableMixin, OutputableMixin, RoutableMixin 39 | 40 | 41 | __all__ = [ 42 | "DesignerPipeline", 43 | "AssetNode", 44 | "BareAsset", 45 | "Decision", 46 | "Script", 47 | "Input", 48 | "Output", 49 | "Route", 50 | "Router", 51 | "BaseReconstructor", 52 | "BaseSegmentor", 53 | "Node", 54 | "Link", 55 | "Param", 56 | "ParamType", 57 | "InputParam", 58 | "OutputParam", 59 | "RouteType", 60 | "Operation", 61 | "NodeType", 62 | "AssetType", 63 | "FunctionType", 64 | "LinkableMixin", 65 | "OutputableMixin", 66 | "RoutableMixin", 67 | "Inputs", 68 | "Outputs", 69 | "ParamProxy", 70 | "TI", 71 | "TO", 72 | "BaseMetric", 73 | "BareMetric", 74 | ] 75 | -------------------------------------------------------------------------------- /aixplain/modules/pipeline/designer/enums.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | from aixplain.enums import FunctionType # noqa: F401 3 | 4 | 5 | class RouteType(str, Enum): 6 | CHECK_TYPE = "checkType" 7 | CHECK_VALUE = "checkValue" 8 | 9 | 10 | class Operation(str, Enum): 11 | GREATER_THAN = "greaterThan" 12 | GREATER_THAN_OR_EQUAL = "greaterThanOrEqual" 13 | LESS_THAN = "lessThan" 14 | LESS_THAN_OR_EQUAL = "lessThanOrEqual" 15 | EQUAL = "equal" 16 | DIFFERENT = "different" 17 | CONTAIN = "contain" 18 | NOT_CONTAIN = "notContain" 19 | 20 | 21 | class NodeType(str, Enum): 22 | ASSET = "ASSET" 23 | INPUT = "INPUT" 24 | OUTPUT = "OUTPUT" 25 | SCRIPT = "SCRIPT" 26 | ROUTER = "ROUTER" 27 | DECISION = "DECISION" 28 | 29 | 30 | class AssetType(str, Enum): 31 | MODEL = "MODEL" 32 | 33 | 34 | class ParamType: 35 | INPUT = "INPUT" 36 | OUTPUT = "OUTPUT" 37 | -------------------------------------------------------------------------------- /aixplain/modules/pipeline/designer/utils.py: -------------------------------------------------------------------------------- 1 | import re 2 | from typing import List 3 | 4 | 5 | def find_prompt_params(prompt: str) -> List[str]: 6 | """ 7 | This method will find the prompt parameters in the prompt string. 8 | 9 | :param prompt: the prompt string 10 | :return: list of prompt parameters 11 | """ 12 | param_regex = re.compile(r"\{\{([^\}]+)\}\}") 13 | return param_regex.findall(prompt) 14 | -------------------------------------------------------------------------------- /aixplain/modules/wallet.py: -------------------------------------------------------------------------------- 1 | __author__ = "aixplain" 2 | 3 | """ 4 | Copyright 2024 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | 18 | Author: aiXplain Team 19 | Date: August 20th 2024 20 | Description: 21 | Wallet Class 22 | """ 23 | 24 | 25 | class Wallet: 26 | """A class representing a wallet for managing credit balances. 27 | 28 | This class provides functionality for managing credit balances in a wallet, 29 | including total, reserved, and available balances. It is used to track and 30 | manage credit resources in the aiXplain platform. 31 | 32 | Attributes: 33 | total_balance (float): Total credit balance in the wallet. 34 | reserved_balance (float): Reserved credit balance in the wallet. 35 | available_balance (float): Available balance (total - reserved). 36 | """ 37 | def __init__(self, total_balance: float, reserved_balance: float): 38 | """Initialize a new Wallet instance. 39 | 40 | Args: 41 | total_balance (float): Total credit balance in the wallet. 42 | reserved_balance (float): Reserved credit balance in the wallet. 43 | """ 44 | self.total_balance = total_balance 45 | self.reserved_balance = reserved_balance 46 | self.available_balance = total_balance - reserved_balance 47 | -------------------------------------------------------------------------------- /aixplain/processes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/edaac86e2c1cf9c823aaf53e08448162f92a4e3a/aixplain/processes/__init__.py -------------------------------------------------------------------------------- /aixplain/processes/data_onboarding/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/edaac86e2c1cf9c823aaf53e08448162f92a4e3a/aixplain/processes/data_onboarding/__init__.py -------------------------------------------------------------------------------- /aixplain/utils/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | aiXplain SDK Library. 3 | --- 4 | 5 | aiXplain SDK enables python programmers to add AI functions 6 | to their software. 7 | 8 | Copyright 2022 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | -------------------------------------------------------------------------------- /aixplain/utils/convert_datatype_utils.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2022 The aiXplain SDK authors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | """ 16 | 17 | from typing import Union, Dict, List 18 | from aixplain.modules.metadata import MetaData 19 | import json 20 | from pydantic import BaseModel 21 | 22 | def dict_to_metadata(metadatas: List[Union[Dict, MetaData]]) -> None: 23 | 24 | """Convert all the Dicts to MetaData 25 | 26 | Args: 27 | metadatas (List[Union[Dict, MetaData]], optional): metadata of metadata information of the dataset. 28 | 29 | Returns: 30 | None 31 | 32 | Raises: 33 | TypeError: If one or more elements in the metadata_schema are not well-structured 34 | 35 | """ 36 | try: 37 | for i in range(len(metadatas)): 38 | if isinstance(metadatas[i], dict): 39 | metadatas[i] = MetaData(**metadatas[i]) 40 | except TypeError: 41 | raise TypeError(f"Data Asset Onboarding Error: One or more elements in the metadata_schema are not well-structured") 42 | 43 | 44 | 45 | def normalize_expected_output(obj): 46 | if isinstance(obj, type) and issubclass(obj, BaseModel): 47 | return obj.model_json_schema() if hasattr(obj, "model_json_schema") else obj.schema() 48 | 49 | if isinstance(obj, BaseModel): 50 | return json.loads(obj.model_dump_json()) if hasattr(obj, "model_dump_json") else json.loads(obj.json()) 51 | 52 | if isinstance(obj, (dict, str)) or obj is None: 53 | return obj 54 | 55 | return json.loads(json.dumps(obj)) -------------------------------------------------------------------------------- /aixplain/utils/evolve_utils.py: -------------------------------------------------------------------------------- 1 | from typing import Union, Dict, Any, Optional, Text 2 | from aixplain.modules.model.llm_model import LLM 3 | 4 | 5 | def create_llm_dict(llm: Optional[Union[Text, LLM]]) -> Optional[Dict[str, Any]]: 6 | """Create a dictionary representation of an LLM for evolution parameters. 7 | 8 | Args: 9 | llm: Either an LLM ID string or an LLM object instance. 10 | 11 | Returns: 12 | Dictionary with LLM information if llm is provided, None otherwise. 13 | """ 14 | if llm is None: 15 | return None 16 | 17 | if isinstance(llm, LLM): 18 | return { 19 | "id": llm.id, 20 | "name": llm.name, 21 | "description": llm.description, 22 | "supplier": llm.supplier, 23 | "version": llm.version, 24 | "function": llm.function, 25 | "parameters": (llm.get_parameters().to_list() if llm.get_parameters() else None), 26 | "temperature": getattr(llm, "temperature", None), 27 | } 28 | else: 29 | return {"id": llm} 30 | -------------------------------------------------------------------------------- /aixplain/utils/llm_utils.py: -------------------------------------------------------------------------------- 1 | from typing import Optional, Text 2 | from aixplain.factories.model_factory import ModelFactory 3 | from aixplain.modules.model.llm_model import LLM 4 | 5 | 6 | def get_llm_instance( 7 | llm_id: Text, 8 | api_key: Optional[Text] = None, 9 | use_cache: bool = True, 10 | ) -> LLM: 11 | """Get an LLM instance with specific configuration. 12 | 13 | Args: 14 | llm_id (Text): ID of the LLM model to use. 15 | api_key (Optional[Text], optional): API key to use. Defaults to None. 16 | use_cache (bool, optional): Whether to use caching for model retrieval. Defaults to True. 17 | 18 | Returns: 19 | LLM: Configured LLM instance. 20 | 21 | Raises: 22 | Exception: If the LLM model with the given ID is not found. 23 | """ 24 | try: 25 | llm = ModelFactory.get(llm_id, api_key=api_key, use_cache=use_cache) 26 | return llm 27 | except Exception: 28 | raise Exception(f"Large Language Model with ID '{llm_id}' not found.") 29 | -------------------------------------------------------------------------------- /aixplain/utils/request_utils.py: -------------------------------------------------------------------------------- 1 | from requests.adapters import HTTPAdapter, Retry 2 | import requests 3 | from typing import Text 4 | 5 | 6 | def _request_with_retry(method: Text, url: Text, **params) -> requests.Response: 7 | """Wrapper around requests with Session to retry in case it fails 8 | 9 | Args: 10 | method (Text): HTTP method, such as 'GET' or 'HEAD'. 11 | url (Text): The URL of the resource to fetch. 12 | **params: Params to pass to request function. 13 | 14 | Returns: 15 | requests.Response: Response object of the request. 16 | """ 17 | session = requests.Session() 18 | retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504]) 19 | session.mount("https://", HTTPAdapter(max_retries=retries)) 20 | response = session.request(method=method.upper(), url=url, **params) 21 | return response 22 | -------------------------------------------------------------------------------- /aixplain/v2/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/edaac86e2c1cf9c823aaf53e08448162f92a4e3a/aixplain/v2/__init__.py -------------------------------------------------------------------------------- /aixplain/v2/api_key.py: -------------------------------------------------------------------------------- 1 | from .resource import ( 2 | BaseResource, 3 | BareListParams, 4 | BareGetParams, 5 | GetResourceMixin, 6 | ListResourceMixin, 7 | CreateResourceMixin, 8 | BaseCreateParams, 9 | Page, 10 | ) 11 | from datetime import datetime 12 | from typing_extensions import Unpack, NotRequired, TYPE_CHECKING 13 | from typing import Dict, List, Optional, Text, Union 14 | 15 | if TYPE_CHECKING: 16 | from aixplain.modules import APIKeyLimits, APIKeyUsageLimit 17 | 18 | 19 | class APIKeyCreateParams(BaseCreateParams): 20 | name: Text 21 | budget: int 22 | global_limits: Union[Dict, "APIKeyLimits"] 23 | asset_limits: List[Union[Dict, "APIKeyLimits"]] 24 | expires_at: datetime 25 | 26 | 27 | class APIKeyGetParams(BareGetParams): 28 | api_key: NotRequired[str] 29 | 30 | 31 | class APIKey( 32 | BaseResource, 33 | GetResourceMixin[APIKeyGetParams, "APIKey"], 34 | ListResourceMixin[BareListParams, "APIKey"], 35 | CreateResourceMixin[APIKeyCreateParams, "APIKey"], 36 | ): 37 | @classmethod 38 | def get(cls, **kwargs: Unpack[APIKeyGetParams]) -> "APIKey": 39 | from aixplain.factories import APIKeyFactory 40 | import aixplain.utils.config as config 41 | 42 | api_key = kwargs.get("api_key", config.TEAM_API_KEY) 43 | return APIKeyFactory.get(api_key=api_key) 44 | 45 | @classmethod 46 | def list(cls, **kwargs: Unpack[BareListParams]) -> Page["APIKey"]: 47 | from aixplain.factories import APIKeyFactory 48 | 49 | return APIKeyFactory.list(**kwargs) 50 | 51 | @classmethod 52 | def create(cls, *args, **kwargs: Unpack[APIKeyCreateParams]) -> "APIKey": 53 | from aixplain.factories import APIKeyFactory 54 | 55 | return APIKeyFactory.create(*args, **kwargs) 56 | 57 | @classmethod 58 | def update(cls, api_key: "APIKey") -> "APIKey": 59 | from aixplain.factories import APIKeyFactory 60 | 61 | return APIKeyFactory.update(api_key) 62 | 63 | @classmethod 64 | def get_usage_limits(cls, api_key: Text = None, asset_id: Optional[Text] = None) -> List["APIKeyUsageLimit"]: 65 | from aixplain.factories import APIKeyFactory 66 | from aixplain.utils import config 67 | 68 | api_key = api_key or config.TEAM_API_KEY 69 | 70 | return APIKeyFactory.get_usage_limits(api_key, asset_id) 71 | -------------------------------------------------------------------------------- /aixplain/v2/data.py: -------------------------------------------------------------------------------- 1 | from .resource import ( 2 | BaseResource, 3 | GetResourceMixin, 4 | BareGetParams, 5 | ) 6 | 7 | from typing_extensions import Unpack 8 | 9 | 10 | class Data( 11 | BaseResource, 12 | GetResourceMixin[BareGetParams, "Data"], 13 | ): 14 | @classmethod 15 | def get(cls, id: str, **kwargs: Unpack[BareGetParams]) -> "Data": 16 | from aixplain.factories import DataFactory 17 | 18 | return DataFactory.get(data_id=id) 19 | -------------------------------------------------------------------------------- /aixplain/v2/file.py: -------------------------------------------------------------------------------- 1 | from typing import List, TYPE_CHECKING 2 | from typing_extensions import Unpack, NotRequired 3 | 4 | from aixplain.v2.resource import BaseResource, CreateResourceMixin, BaseCreateParams 5 | 6 | if TYPE_CHECKING: 7 | from aixplain.v2.enums import License, StorageType 8 | 9 | 10 | class FileCreateParams(BaseCreateParams): 11 | """Parameters for creating a file.""" 12 | 13 | local_path: str 14 | tags: NotRequired[List[str]] 15 | license: NotRequired["License"] 16 | is_temp: NotRequired[bool] 17 | 18 | 19 | class File(BaseResource, CreateResourceMixin[FileCreateParams, "File"]): 20 | """Resource for files.""" 21 | 22 | RESOURCE_PATH = "sdk/files" 23 | 24 | @classmethod 25 | def create(cls, *args, **kwargs: Unpack[FileCreateParams]) -> "File": 26 | """Create a file.""" 27 | from aixplain.factories import FileFactory 28 | 29 | kwargs.setdefault("is_temp", True) 30 | kwargs.setdefault("license", None) 31 | kwargs.setdefault("tags", None) 32 | 33 | return FileFactory.create(*args, **kwargs) 34 | 35 | @classmethod 36 | def to_link(cls, local_path: str) -> str: 37 | """Convert a local path to a link. 38 | 39 | Args: 40 | local_path: str: The local path to the file. 41 | 42 | Returns: 43 | str: The link to the file. 44 | """ 45 | from aixplain.factories import FileFactory 46 | 47 | return FileFactory.to_link(local_path) 48 | 49 | @classmethod 50 | def upload( 51 | cls, 52 | local_path: str, 53 | tags: List[str] = None, 54 | license: "License" = None, 55 | is_temp: bool = True, 56 | ) -> str: 57 | """Upload a file. 58 | 59 | Args: 60 | local_path: str: The local path to the file. 61 | 62 | Returns: 63 | str: The upload URL. 64 | """ 65 | from aixplain.factories import FileFactory 66 | 67 | return FileFactory.upload(local_path, tags, license, is_temp) 68 | 69 | @classmethod 70 | def check_storage_type(cls, upload_url: str) -> "StorageType": 71 | """Check the storage type of a file. 72 | 73 | Args: 74 | upload_url: str: The upload URL. 75 | 76 | Returns: 77 | StorageType: The storage type of the file. 78 | """ 79 | from aixplain.factories import FileFactory 80 | 81 | return FileFactory.check_storage_type(upload_url) 82 | -------------------------------------------------------------------------------- /aixplain/v2/finetune.py: -------------------------------------------------------------------------------- 1 | from typing import List, Union, TYPE_CHECKING 2 | from typing_extensions import Unpack, NotRequired 3 | 4 | from aixplain.v2.resource import ( 5 | BaseResource, 6 | CreateResourceMixin, 7 | BareCreateParams, 8 | ) 9 | 10 | if TYPE_CHECKING: 11 | from aixplain.modules.finetune import Hyperparameters 12 | from aixplain.modules.dataset import Dataset 13 | from aixplain.modules.model import Model 14 | 15 | 16 | class FinetuneCreateParams(BareCreateParams): 17 | """Parameters for creating a finetune. 18 | 19 | Attributes: 20 | name: str: The name of the finetune. 21 | dataset_list: List[Dataset]: The list of datasets. 22 | model: Union[Model, str]: The model. 23 | prompt_template: str: The prompt template. 24 | hyperparameters: Hyperparameters: The hyperparameters. 25 | train_percentage: float: The train percentage. 26 | dev_percentage: float: The dev percentage. 27 | """ 28 | 29 | name: str 30 | dataset_list: List["Dataset"] 31 | model: Union["Model", str] 32 | prompt_template: NotRequired[str] 33 | hyperparameters: NotRequired["Hyperparameters"] 34 | train_percentage: NotRequired[float] 35 | dev_percentage: NotRequired[float] 36 | 37 | 38 | class Finetune( 39 | BaseResource, 40 | CreateResourceMixin[FinetuneCreateParams, "Finetune"], 41 | ): 42 | """Resource for finetunes.""" 43 | 44 | RESOURCE_PATH = "sdk/finetunes" 45 | 46 | @classmethod 47 | def create(cls, *args, **kwargs: Unpack[FinetuneCreateParams]) -> "Finetune": 48 | from aixplain.factories import FinetuneFactory 49 | 50 | return FinetuneFactory.create(*args, **kwargs) 51 | -------------------------------------------------------------------------------- /aixplain/v2/metric.py: -------------------------------------------------------------------------------- 1 | from typing_extensions import Unpack, NotRequired 2 | 3 | from aixplain.v2.resource import ( 4 | BaseResource, 5 | ListResourceMixin, 6 | GetResourceMixin, 7 | BareGetParams, 8 | BaseListParams, 9 | Page, 10 | ) 11 | 12 | 13 | class MetricListParams(BaseListParams): 14 | """Parameters for listing metrics. 15 | 16 | Attributes: 17 | model_id: str: The model ID. 18 | is_source_required: bool: Whether the source is required. 19 | is_reference_required: bool: Whether the reference is required. 20 | """ 21 | 22 | model_id: str 23 | is_source_required: NotRequired[bool] 24 | is_reference_required: NotRequired[bool] 25 | 26 | 27 | class Metric( 28 | BaseResource, 29 | ListResourceMixin[MetricListParams, "Metric"], 30 | GetResourceMixin[BareGetParams, "Metric"], 31 | ): 32 | """Resource for metrics.""" 33 | 34 | RESOURCE_PATH = "sdk/metrics" 35 | 36 | @classmethod 37 | def get(cls, id: str, **kwargs: Unpack[BareGetParams]) -> "Metric": 38 | from aixplain.factories.metric_factory import MetricFactory 39 | 40 | return MetricFactory.get(metric_id=id) 41 | 42 | @classmethod 43 | def list(cls, **kwargs: Unpack[MetricListParams]) -> Page["Metric"]: 44 | from aixplain.factories.metric_factory import MetricFactory 45 | 46 | kwargs.setdefault("is_source_required", None) 47 | kwargs.setdefault("is_reference_required", None) 48 | kwargs.setdefault("page_number", cls.PAGINATE_DEFAULT_PAGE_NUMBER) 49 | kwargs.setdefault("page_size", cls.PAGINATE_DEFAULT_PAGE_SIZE) 50 | 51 | return MetricFactory.list(**kwargs) 52 | -------------------------------------------------------------------------------- /aixplain/v2/script.py: -------------------------------------------------------------------------------- 1 | from aixplain.v2.resource import BaseResource 2 | 3 | 4 | class Script(BaseResource): 5 | @classmethod 6 | def upload(cls, script_path: str) -> "Script": 7 | """Upload a script to the server. 8 | 9 | Args: 10 | script_path: str: The path to the script. 11 | 12 | Returns: 13 | Script: The script. 14 | """ 15 | from aixplain.factories.script_factory import ScriptFactory 16 | 17 | file_id, metadata = ScriptFactory.upload_script(script_path) 18 | 19 | return ScriptFactory.upload_script({"fileId": file_id, "metadata": metadata}) 20 | -------------------------------------------------------------------------------- /aixplain/v2/team_agent.py: -------------------------------------------------------------------------------- 1 | from typing_extensions import ( 2 | Dict, 3 | Unpack, 4 | List, 5 | Union, 6 | TYPE_CHECKING, 7 | NotRequired, 8 | Text, 9 | ) 10 | 11 | from .resource import ( 12 | BaseResource, 13 | ListResourceMixin, 14 | GetResourceMixin, 15 | BareListParams, 16 | BareGetParams, 17 | BaseCreateParams, 18 | Page, 19 | ) 20 | 21 | if TYPE_CHECKING: 22 | from aixplain.modules.agent import Agent 23 | from aixplain.enums import Supplier 24 | 25 | 26 | class TeamAgentCreateParams(BaseCreateParams): 27 | name: Text 28 | agents: List[Union[Text, "Agent"]] 29 | llm_id: Text 30 | description: Text 31 | api_key: Text 32 | supplier: Union[Dict, Text, "Supplier", int] 33 | version: NotRequired[Text] 34 | use_mentalist_and_inspector: bool 35 | 36 | 37 | class TeamAgentGetParams(BareGetParams): 38 | api_key: NotRequired[str] 39 | 40 | 41 | class TeamAgent( 42 | BaseResource, 43 | ListResourceMixin[BareListParams, "TeamAgent"], 44 | GetResourceMixin[BareGetParams, "TeamAgent"], 45 | ): 46 | """Resource for agents. 47 | 48 | Attributes: 49 | RESOURCE_PATH: str: The resource path. 50 | PAGINATE_PATH: None: The path for pagination. 51 | PAGINATE_METHOD: str: The method for pagination. 52 | PAGINATE_ITEMS_KEY: None: The key for the response. 53 | """ 54 | 55 | RESOURCE_PATH = "sdk/agent-communities" 56 | PAGINATE_PATH = None 57 | PAGINATE_METHOD = "get" 58 | PAGINATE_ITEMS_KEY = None 59 | 60 | LLM_ID = "669a63646eb56306647e1091" 61 | SUPPLIER = "aiXplain" 62 | 63 | @classmethod 64 | def list(cls, **kwargs: Unpack[BareListParams]) -> Page["TeamAgent"]: 65 | from aixplain.factories import TeamAgentFactory 66 | 67 | return TeamAgentFactory.list(**kwargs) 68 | 69 | @classmethod 70 | def get(cls, id: str, **kwargs: Unpack[TeamAgentGetParams]) -> "TeamAgent": 71 | from aixplain.factories import TeamAgentFactory 72 | 73 | return TeamAgentFactory.get(id, **kwargs) 74 | 75 | @classmethod 76 | def create(cls, *args, **kwargs: Unpack[TeamAgentCreateParams]) -> "TeamAgent": 77 | from aixplain.factories import TeamAgentFactory 78 | from aixplain.utils import config 79 | 80 | kwargs.setdefault("llm_id", cls.LLM_ID) 81 | kwargs.setdefault("api_key", config.TEAM_API_KEY) 82 | kwargs.setdefault("supplier", cls.SUPPLIER) 83 | kwargs.setdefault("description", "") 84 | kwargs.setdefault("use_mentalist_and_inspector", True) 85 | 86 | return TeamAgentFactory.create(*args, **kwargs) 87 | -------------------------------------------------------------------------------- /aixplain/v2/wallet.py: -------------------------------------------------------------------------------- 1 | from .resource import ( 2 | BaseResource, 3 | GetResourceMixin, 4 | BareGetParams, 5 | ) 6 | from typing_extensions import Unpack, NotRequired 7 | 8 | 9 | class WalletGetParams(BareGetParams): 10 | api_key: NotRequired[str] 11 | 12 | 13 | class Wallet( 14 | BaseResource, 15 | GetResourceMixin[WalletGetParams, "Wallet"], 16 | ): 17 | @classmethod 18 | def get(cls, **kwargs: Unpack[WalletGetParams]) -> "Wallet": 19 | from aixplain.factories import WalletFactory 20 | import aixplain.utils.config as config 21 | 22 | api_key = kwargs.get("api_key", config.TEAM_API_KEY) 23 | return WalletFactory.get(api_key=api_key) 24 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # aiXplain SDK 2 | 3 |
4 | aiXplain logo 5 |
6 |
7 | 8 | [![Python 3.5+](https://img.shields.io/badge/python-3.5+-blue.svg)](https://www.python.org/downloads/) 9 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0) 10 | [![PyPI version](https://badge.fury.io/py/aiXplain.svg)](https://badge.fury.io/py/aiXplain) 11 | 12 | **The professional AI SDK for developers and enterprises** 13 |
14 | 15 | ## 📖 API Reference 16 | 17 | - **Complete documentation:** 18 | - [Python](https://docs.aixplain.com/api-reference/python/) 19 | - [Swift](https://docs.aixplain.com/api-reference/swift/) 20 | 21 | 22 | ## 🚀 Overview 23 | 24 | The aiXplain SDK is a comprehensive Python library that empowers developers to integrate cutting-edge AI capabilities into their applications with ease. Access thousands of AI models, build custom pipelines, and deploy intelligent solutions at scale. 25 | 26 | ### ✨ Key Features 27 | 28 | - **🔍 Discover**: Access 35,000+ ready-to-use AI models across multiple domains 29 | - **⚡ Benchmark**: Compare AI systems using comprehensive datasets and metrics 30 | - **🛠️ Design**: Create and deploy custom AI pipelines with our visual designer 31 | - **🎯 FineTune**: Enhance pre-trained models with your data for optimal performance 32 | 33 | 34 | ## 📦 Installation 35 | ```bash 36 | pip install aixplain 37 | ``` 38 | 39 | ## 🔑 Authentication 40 | ```bash 41 | export TEAM_API_KEY=your_api_key_here 42 | ``` 43 | 44 | ## 🏃‍♂️ Quick Start 45 | ```python 46 | agent = AgentFactory.create( 47 | name="Google Search Agent", 48 | description="A search agent", 49 | instructions="Use Google Search to answer queries.", 50 | tools=[ 51 | # Google Search (Serp) 52 | AgentFactory.create_model_tool("65c51c556eb563350f6e1bb1")]) 53 | 54 | response = agent.run("What's the latest AI news?").data.output 55 | print(response) 56 | 57 | agent.deploy() 58 | ``` 59 | 60 | ## 🔗 Platform Links 61 | - **Platform**: [platform.aixplain.com](https://platform.aixplain.com) 62 | - **Discover**: [platform.aixplain.com/discover](https://platform.aixplain.com/discover) 63 | - **Docs**: [docs.aixplain.com/](https://docs.aixplain.com/) 64 | - **Support**: [GitHub Issues](https://github.com/aixplain/aiXplain/issues) 65 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/cli_groups.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: cli_groups 3 | title: aixplain.cli_groups 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2022 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: Michael Lam 23 | Date: September 18th 2023 24 | Description: 25 | CLI Runner 26 | 27 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/decorators/api_key_checker.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: api_key_checker 3 | title: aixplain.decorators.api_key_checker 4 | --- 5 | 6 | API key validation decorator for aiXplain SDK. 7 | 8 | #### check\_api\_key 9 | 10 | ```python 11 | def check_api_key(method) 12 | ``` 13 | 14 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/decorators/api_key_checker.py#L6) 15 | 16 | Decorator to verify that an API key is set before executing the method. 17 | 18 | This decorator uses the centralized API key validation logic from config.py 19 | to ensure consistent behavior across the entire SDK. 20 | 21 | **Arguments**: 22 | 23 | - `method` _callable_ - The method to be decorated. 24 | 25 | 26 | **Returns**: 27 | 28 | - `callable` - The wrapped method that includes API key verification. 29 | 30 | 31 | **Raises**: 32 | 33 | - `Exception` - If neither TEAM_API_KEY nor AIXPLAIN_API_KEY is set. 34 | 35 | 36 | **Example**: 37 | 38 | @check_api_key 39 | def my_api_method(): 40 | # Method implementation 41 | pass 42 | 43 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/decorators/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: decorators 4 | title: aixplain.decorators 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/asset_status.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: asset_status 3 | title: aixplain.enums.asset_status 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2024 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 23 | Date: February 21st 2024 24 | Description: 25 | Asset Enum 26 | 27 | ### AssetStatus Objects 28 | 29 | ```python 30 | class AssetStatus(Text, Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/asset_status.py#L28) 34 | 35 | Enumeration of possible status values for an asset in the aiXplain system. 36 | 37 | This enum defines all possible states that an asset can be in throughout its lifecycle, 38 | from creation to deletion. Each enum value corresponds to a specific state in the 39 | asset's lifecycle. 40 | 41 | **Attributes**: 42 | 43 | - `DRAFT` _str_ - Initial state for a newly created asset. 44 | - `HIDDEN` _str_ - Asset is hidden from public view. 45 | - `SCHEDULED` _str_ - Asset is scheduled for processing. 46 | - `ONBOARDING` _str_ - Asset is in the process of being onboarded. 47 | - `ONBOARDED` _str_ - Asset has been successfully onboarded. 48 | - `PENDING` _str_ - Asset is waiting for processing. 49 | - `FAILED` _str_ - Asset processing has failed. 50 | - `TRAINING` _str_ - Asset is currently in training. 51 | - `REJECTED` _str_ - Asset has been rejected. 52 | - `ENABLING` _str_ - Asset is in the process of being enabled. 53 | - `HIDDEN`0 _str_ - Asset is in the process of being deleted. 54 | - `HIDDEN`1 _str_ - Asset has been disabled. 55 | - `HIDDEN`2 _str_ - Asset has been deleted. 56 | - `HIDDEN`3 _str_ - Asset is currently being processed. 57 | - `HIDDEN`4 _str_ - Asset has completed processing. 58 | - `HIDDEN`5 _str_ - Asset operation is being canceled. 59 | - `HIDDEN`6 _str_ - Asset operation has been canceled. 60 | - `HIDDEN`7 _str_ - Draft state that has been deprecated. 61 | 62 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/code_interpreter.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: code_interpreter 3 | title: aixplain.enums.code_interpreter 4 | --- 5 | 6 | ### CodeInterpreterModel Objects 7 | 8 | ```python 9 | class CodeInterpreterModel(str, Enum) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/code_interpreter.py#L4) 13 | 14 | Enumeration of available Code Interpreter model identifiers. 15 | 16 | This enum defines the unique identifiers for different code interpreter models 17 | available in the system. Each value represents a specific model's ID that can 18 | be used for code interpretation tasks. 19 | 20 | **Attributes**: 21 | 22 | - `PYTHON_AZURE` _str_ - Model ID for the Python code interpreter running on Azure. 23 | 24 | #### \_\_str\_\_ 25 | 26 | ```python 27 | def __str__() -> str 28 | ``` 29 | 30 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/code_interpreter.py#L17) 31 | 32 | Return the string representation of the model ID. 33 | 34 | **Returns**: 35 | 36 | - `str` - The model ID value as a string. 37 | 38 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/data_split.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: data_split 3 | title: aixplain.enums.data_split 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: March 20th 2023 24 | Description: 25 | Data Split Enum 26 | 27 | ### DataSplit Objects 28 | 29 | ```python 30 | class DataSplit(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/data_split.py#L27) 34 | 35 | Enumeration of dataset split types. 36 | 37 | This enum defines the standard dataset split types used for machine learning tasks, 38 | including training, validation, and testing splits. 39 | 40 | **Attributes**: 41 | 42 | - `TRAIN` _str_ - Training dataset split used for model training. 43 | - `VALIDATION` _str_ - Validation dataset split used for model tuning. 44 | - `TEST` _str_ - Test dataset split used for final model evaluation. 45 | 46 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/data_subtype.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: data_subtype 3 | title: aixplain.enums.data_subtype 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: May 3rd 2023 24 | Description: 25 | Data Subtype Enum 26 | 27 | ### DataSubtype Objects 28 | 29 | ```python 30 | class DataSubtype(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/data_subtype.py#L27) 34 | 35 | Enumeration of data subtypes for categorizing and organizing data. 36 | 37 | This enum defines various subtypes that can be used to further categorize 38 | data points within the system, particularly useful for demographic and 39 | content-based categorization. 40 | 41 | **Attributes**: 42 | 43 | - `AGE` _str_ - Age category subtype. 44 | - `GENDER` _str_ - Gender category subtype. 45 | - `INTERVAL` _str_ - Time interval subtype. 46 | - `OTHER` _str_ - Miscellaneous/other subtype. 47 | - `RACE` _str_ - Race/ethnicity category subtype. 48 | - `SPLIT` _str_ - Data split category subtype. 49 | - `TOPIC` _str_ - Content topic subtype. 50 | 51 | #### \_\_str\_\_ 52 | 53 | ```python 54 | def __str__() -> str 55 | ``` 56 | 57 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/data_subtype.py#L51) 58 | 59 | Return the string representation of the data subtype. 60 | 61 | **Returns**: 62 | 63 | - `str` - The data subtype value as a string. 64 | 65 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/data_type.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: data_type 3 | title: aixplain.enums.data_type 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: March 20th 2023 24 | Description: 25 | Data Type Enum 26 | 27 | ### DataType Objects 28 | 29 | ```python 30 | class DataType(str, Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/data_type.py#L27) 34 | 35 | Enumeration of supported data types in the aiXplain system. 36 | 37 | This enum defines all the data types that can be processed by the system, 38 | including various media types and basic data types. 39 | 40 | **Attributes**: 41 | 42 | - `AUDIO` _str_ - Audio data type. 43 | - `FLOAT` _str_ - Floating-point number data type. 44 | - `IMAGE` _str_ - Image data type. 45 | - `INTEGER` _str_ - Integer number data type. 46 | - `LABEL` _str_ - Label/category data type. 47 | - `TENSOR` _str_ - Tensor/multi-dimensional array data type. 48 | - `TEXT` _str_ - Text data type. 49 | - `VIDEO` _str_ - Video data type. 50 | - `EMBEDDING` _str_ - Vector embedding data type. 51 | - `NUMBER` _str_ - Generic number data type. 52 | - `FLOAT`0 _str_ - Boolean data type. 53 | 54 | #### \_\_str\_\_ 55 | 56 | ```python 57 | def __str__() -> str 58 | ``` 59 | 60 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/data_type.py#L58) 61 | 62 | Return the string representation of the data type. 63 | 64 | **Returns**: 65 | 66 | - `str` - The data type value as a string. 67 | 68 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/database_source.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: database_source 3 | title: aixplain.enums.database_source 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2024 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: Lucas Pavanelli and Thiago Castro Ferreira and Ahmet Gunduz 23 | Date: March 7th 2025 24 | Description: 25 | Database Source Type Enum 26 | 27 | ### DatabaseSourceType Objects 28 | 29 | ```python 30 | class DatabaseSourceType(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/database_source.py#L27) 34 | 35 | Enumeration of supported database source types. 36 | 37 | This enum defines the different types of database sources that can be used 38 | for data storage and retrieval in the system. 39 | 40 | **Attributes**: 41 | 42 | - `POSTGRESQL` _str_ - PostgreSQL database source type. 43 | - `SQLITE` _str_ - SQLite database source type. 44 | - `CSV` _str_ - CSV file source type. 45 | 46 | #### from\_string 47 | 48 | ```python 49 | @classmethod 50 | def from_string(cls, source_type: str) -> "DatabaseSourceType" 51 | ``` 52 | 53 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/database_source.py#L44) 54 | 55 | Convert string to DatabaseSourceType enum 56 | 57 | **Arguments**: 58 | 59 | - `source_type` _str_ - Source type string 60 | 61 | 62 | **Returns**: 63 | 64 | - `DatabaseSourceType` - Corresponding enum value 65 | 66 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/embedding_model.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: embedding_model 3 | title: aixplain.enums.embedding_model 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | Licensed under the Apache License, Version 2.0 (the "License"); 10 | you may not use this file except in compliance with the License. 11 | You may obtain a copy of the License at 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | Author: aiXplain team 19 | Date: February 17th 2025 20 | Description: 21 | Embedding Model Enum 22 | 23 | ### EmbeddingModel Objects 24 | 25 | ```python 26 | class EmbeddingModel(str, Enum) 27 | ``` 28 | 29 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/embedding_model.py#L23) 30 | 31 | Enumeration of available embedding models in the aiXplain system. 32 | 33 | This enum defines the unique identifiers for different embedding models that can 34 | be used to generate vector representations of data. 35 | 36 | **Attributes**: 37 | 38 | - `OPENAI_ADA002` _str_ - OpenAI's Ada-002 text embedding model ID. 39 | - `JINA_CLIP_V2_MULTIMODAL` _str_ - Jina CLIP v2 multimodal embedding model ID. 40 | - `MULTILINGUAL_E5_LARGE` _str_ - Multilingual E5 Large text embedding model ID. 41 | - `BGE_M3` _str_ - BGE-M3 embedding model ID. 42 | 43 | #### \_\_str\_\_ 44 | 45 | ```python 46 | def __str__() -> str 47 | ``` 48 | 49 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/embedding_model.py#L40) 50 | 51 | Return the string representation of the embedding model ID. 52 | 53 | **Returns**: 54 | 55 | - `str` - The model ID value as a string. 56 | 57 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/error_handler.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: error_handler 3 | title: aixplain.enums.error_handler 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: May 26th 2023 24 | Description: 25 | Error Handler Enum 26 | 27 | ### ErrorHandler Objects 28 | 29 | ```python 30 | class ErrorHandler(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/error_handler.py#L27) 34 | 35 | Enumeration class defining different error handler strategies. 36 | 37 | **Attributes**: 38 | 39 | - `SKIP` _str_ - skip failed rows. 40 | - `FAIL` _str_ - raise an exception. 41 | 42 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/evolve_type.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: evolve_type 3 | title: aixplain.enums.evolve_type 4 | --- 5 | 6 | ### EvolveType Objects 7 | 8 | ```python 9 | class EvolveType(str, Enum) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/evolve_type.py#L4) 13 | 14 | Enumeration of evolution types for team agents. 15 | 16 | This enum defines the available evolution strategies that can be applied 17 | to team agents during the evolution process. Each type represents a 18 | different approach to improving agent performance. 19 | 20 | **Attributes**: 21 | 22 | - `TEAM_TUNING` _str_ - Evolution strategy focused on tuning team-level 23 | configurations and interactions between agents. 24 | - `INSTRUCTION_TUNING` _str_ - Evolution strategy focused on refining 25 | individual agent instructions and prompts. 26 | 27 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/file_type.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: file_type 3 | title: aixplain.enums.file_type 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: March 20th 2023 24 | Description: 25 | File Type Enum 26 | 27 | ### FileType Objects 28 | 29 | ```python 30 | class FileType(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/file_type.py#L27) 34 | 35 | Enumeration of supported file types in the aiXplain system. 36 | 37 | This enum defines the file extensions for various file formats that can be 38 | processed by the system, including document, audio, image, and video formats. 39 | 40 | **Attributes**: 41 | 42 | - `CSV` _str_ - Comma-separated values file (.csv). 43 | - `JSON` _str_ - JSON document file (.json). 44 | - `TXT` _str_ - Plain text file (.txt). 45 | - `XML` _str_ - XML document file (.xml). 46 | - `FLAC` _str_ - Free Lossless Audio Codec file (.flac). 47 | - `MP3` _str_ - MP3 audio file (.mp3). 48 | - `WAV` _str_ - Waveform audio file (.wav). 49 | - `JPEG` _str_ - JPEG image file (.jpeg). 50 | - `PNG` _str_ - Portable Network Graphics file (.png). 51 | - `JPG` _str_ - JPEG image file (.jpg). 52 | - `JSON`0 _str_ - Graphics Interchange Format file (.gif). 53 | - `JSON`1 _str_ - WebP image file (.webp). 54 | - `JSON`2 _str_ - Audio Video Interleave file (.avi). 55 | - `JSON`3 _str_ - MPEG-4 video file (.mp4). 56 | - `JSON`4 _str_ - QuickTime movie file (.mov). 57 | - `JSON`5 _str_ - MPEG-4 video file (.mpeg4). 58 | 59 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/function_type.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: function_type 3 | title: aixplain.enums.function_type 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: May 22th 2025 24 | Description: 25 | Function Type Enum 26 | 27 | ### FunctionType Objects 28 | 29 | ```python 30 | class FunctionType(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/function_type.py#L27) 34 | 35 | Enumeration of function types in the aiXplain system. 36 | 37 | This enum defines the different types of functions and services available 38 | in the system, including AI models, data processing utilities, and 39 | integration components. 40 | 41 | **Attributes**: 42 | 43 | - `AI` _str_ - Artificial Intelligence function type. 44 | - `SEGMENTOR` _str_ - Data segmentation function type. 45 | - `RECONSTRUCTOR` _str_ - Data reconstruction function type. 46 | - `UTILITY` _str_ - Utility function type. 47 | - `METRIC` _str_ - Metric/evaluation function type. 48 | - `SEARCH` _str_ - Search function type. 49 | - `INTEGRATION` _str_ - Integration connector function type. # i.e. slack 50 | - `CONNECTION` _str_ - Connection function type. # slack - action 51 | - `MCP_CONNECTION` _str_ - MCP connection function type. 52 | - `MCPSERVER` _str_ - MCP server is for on-prem solution. It should be treated like a model. # ONPREM_MCP_MODEL 53 | 54 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/index_stores.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: index_stores 3 | title: aixplain.enums.index_stores 4 | --- 5 | 6 | ### IndexStores Objects 7 | 8 | ```python 9 | class IndexStores(Enum) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/index_stores.py#L4) 13 | 14 | Enumeration of available index store providers in the aiXplain system. 15 | 16 | This enum defines the different index store providers that can be used for 17 | storing and retrieving indexed data, along with their identifiers. 18 | 19 | **Attributes**: 20 | 21 | - `AIR` _dict_ - AIR index store configuration with name and ID. 22 | - `VECTARA` _dict_ - Vectara index store configuration with name and ID. 23 | - `GRAPHRAG` _dict_ - GraphRAG index store configuration with name and ID. 24 | - `ZERO_ENTROPY` _dict_ - Zero Entropy index store configuration with name and ID. 25 | 26 | #### \_\_str\_\_ 27 | 28 | ```python 29 | def __str__() -> str 30 | ``` 31 | 32 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/index_stores.py#L21) 33 | 34 | Return the name of the index store. 35 | 36 | **Returns**: 37 | 38 | - `str` - The name value from the index store configuration. 39 | 40 | #### get\_model\_id 41 | 42 | ```python 43 | def get_model_id() -> str 44 | ``` 45 | 46 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/index_stores.py#L29) 47 | 48 | Return the model ID of the index store. 49 | 50 | **Returns**: 51 | 52 | - `str` - The ID value from the index store configuration. 53 | 54 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: enums 4 | title: aixplain.enums 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/onboard_status.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: onboard_status 3 | title: aixplain.enums.onboard_status 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: March 22th 2023 24 | Description: 25 | Onboard Status Enum 26 | 27 | ### OnboardStatus Objects 28 | 29 | ```python 30 | class OnboardStatus(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/onboard_status.py#L27) 34 | 35 | Enumeration of possible onboarding status values. 36 | 37 | This enum defines all possible states that an onboarding process can be in, 38 | from initial onboarding to completed or failed states. 39 | 40 | **Attributes**: 41 | 42 | - `ONBOARDING` _str_ - Initial onboarding state. 43 | - `ONBOARDED` _str_ - Successful onboarding state. 44 | - `FAILED` _str_ - Failed onboarding state. 45 | - `DELETED` _str_ - Deleted onboarding state. 46 | 47 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/ownership_type.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: ownership_type 3 | title: aixplain.enums.ownership_type 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: November 22nd 2023 24 | Description: 25 | Asset Ownership Type 26 | 27 | ### OwnershipType Objects 28 | 29 | ```python 30 | class OwnershipType(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/ownership_type.py#L27) 34 | 35 | Enumeration of possible ownership types. 36 | 37 | This enum defines the different types of ownership that can be associated with 38 | an asset or resource, including subscribed and owned ownership. 39 | 40 | **Attributes**: 41 | 42 | - `SUBSCRIBED` _str_ - Subscribed ownership type. 43 | - `OWNED` _str_ - Owned ownership type. 44 | 45 | #### \_\_str\_\_ 46 | 47 | ```python 48 | def __str__() 49 | ``` 50 | 51 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/ownership_type.py#L40) 52 | 53 | Return the string representation of the ownership type. 54 | 55 | **Returns**: 56 | 57 | - `str` - The ownership type value as a string. 58 | 59 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/privacy.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: privacy 3 | title: aixplain.enums.privacy 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: March 20th 2023 24 | Description: 25 | Privacy Enum 26 | 27 | ### Privacy Objects 28 | 29 | ```python 30 | class Privacy(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/privacy.py#L27) 34 | 35 | Enumeration of possible privacy levels. 36 | 37 | This enum defines the different levels of privacy that can be associated with 38 | an asset or resource, including public, private, and restricted privacy levels. 39 | 40 | **Attributes**: 41 | 42 | - `PUBLIC` _str_ - Public privacy level. 43 | - `PRIVATE` _str_ - Private privacy level. 44 | - `RESTRICTED` _str_ - Restricted privacy level. 45 | 46 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/response_status.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: response_status 3 | title: aixplain.enums.response_status 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2024 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 23 | Date: February 21st 2024 24 | Description: 25 | Asset Enum 26 | 27 | ### ResponseStatus Objects 28 | 29 | ```python 30 | class ResponseStatus(Text, Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/response_status.py#L28) 34 | 35 | Enumeration of possible response status values. 36 | 37 | This enum defines the different statuses that a response can be in, including 38 | in progress, success, and failure. 39 | 40 | **Attributes**: 41 | 42 | - `IN_PROGRESS` _str_ - Response is in progress. 43 | - `SUCCESS` _str_ - Response was successful. 44 | - `FAILED` _str_ - Response failed. 45 | 46 | #### \_\_str\_\_ 47 | 48 | ```python 49 | def __str__() 50 | ``` 51 | 52 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/response_status.py#L43) 53 | 54 | Return the string representation of the response status. 55 | 56 | **Returns**: 57 | 58 | - `str` - The response status value as a string. 59 | 60 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/sort_by.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: sort_by 3 | title: aixplain.enums.sort_by 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: March 20th 2023 24 | Description: 25 | Sort By Enum 26 | 27 | ### SortBy Objects 28 | 29 | ```python 30 | class SortBy(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/sort_by.py#L27) 34 | 35 | Enumeration of possible sorting criteria. 36 | 37 | This enum defines the different criteria that can be used to sort assets, 38 | including creation date, price, and popularity. 39 | 40 | **Attributes**: 41 | 42 | - `CREATION_DATE` _str_ - Sort by creation date. 43 | - `PRICE` _str_ - Sort by normalized price. 44 | - `POPULARITY` _str_ - Sort by total number of subscriptions. 45 | 46 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/sort_order.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: sort_order 3 | title: aixplain.enums.sort_order 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: March 20th 2023 24 | Description: 25 | Sort By Enum 26 | 27 | ### SortOrder Objects 28 | 29 | ```python 30 | class SortOrder(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/sort_order.py#L27) 34 | 35 | Enumeration of possible sorting orders. 36 | 37 | This enum defines the different directions that can be used to sort assets, 38 | including ascending and descending order. 39 | 40 | **Attributes**: 41 | 42 | - `ASCENDING` _int_ - Sort in ascending order. 43 | - `DESCENDING` _int_ - Sort in descending order. 44 | 45 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/splitting_options.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: splitting_options 3 | title: aixplain.enums.splitting_options 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: May 30th 2025 24 | Description: 25 | Splitting Options Enum 26 | 27 | ### SplittingOptions Objects 28 | 29 | ```python 30 | class SplittingOptions(str, Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/splitting_options.py#L27) 34 | 35 | Enumeration of possible splitting options. 36 | 37 | This enum defines the different ways that text can be split into chunks, 38 | including by word, sentence, passage, page, and line. 39 | 40 | **Attributes**: 41 | 42 | - `WORD` _str_ - Split by word. 43 | - `SENTENCE` _str_ - Split by sentence. 44 | - `PASSAGE` _str_ - Split by passage. 45 | - `PAGE` _str_ - Split by page. 46 | - `LINE` _str_ - Split by line. 47 | 48 | #### \_\_str\_\_ 49 | 50 | ```python 51 | def __str__() 52 | ``` 53 | 54 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/splitting_options.py#L46) 55 | 56 | Return the string representation of the splitting option. 57 | 58 | **Returns**: 59 | 60 | - `str` - The splitting option value as a string. 61 | 62 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/status.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: status 3 | title: aixplain.enums.status 4 | --- 5 | 6 | ### Status Objects 7 | 8 | ```python 9 | class Status(Text, Enum) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/status.py#L5) 13 | 14 | Enumeration of possible status values. 15 | 16 | This enum defines the different statuses that a task or operation can be in, 17 | including failed, in progress, and success. 18 | 19 | **Attributes**: 20 | 21 | - `FAILED` _str_ - Task failed. 22 | - `IN_PROGRESS` _str_ - Task is in progress. 23 | - `SUCCESS` _str_ - Task was successful. 24 | 25 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/storage_type.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: storage_type 3 | title: aixplain.enums.storage_type 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: March 20th 2023 24 | Description: 25 | Storage Type Enum 26 | 27 | ### StorageType Objects 28 | 29 | ```python 30 | class StorageType(Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/storage_type.py#L27) 34 | 35 | Enumeration of possible storage types. 36 | 37 | This enum defines the different types of storage that can be used to store 38 | assets, including text, URL, and file. 39 | 40 | **Attributes**: 41 | 42 | - `TEXT` _str_ - Text storage type. 43 | - `URL` _str_ - URL storage type. 44 | - `FILE` _str_ - File storage type. 45 | 46 | #### \_\_str\_\_ 47 | 48 | ```python 49 | def __str__() 50 | ``` 51 | 52 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/storage_type.py#L42) 53 | 54 | Return the string representation of the storage type. 55 | 56 | **Returns**: 57 | 58 | - `str` - The storage type value as a string. 59 | 60 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/supplier.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: supplier 3 | title: aixplain.enums.supplier 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2023 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: September 25th 2023 24 | Description: 25 | Supplier Enum 26 | 27 | #### clean\_name 28 | 29 | ```python 30 | def clean_name(name: str) -> str 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/supplier.py#L33) 34 | 35 | Clean a supplier name by replacing spaces and special characters with underscores. 36 | 37 | This function takes a supplier name and performs the following transformations: 38 | 1. Replaces spaces and hyphens with underscores. 39 | 2. Removes any non-alphanumeric characters. 40 | 3. Removes any leading numbers. 41 | 42 | **Arguments**: 43 | 44 | - `name` _str_ - The supplier name to clean. 45 | 46 | 47 | **Returns**: 48 | 49 | - `str` - The cleaned supplier name. 50 | 51 | #### load\_suppliers 52 | 53 | ```python 54 | def load_suppliers() -> Enum 55 | ``` 56 | 57 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/enums/supplier.py#L53) 58 | 59 | Load suppliers from the backend or cache. 60 | 61 | This function fetches supplier information from the backend API and creates 62 | an Enum class with supplier names as keys. 63 | 64 | **Returns**: 65 | 66 | - `Enum` - An Enum class with supplier names as keys. 67 | 68 | 69 | **Raises**: 70 | 71 | - `Exception` - If suppliers cannot be loaded due to invalid API key or other errors. 72 | 73 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/exceptions/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: exceptions 3 | title: aixplain.exceptions 4 | --- 5 | 6 | Error message registry for aiXplain SDK. 7 | 8 | This module maintains a centralized registry of error messages used throughout the aiXplain ecosystem. 9 | It allows developers to look up existing error messages and reuse them instead of creating new ones. 10 | 11 | #### get\_error\_from\_status\_code 12 | 13 | ```python 14 | def get_error_from_status_code(status_code: int, 15 | error_details: str = None 16 | ) -> AixplainBaseException 17 | ``` 18 | 19 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/exceptions/__init__.py#L35) 20 | 21 | Map HTTP status codes to appropriate exception types. 22 | 23 | **Arguments**: 24 | 25 | - `status_code` _int_ - The HTTP status code to map. 26 | - `error_details` _str, optional_ - Additional error details to include in the message. 27 | 28 | 29 | **Returns**: 30 | 31 | - `AixplainBaseException` - An exception of the appropriate type. 32 | 33 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/factories/asset_factory.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: asset_factory 3 | title: aixplain.factories.asset_factory 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2022 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 23 | Date: December 27th 2022 24 | Description: 25 | Asset Factory Class 26 | 27 | ### AssetFactory Objects 28 | 29 | ```python 30 | class AssetFactory() 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/asset_factory.py#L30) 34 | 35 | Base class for asset factories. 36 | 37 | This class provides a common interface for creating and retrieving assets 38 | from the aiXplain platform. Subclasses should implement the abstract methods 39 | to define specific asset types. 40 | 41 | **Attributes**: 42 | 43 | - `backend_url` _str_ - Base URL for the aiXplain backend API. 44 | 45 | #### get 46 | 47 | ```python 48 | @abstractmethod 49 | def get(asset_id: Text) -> Asset 50 | ``` 51 | 52 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/asset_factory.py#L43) 53 | 54 | Create a 'Asset' object from id 55 | 56 | **Arguments**: 57 | 58 | - `asset_id` _str_ - ID of required asset. 59 | 60 | 61 | **Returns**: 62 | 63 | - `Asset` - Created 'Asset' object 64 | 65 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/factories/data_factory.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: data_factory 3 | title: aixplain.factories.data_factory 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2022 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 23 | Date: May 15th 2023 24 | Description: 25 | Data Factory Class 26 | 27 | ### DataFactory Objects 28 | 29 | ```python 30 | class DataFactory(AssetFactory) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/data_factory.py#L38) 34 | 35 | Factory class for creating and managing data assets. 36 | 37 | This class provides functionality for creating, retrieving, and managing 38 | data assets in the aiXplain platform. Data assets represent individual 39 | pieces of data (e.g., text, audio) that can be used in corpora or 40 | directly with models. 41 | 42 | **Attributes**: 43 | 44 | - `backend_url` _str_ - Base URL for the aiXplain backend API. 45 | 46 | #### get 47 | 48 | ```python 49 | @classmethod 50 | def get(cls, data_id: Text) -> Data 51 | ``` 52 | 53 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/data_factory.py#L95) 54 | 55 | Retrieve a data asset by its ID. 56 | 57 | This method fetches a data asset from the platform using its unique 58 | identifier. 59 | 60 | **Arguments**: 61 | 62 | - `data_id` _Text_ - Unique identifier of the data asset to retrieve. 63 | 64 | 65 | **Returns**: 66 | 67 | - `Data` - Retrieved data asset object with its configuration. 68 | 69 | 70 | **Raises**: 71 | 72 | - `Exception` - If: 73 | - Data asset ID is invalid or not found 74 | - Authentication fails 75 | - Service is unavailable 76 | 77 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/factories/finetune_factory/prompt_validator.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: prompt_validator 3 | title: aixplain.factories.finetune_factory.prompt_validator 4 | --- 5 | 6 | #### validate\_prompt 7 | 8 | ```python 9 | def validate_prompt(prompt: Text, dataset_list: List[Dataset]) -> Text 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/finetune_factory/prompt_validator.py#L23) 13 | 14 | Validate and normalize a prompt template against a list of datasets. 15 | 16 | This function processes a prompt template that contains references to dataset 17 | columns in the format <<COLUMN_NAME>> or <<COLUMN_ID>>. It validates that all 18 | referenced columns exist in the provided datasets and normalizes column IDs 19 | to their corresponding names. 20 | 21 | **Arguments**: 22 | 23 | - `prompt` _Text_ - Prompt template containing column references in 24 | <<COLUMN_NAME>> or <<COLUMN_ID>> format. 25 | - `dataset_list` _List[Dataset]_ - List of datasets to validate the 26 | prompt template against. 27 | 28 | 29 | **Returns**: 30 | 31 | - `Text` - Normalized prompt template with column references converted 32 | to \{COLUMN_NAME} format. 33 | 34 | 35 | **Raises**: 36 | 37 | - `AssertionError` - If any of these conditions are met: 38 | - Multiple datasets have the same referenced column name 39 | - Referenced columns are not found in any dataset 40 | 41 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/factories/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: factories 3 | title: aixplain.factories 4 | --- 5 | 6 | aiXplain SDK Library. 7 | --- 8 | 9 | aiXplain SDK enables python programmers to add AI functions 10 | to their software. 11 | 12 | Copyright 2022 The aiXplain SDK authors 13 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); 15 | you may not use this file except in compliance with the License. 16 | You may obtain a copy of the License at 17 | 18 | http://www.apache.org/licenses/LICENSE-2.0 19 | 20 | Unless required by applicable law or agreed to in writing, software 21 | distributed under the License is distributed on an "AS IS" BASIS, 22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | See the License for the specific language governing permissions and 24 | limitations under the License. 25 | 26 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/factories/model_factory/mixins/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: mixins 4 | title: aixplain.factories.model_factory.mixins 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/factories/model_factory/mixins/model_getter.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: model_getter 3 | title: aixplain.factories.model_factory.mixins.model_getter 4 | --- 5 | 6 | ### ModelGetterMixin Objects 7 | 8 | ```python 9 | class ModelGetterMixin() 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/model_factory/mixins/model_getter.py#L12) 13 | 14 | Mixin class providing model retrieval functionality. 15 | 16 | This mixin provides methods for retrieving model instances from the backend, 17 | with support for caching to improve performance. 18 | 19 | #### get 20 | 21 | ```python 22 | @classmethod 23 | def get(cls, 24 | model_id: Text, 25 | api_key: Optional[Text] = None, 26 | use_cache: bool = False) -> Model 27 | ``` 28 | 29 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/model_factory/mixins/model_getter.py#L19) 30 | 31 | Retrieve a model instance by its ID. 32 | 33 | This method attempts to retrieve a model from the cache if enabled, 34 | falling back to fetching from the backend if necessary. 35 | 36 | **Arguments**: 37 | 38 | - `model_id` _Text_ - ID of the model to retrieve. 39 | - `api_key` _Optional[Text], optional_ - API key for authentication. 40 | Defaults to None, using the configured TEAM_API_KEY. 41 | - `use_cache` _bool, optional_ - Whether to attempt retrieving from cache. 42 | Defaults to False. 43 | 44 | 45 | **Returns**: 46 | 47 | - `Model` - Retrieved model instance. 48 | 49 | 50 | **Raises**: 51 | 52 | - `Exception` - If the model cannot be retrieved or doesn't exist. 53 | 54 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/factories/pipeline_factory/utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: utils 3 | title: aixplain.factories.pipeline_factory.utils 4 | --- 5 | 6 | #### build\_from\_response 7 | 8 | ```python 9 | def build_from_response(response: Dict, 10 | load_architecture: bool = False) -> Pipeline 11 | ``` 12 | 13 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/pipeline_factory/utils.py#L23) 14 | 15 | Convert API response into a Pipeline object. 16 | 17 | This function creates a Pipeline object from an API response, optionally loading 18 | its full architecture including nodes and links. The architecture can include 19 | various node types like Input, Output, BareAsset, BareMetric, Decision, Router, 20 | Script, BareSegmentor, and BareReconstructor. 21 | 22 | **Arguments**: 23 | 24 | - `response` _Dict_ - API response containing pipeline information including: 25 | - id: Pipeline identifier 26 | - name: Pipeline name 27 | - api_key: Optional API key 28 | - status: Pipeline status (defaults to "draft") 29 | - nodes: Optional list of node configurations 30 | - links: Optional list of link configurations 31 | - `load_architecture` _bool, optional_ - Whether to load the full pipeline 32 | architecture including nodes and links. Defaults to False. 33 | 34 | 35 | **Returns**: 36 | 37 | - `Pipeline` - Instantiated pipeline object. If load_architecture is True, 38 | includes all configured nodes and links. If architecture loading fails, 39 | returns a pipeline with empty nodes and links lists. 40 | 41 | 42 | **Notes**: 43 | 44 | When loading architecture, decision nodes with passthrough parameters are 45 | processed first to ensure proper parameter linking. 46 | 47 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/factories/script_factory.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: script_factory 3 | title: aixplain.factories.script_factory 4 | --- 5 | 6 | ### ScriptFactory Objects 7 | 8 | ```python 9 | class ScriptFactory() 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/script_factory.py#L10) 13 | 14 | A factory class for handling script file operations. 15 | 16 | This class provides functionality for uploading script files to the backend 17 | and managing their metadata. 18 | 19 | #### upload\_script 20 | 21 | ```python 22 | @classmethod 23 | def upload_script(cls, script_path: str) -> Tuple[str, str] 24 | ``` 25 | 26 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/script_factory.py#L17) 27 | 28 | Uploads a script file to the backend and returns its ID and metadata. 29 | 30 | **Arguments**: 31 | 32 | - `script_path` _str_ - The file system path to the script file to be uploaded. 33 | 34 | 35 | **Returns**: 36 | 37 | Tuple[str, str]: A tuple containing: 38 | - file_id (str): The unique identifier assigned to the uploaded file. 39 | - metadata (str): JSON string containing file metadata (name and size). 40 | 41 | 42 | **Raises**: 43 | 44 | - `Exception` - If the upload fails or the file cannot be accessed. 45 | 46 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/factories/team_agent_factory/utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: utils 3 | title: aixplain.factories.team_agent_factory.utils 4 | --- 5 | 6 | #### build\_team\_agent 7 | 8 | ```python 9 | def build_team_agent(payload: Dict, 10 | agents: List[Agent] = None, 11 | api_key: Text = config.TEAM_API_KEY) -> TeamAgent 12 | ``` 13 | 14 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/team_agent_factory/utils.py#L23) 15 | 16 | Build a TeamAgent instance from configuration payload. 17 | 18 | This function creates a TeamAgent instance from a configuration payload, 19 | handling the setup of agents, LLMs, inspectors, and task dependencies. 20 | 21 | **Arguments**: 22 | 23 | - `payload` _Dict_ - Configuration dictionary containing: 24 | - id: Optional team agent ID 25 | - name: Team agent name 26 | - agents: List of agent configurations 27 | - description: Optional description 28 | - instructions: Optional instructions 29 | - teamId: Optional supplier information 30 | - version: Optional version 31 | - cost: Optional cost information 32 | - llmId: LLM model ID (defaults to GPT-4) 33 | - plannerId: Optional planner model ID 34 | - inspectors: Optional list of inspector configurations 35 | - inspectorTargets: Optional list of inspection targets 36 | - status: Team agent status 37 | - tools: Optional list of tool configurations 38 | - `agents` _List[Agent], optional_ - Pre-instantiated agent objects. If not 39 | provided, agents will be instantiated from IDs in the payload. 40 | Defaults to None. 41 | - `api_key` _Text, optional_ - API key for authentication. Defaults to 42 | config.TEAM_API_KEY. 43 | 44 | 45 | **Returns**: 46 | 47 | - `TeamAgent` - Configured team agent instance with all components initialized. 48 | 49 | 50 | **Raises**: 51 | 52 | - `Exception` - If a task dependency referenced in an agent's configuration 53 | cannot be found. 54 | 55 | #### is\_yaml\_formatted 56 | 57 | ```python 58 | def is_yaml_formatted(text) 59 | ``` 60 | 61 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/team_agent_factory/utils.py#L231) 62 | 63 | Check if a string is valid YAML format with additional validation. 64 | 65 | **Arguments**: 66 | 67 | - `text` _str_ - The string to check 68 | 69 | 70 | **Returns**: 71 | 72 | - `bool` - True if valid YAML, False otherwise 73 | 74 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/factories/wallet_factory.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: wallet_factory 3 | title: aixplain.factories.wallet_factory 4 | --- 5 | 6 | ### WalletFactory Objects 7 | 8 | ```python 9 | class WalletFactory() 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/wallet_factory.py#L8) 13 | 14 | A factory class for retrieving wallet information. 15 | 16 | This class provides functionality to fetch wallet details including total 17 | and reserved balance information from the backend API. 18 | 19 | **Attributes**: 20 | 21 | - `backend_url` - The URL endpoint for the backend API. 22 | 23 | #### get 24 | 25 | ```python 26 | @classmethod 27 | def get(cls, api_key: Text = config.TEAM_API_KEY) -> Wallet 28 | ``` 29 | 30 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/factories/wallet_factory.py#L20) 31 | 32 | Retrieves the current wallet information from the backend. 33 | 34 | This method fetches the wallet details including total balance and reserved balance 35 | using the provided API key. 36 | 37 | **Arguments**: 38 | 39 | - `api_key` _Text, optional_ - The API key for authentication. Defaults to config.TEAM_API_KEY. 40 | 41 | 42 | **Returns**: 43 | 44 | - `Wallet` - A Wallet object containing the total and reserved balance information. 45 | 46 | 47 | **Raises**: 48 | 49 | - `Exception` - If the wallet information cannot be retrieved from the backend. 50 | 51 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: aixplain 3 | title: aixplain 4 | --- 5 | 6 | aiXplain SDK Library. 7 | --- 8 | 9 | aiXplain SDK enables python programmers to add AI functions 10 | to their software. 11 | 12 | Copyright 2022 The aiXplain SDK authors 13 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); 15 | you may not use this file except in compliance with the License. 16 | You may obtain a copy of the License at 17 | 18 | http://www.apache.org/licenses/LICENSE-2.0 19 | 20 | Unless required by applicable law or agreed to in writing, software 21 | distributed under the License is distributed on an "AS IS" BASIS, 22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | See the License for the specific language governing permissions and 24 | limitations under the License. 25 | 26 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/agent/output_format.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: output_format 3 | title: aixplain.modules.agent.output_format 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2024 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 23 | Date: February 21st 2024 24 | Description: 25 | Asset Enum 26 | 27 | ### OutputFormat Objects 28 | 29 | ```python 30 | class OutputFormat(Text, Enum) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/agent/output_format.py#L28) 34 | 35 | Enum representing different output formats for AI agent responses. 36 | 37 | This enum defines the possible output formats that can be used by AI agents. 38 | Each format is represented by a string constant. 39 | 40 | **Attributes**: 41 | 42 | - `MARKDOWN` _Text_ - Markdown format for formatted text output. 43 | - `TEXT` _Text_ - Plain text output. 44 | - `JSON` _Text_ - JSON format for structured data output. 45 | 46 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/agent/utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: utils 3 | title: aixplain.modules.agent.utils 4 | --- 5 | 6 | #### process\_variables 7 | 8 | ```python 9 | def process_variables(query: Union[Text, Dict], data: Union[Dict, Text], 10 | parameters: Dict, 11 | agent_description: Union[Text, None]) -> Text 12 | ``` 13 | 14 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/agent/utils.py#L5) 15 | 16 | Process variables in an agent's description and input data. 17 | 18 | This function validates and processes variables in an agent's description and 19 | input data, ensuring that all required variables are present and properly 20 | formatted. 21 | 22 | **Arguments**: 23 | 24 | - `query` _Union[Text, Dict]_ - The input data provided to the agent. 25 | - `data` _Union[Dict, Text]_ - The data to be processed. 26 | - `parameters` _Dict_ - The parameters available to the agent. 27 | - `agent_description` _Union[Text, None]_ - The description of the agent. 28 | 29 | 30 | **Returns**: 31 | 32 | - `Text` - The processed input data with all required variables included. 33 | 34 | 35 | **Raises**: 36 | 37 | - `AssertionError` - If a required variable is not found in the data or parameters. 38 | 39 | #### validate\_history 40 | 41 | ```python 42 | def validate_history(history) 43 | ``` 44 | 45 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/agent/utils.py#L55) 46 | 47 | Validates that `history` is a list of dicts, each with 'role' and 'content' keys. 48 | Raises a ValueError if validation fails. 49 | 50 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/file.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: file 3 | title: aixplain.modules.file 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2022 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain team 23 | Date: March 20th 2023 24 | Description: 25 | File Class 26 | 27 | ### File Objects 28 | 29 | ```python 30 | class File() 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/file.py#L31) 34 | 35 | A class representing a file in the aiXplain platform. 36 | 37 | This class provides functionality for managing files, which are used to store 38 | data samples in the platform. It supports various file types, compression formats, 39 | and data splits. 40 | 41 | **Attributes**: 42 | 43 | - `path` _Union[Text, pathlib.Path]_ - File path 44 | - `extension` _Union[Text, FileType]_ - File extension (e.g. CSV, TXT, etc.) 45 | - `data_split` _Optional[DataSplit]_ - Data split of the file. 46 | - `compression` _Optional[Text]_ - Compression extension (e.g., .gz). 47 | 48 | #### \_\_init\_\_ 49 | 50 | ```python 51 | def __init__(path: Union[Text, pathlib.Path], 52 | extension: Union[Text, FileType], 53 | data_split: Optional[DataSplit] = None, 54 | compression: Optional[Text] = None) -> None 55 | ``` 56 | 57 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/file.py#L44) 58 | 59 | Initialize a new File instance. 60 | 61 | **Arguments**: 62 | 63 | - `path` _Union[Text, pathlib.Path]_ - File path 64 | - `extension` _Union[Text, FileType]_ - File extension (e.g. CSV, TXT, etc.) 65 | - `data_split` _Optional[DataSplit], optional_ - Data split of the file. Defaults to None. 66 | - `compression` _Optional[Text], optional_ - Compression extension (e.g., .gz). Defaults to None. 67 | 68 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/finetune/status.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: status 3 | title: aixplain.modules.finetune.status 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2024 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 23 | Date: February 21st 2024 24 | Description: 25 | FinetuneCost Class 26 | 27 | ### FinetuneStatus Objects 28 | 29 | ```python 30 | @dataclass_json 31 | 32 | @dataclass 33 | class FinetuneStatus(object) 34 | ``` 35 | 36 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/finetune/status.py#L32) 37 | 38 | Status information for a fine-tuning job. 39 | 40 | This class encapsulates the status of a fine-tuning job, including the overall 41 | status of the job, the status of the model, and various training metrics. 42 | 43 | **Attributes**: 44 | 45 | - `status` _AssetStatus_ - Overall status of the fine-tuning job. 46 | - `model_status` _AssetStatus_ - Status of the fine-tuned model. 47 | - `epoch` _Optional[float]_ - Current training epoch. 48 | - `training_loss` _Optional[float]_ - Training loss at the current epoch. 49 | - `validation_loss` _Optional[float]_ - Validation loss at the current epoch. 50 | 51 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: modules 3 | title: aixplain.modules 4 | --- 5 | 6 | aiXplain SDK Library. 7 | --- 8 | 9 | aiXplain SDK enables python programmers to add AI functions 10 | to their software. 11 | 12 | Copyright 2022 The aiXplain SDK authors 13 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); 15 | you may not use this file except in compliance with the License. 16 | You may obtain a copy of the License at 17 | 18 | http://www.apache.org/licenses/LICENSE-2.0 19 | 20 | Unless required by applicable law or agreed to in writing, software 21 | distributed under the License is distributed on an "AS IS" BASIS, 22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | See the License for the specific language governing permissions and 24 | limitations under the License. 25 | 26 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/mixins.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: mixins 3 | title: aixplain.modules.mixins 4 | --- 5 | 6 | Mixins for common functionality across different asset types. 7 | 8 | Copyright 2024 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli 23 | Date: November 25th 2024 24 | Description: 25 | Mixins for common functionality across different asset types 26 | 27 | ### DeployableMixin Objects 28 | 29 | ```python 30 | class DeployableMixin(ABC, Generic[T]) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/mixins.py#L31) 34 | 35 | A mixin that provides common deployment-related functionality for assets. 36 | 37 | This mixin provides methods for: 38 | 1. Filtering items that are not onboarded 39 | 2. Validating if an asset is ready to be deployed 40 | 3. Deploying an asset 41 | 42 | Classes that inherit from this mixin should: 43 | 1. Implement _validate_deployment_readiness to call the parent implementation with their specific asset type 44 | 2. Optionally override deploy() if they need special deployment handling 45 | 46 | #### deploy 47 | 48 | ```python 49 | def deploy() -> None 50 | ``` 51 | 52 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/mixins.py#L62) 53 | 54 | Deploy the asset. 55 | 56 | This method validates that the asset is ready to be deployed and updates its status to ONBOARDED. 57 | Classes that need special deployment handling should override this method. 58 | 59 | **Raises**: 60 | 61 | - `AlreadyDeployedError` - If the asset is already deployed 62 | - `ValueError` - If the asset is not ready to be deployed 63 | 64 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/model/model_parameters.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: model_parameters 3 | title: aixplain.modules.model.model_parameters 4 | --- 5 | 6 | ### ModelParameters Objects 7 | 8 | ```python 9 | class ModelParameters(BaseParameters) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/model/model_parameters.py#L5) 13 | 14 | #### \_\_init\_\_ 15 | 16 | ```python 17 | def __init__(input_params: Dict[str, Dict[str, Any]]) -> None 18 | ``` 19 | 20 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/model/model_parameters.py#L6) 21 | 22 | Initialize ModelParameters with input parameters dictionary. 23 | 24 | **Arguments**: 25 | 26 | - `input_params` _Dict[str, Dict[str, Any]]_ - Dictionary containing parameter configurations 27 | 28 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/model/model_response_streamer.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: model_response_streamer 3 | title: aixplain.modules.model.model_response_streamer 4 | --- 5 | 6 | ### ModelResponseStreamer Objects 7 | 8 | ```python 9 | class ModelResponseStreamer() 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/model/model_response_streamer.py#L7) 13 | 14 | A class representing a streamer for model responses. 15 | 16 | This class provides an iterator interface for streaming model responses. 17 | It handles the conversion of JSON-like strings into ModelResponse objects 18 | and manages the response status. 19 | 20 | #### \_\_init\_\_ 21 | 22 | ```python 23 | def __init__(iterator: Iterator) 24 | ``` 25 | 26 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/model/model_response_streamer.py#L15) 27 | 28 | Initialize a new ModelResponseStreamer instance. 29 | 30 | **Arguments**: 31 | 32 | - `iterator` _Iterator_ - An iterator that yields JSON-like strings. 33 | 34 | #### \_\_next\_\_ 35 | 36 | ```python 37 | def __next__() 38 | ``` 39 | 40 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/model/model_response_streamer.py#L24) 41 | 42 | Return the next chunk of the response. 43 | 44 | **Returns**: 45 | 46 | - `ModelResponse` - A ModelResponse object containing the next chunk of the response. 47 | 48 | #### \_\_iter\_\_ 49 | 50 | ```python 51 | def __iter__() 52 | ``` 53 | 54 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/model/model_response_streamer.py#L41) 55 | 56 | Return the iterator for the ModelResponseStreamer. 57 | 58 | **Returns**: 59 | 60 | - `Iterator` - The iterator for the ModelResponseStreamer. 61 | 62 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/model/record.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: record 3 | title: aixplain.modules.model.record 4 | --- 5 | 6 | ### Record Objects 7 | 8 | ```python 9 | class Record() 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/model/record.py#L6) 13 | 14 | A class representing a record in an index. 15 | 16 | This class defines the structure of a record with its value, type, ID, URI, 17 | and attributes. 18 | 19 | #### \_\_init\_\_ 20 | 21 | ```python 22 | def __init__(value: str = "", 23 | value_type: DataType = DataType.TEXT, 24 | id: Optional[str] = None, 25 | uri: str = "", 26 | attributes: dict = {}) 27 | ``` 28 | 29 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/model/record.py#L12) 30 | 31 | Initialize a new Record instance. 32 | 33 | **Arguments**: 34 | 35 | - `value` _str_ - The value of the record. 36 | - `value_type` _DataType_ - The type of the value. 37 | - `id` _Optional[str]_ - The ID of the record. Defaults to a random UUID. 38 | - `uri` _str_ - The URI of the record. 39 | - `attributes` _dict_ - The attributes of the record. 40 | 41 | #### to\_dict 42 | 43 | ```python 44 | def to_dict() 45 | ``` 46 | 47 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/model/record.py#L35) 48 | 49 | Convert the record to a dictionary. 50 | 51 | **Returns**: 52 | 53 | - `dict` - A dictionary containing the record's value, type, ID, URI, and attributes. 54 | 55 | #### validate 56 | 57 | ```python 58 | def validate() 59 | ``` 60 | 61 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/model/record.py#L49) 62 | 63 | Validate the record. 64 | 65 | **Raises**: 66 | 67 | - `AssertionError` - If the value type is invalid or if the URI is required for image records. 68 | 69 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/pipeline/default.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: default 3 | title: aixplain.modules.pipeline.default 4 | --- 5 | 6 | ### DefaultPipeline Objects 7 | 8 | ```python 9 | class DefaultPipeline(PipelineAsset, DesignerPipeline) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/pipeline/default.py#L6) 13 | 14 | DefaultPipeline is a subclass of PipelineAsset and DesignerPipeline. 15 | 16 | #### \_\_init\_\_ 17 | 18 | ```python 19 | def __init__(*args, **kwargs) 20 | ``` 21 | 22 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/pipeline/default.py#L10) 23 | 24 | Initialize the DefaultPipeline. 25 | 26 | #### save 27 | 28 | ```python 29 | def save(*args, **kwargs) 30 | ``` 31 | 32 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/pipeline/default.py#L17) 33 | 34 | Save the DefaultPipeline. 35 | 36 | #### to\_dict 37 | 38 | ```python 39 | def to_dict() -> dict 40 | ``` 41 | 42 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/pipeline/default.py#L25) 43 | 44 | Convert the DefaultPipeline to a dictionary. 45 | 46 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/pipeline/designer/enums.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: enums 3 | title: aixplain.modules.pipeline.designer.enums 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/pipeline/designer/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: designer 4 | title: aixplain.modules.pipeline.designer 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/pipeline/designer/utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: utils 3 | title: aixplain.modules.pipeline.designer.utils 4 | --- 5 | 6 | #### find\_prompt\_params 7 | 8 | ```python 9 | def find_prompt_params(prompt: str) -> List[str] 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/pipeline/designer/utils.py#L5) 13 | 14 | This method will find the prompt parameters in the prompt string. 15 | 16 | **Arguments**: 17 | 18 | - `prompt`: the prompt string 19 | 20 | **Returns**: 21 | 22 | list of prompt parameters 23 | 24 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/pipeline/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: pipeline 4 | title: aixplain.modules.pipeline 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/wallet.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: wallet 3 | title: aixplain.modules.wallet 4 | --- 5 | 6 | #### \_\_author\_\_ 7 | 8 | Copyright 2024 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | 22 | Author: aiXplain Team 23 | Date: August 20th 2024 24 | Description: 25 | Wallet Class 26 | 27 | ### Wallet Objects 28 | 29 | ```python 30 | class Wallet() 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/wallet.py#L25) 34 | 35 | A class representing a wallet for managing credit balances. 36 | 37 | This class provides functionality for managing credit balances in a wallet, 38 | including total, reserved, and available balances. It is used to track and 39 | manage credit resources in the aiXplain platform. 40 | 41 | **Attributes**: 42 | 43 | - `total_balance` _float_ - Total credit balance in the wallet. 44 | - `reserved_balance` _float_ - Reserved credit balance in the wallet. 45 | - `available_balance` _float_ - Available balance (total - reserved). 46 | 47 | #### \_\_init\_\_ 48 | 49 | ```python 50 | def __init__(total_balance: float, reserved_balance: float) 51 | ``` 52 | 53 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/wallet.py#L37) 54 | 55 | Initialize a new Wallet instance. 56 | 57 | **Arguments**: 58 | 59 | - `total_balance` _float_ - Total credit balance in the wallet. 60 | - `reserved_balance` _float_ - Reserved credit balance in the wallet. 61 | 62 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/processes/data_onboarding/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: data_onboarding 4 | title: aixplain.processes.data_onboarding 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/processes/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: processes 4 | title: aixplain.processes 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/utils/cache_utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: cache_utils 3 | title: aixplain.utils.cache_utils 4 | --- 5 | 6 | #### get\_cache\_expiry 7 | 8 | ```python 9 | def get_cache_expiry() -> int 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/utils/cache_utils.py#L17) 13 | 14 | Get the cache expiration duration in seconds. 15 | 16 | Retrieves the cache expiration duration from the CACHE_EXPIRY_TIME 17 | environment variable. If not set, falls back to the default CACHE_DURATION. 18 | 19 | **Returns**: 20 | 21 | - `int` - The cache expiration duration in seconds. 22 | 23 | #### save\_to\_cache 24 | 25 | ```python 26 | def save_to_cache(cache_file: str, data: dict, lock_file: str) -> None 27 | ``` 28 | 29 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/utils/cache_utils.py#L29) 30 | 31 | Save data to a cache file with thread-safe file locking. 32 | 33 | This function saves the provided data to a JSON cache file along with a 34 | timestamp. It uses file locking to ensure thread safety during writing. 35 | 36 | **Arguments**: 37 | 38 | - `cache_file` _str_ - Path to the cache file where data will be saved. 39 | - `data` _dict_ - The data to be cached. Must be JSON-serializable. 40 | - `lock_file` _str_ - Path to the lock file used for thread safety. 41 | 42 | 43 | **Notes**: 44 | 45 | - Creates the cache directory if it doesn't exist 46 | - Logs an error if saving fails but doesn't raise an exception 47 | - The data is saved with a timestamp for expiration checking 48 | 49 | #### load\_from\_cache 50 | 51 | ```python 52 | def load_from_cache(cache_file: str, lock_file: str) -> dict 53 | ``` 54 | 55 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/utils/cache_utils.py#L59) 56 | 57 | Load data from a cache file with expiration checking. 58 | 59 | This function loads data from a JSON cache file if it exists and hasn't 60 | expired. It uses file locking to ensure thread safety during reading. 61 | 62 | **Arguments**: 63 | 64 | - `cache_file` _str_ - Path to the cache file to load data from. 65 | - `lock_file` _str_ - Path to the lock file used for thread safety. 66 | 67 | 68 | **Returns**: 69 | 70 | - `dict` - The cached data if the cache exists and hasn't expired, 71 | None otherwise. 72 | 73 | 74 | **Notes**: 75 | 76 | - Returns None if the cache file doesn't exist 77 | - Returns None if the cached data has expired based on CACHE_EXPIRY_TIME 78 | - Uses thread-safe file locking for reading 79 | 80 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/utils/config.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: config 3 | title: aixplain.utils.config 4 | --- 5 | 6 | Copyright 2022 The aiXplain SDK authors. 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | #### validate\_api\_keys 21 | 22 | ```python 23 | def validate_api_keys() 24 | ``` 25 | 26 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/utils/config.py#L31) 27 | 28 | Centralized API key validation function - single source of truth. 29 | 30 | This function handles all API key validation logic: 31 | 1. Ensures at least one API key is provided 32 | 2. Prevents conflicting API keys 33 | 3. Auto-normalizes AIXPLAIN_API_KEY to TEAM_API_KEY if needed 34 | 35 | **Raises**: 36 | 37 | - `Exception` - If no API keys are provided or if conflicting keys are detected 38 | 39 | #### check\_api\_keys\_available 40 | 41 | ```python 42 | def check_api_keys_available() 43 | ``` 44 | 45 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/utils/config.py#L58) 46 | 47 | Runtime check to ensure API keys are available. 48 | 49 | This is used by decorators and other runtime validation. 50 | Uses the same validation logic as the module-level check. 51 | 52 | **Raises**: 53 | 54 | - `Exception` - If no valid API keys are available 55 | 56 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/utils/convert_datatype_utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: convert_datatype_utils 3 | title: aixplain.utils.convert_datatype_utils 4 | --- 5 | 6 | Copyright 2022 The aiXplain SDK authors 7 | 8 | Licensed under the Apache License, Version 2.0 (the "License"); 9 | you may not use this file except in compliance with the License. 10 | You may obtain a copy of the License at 11 | 12 | http://www.apache.org/licenses/LICENSE-2.0 13 | 14 | Unless required by applicable law or agreed to in writing, software 15 | distributed under the License is distributed on an "AS IS" BASIS, 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | See the License for the specific language governing permissions and 18 | limitations under the License. 19 | 20 | #### dict\_to\_metadata 21 | 22 | ```python 23 | def dict_to_metadata(metadatas: List[Union[Dict, MetaData]]) -> None 24 | ``` 25 | 26 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/utils/convert_datatype_utils.py#L22) 27 | 28 | Convert all the Dicts to MetaData 29 | 30 | **Arguments**: 31 | 32 | - `metadatas` _List[Union[Dict, MetaData]], optional_ - metadata of metadata information of the dataset. 33 | 34 | 35 | **Returns**: 36 | 37 | None 38 | 39 | 40 | **Raises**: 41 | 42 | - `TypeError` - If one or more elements in the metadata_schema are not well-structured 43 | 44 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/utils/evolve_utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: evolve_utils 3 | title: aixplain.utils.evolve_utils 4 | --- 5 | 6 | #### create\_llm\_dict 7 | 8 | ```python 9 | def create_llm_dict( 10 | llm: Optional[Union[Text, LLM]]) -> Optional[Dict[str, Any]] 11 | ``` 12 | 13 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/utils/evolve_utils.py#L5) 14 | 15 | Create a dictionary representation of an LLM for evolution parameters. 16 | 17 | **Arguments**: 18 | 19 | - `llm` - Either an LLM ID string or an LLM object instance. 20 | 21 | 22 | **Returns**: 23 | 24 | Dictionary with LLM information if llm is provided, None otherwise. 25 | 26 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/utils/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: utils 3 | title: aixplain.utils 4 | --- 5 | 6 | aiXplain SDK Library. 7 | --- 8 | 9 | aiXplain SDK enables python programmers to add AI functions 10 | to their software. 11 | 12 | Copyright 2022 The aiXplain SDK authors 13 | 14 | Licensed under the Apache License, Version 2.0 (the "License"); 15 | you may not use this file except in compliance with the License. 16 | You may obtain a copy of the License at 17 | 18 | http://www.apache.org/licenses/LICENSE-2.0 19 | 20 | Unless required by applicable law or agreed to in writing, software 21 | distributed under the License is distributed on an "AS IS" BASIS, 22 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | See the License for the specific language governing permissions and 24 | limitations under the License. 25 | 26 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/utils/llm_utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: llm_utils 3 | title: aixplain.utils.llm_utils 4 | --- 5 | 6 | #### get\_llm\_instance 7 | 8 | ```python 9 | def get_llm_instance(llm_id: Text, 10 | api_key: Optional[Text] = None, 11 | use_cache: bool = True) -> LLM 12 | ``` 13 | 14 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/utils/llm_utils.py#L6) 15 | 16 | Get an LLM instance with specific configuration. 17 | 18 | **Arguments**: 19 | 20 | - `llm_id` _Text_ - ID of the LLM model to use. 21 | - `api_key` _Optional[Text], optional_ - API key to use. Defaults to None. 22 | - `use_cache` _bool, optional_ - Whether to use caching for model retrieval. Defaults to True. 23 | 24 | 25 | **Returns**: 26 | 27 | - `LLM` - Configured LLM instance. 28 | 29 | 30 | **Raises**: 31 | 32 | - `Exception` - If the LLM model with the given ID is not found. 33 | 34 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/utils/request_utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: request_utils 3 | title: aixplain.utils.request_utils 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/api_key.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: api_key 3 | title: aixplain.v2.api_key 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/benchmark.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: benchmark 3 | title: aixplain.v2.benchmark 4 | --- 5 | 6 | ### BenchmarkCreateParams Objects 7 | 8 | ```python 9 | class BenchmarkCreateParams(BareCreateParams) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/benchmark.py#L18) 13 | 14 | Parameters for creating a benchmark. 15 | 16 | **Attributes**: 17 | 18 | - `name` - str: The name of the benchmark. 19 | - `dataset_list` - List["Dataset"]: The list of datasets. 20 | - `model_list` - List["Model"]: The list of models. 21 | - `metric_list` - List["Metric"]: The list of metrics. 22 | 23 | ### Benchmark Objects 24 | 25 | ```python 26 | class Benchmark(BaseResource, GetResourceMixin[BareGetParams, "Benchmark"], 27 | CreateResourceMixin[BenchmarkCreateParams, "Benchmark"]) 28 | ``` 29 | 30 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/benchmark.py#L34) 31 | 32 | Resource for benchmarks. 33 | 34 | #### list\_normalization\_options 35 | 36 | ```python 37 | @classmethod 38 | def list_normalization_options(cls, metric: "Metric", 39 | model: "Model") -> List[str] 40 | ``` 41 | 42 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/benchmark.py#L56) 43 | 44 | List the normalization options for a metric and a model. 45 | 46 | **Arguments**: 47 | 48 | - `metric` - "Metric": The metric. 49 | - `model` - "Model": The model. 50 | 51 | 52 | **Returns**: 53 | 54 | - `List[str]` - The list of normalization options. 55 | 56 | ### BenchmarkJob Objects 57 | 58 | ```python 59 | class BenchmarkJob(BaseResource, GetResourceMixin[BareGetParams, 60 | "BenchmarkJob"]) 61 | ``` 62 | 63 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/benchmark.py#L72) 64 | 65 | Resource for benchmark jobs. 66 | 67 | #### get\_scores 68 | 69 | ```python 70 | def get_scores() -> dict 71 | ``` 72 | 73 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/benchmark.py#L86) 74 | 75 | Get the scores for a benchmark job. 76 | 77 | **Returns**: 78 | 79 | - `dict` - The scores. 80 | 81 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/corpus.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: corpus 3 | title: aixplain.v2.corpus 4 | --- 5 | 6 | ### CorpusListParams Objects 7 | 8 | ```python 9 | class CorpusListParams(BaseListParams) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/corpus.py#L34) 13 | 14 | Parameters for listing corpora. 15 | 16 | **Attributes**: 17 | 18 | - `query` - Optional[Text]: A search query. 19 | - `function` - Optional[Function]: The function of the model. 20 | - `suppliers` - Union[Supplier, List[Supplier]: The suppliers of the model. 21 | - `source_languages` - Union[Language, List[Language]: The source languages of the model. 22 | - `target_languages` - Union[Language, List[Language]: The target languages of the model. 23 | - `is_finetunable` - bool: Whether the model is finetunable. 24 | 25 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/data.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: data 3 | title: aixplain.v2.data 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/dataset.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: dataset 3 | title: aixplain.v2.dataset 4 | --- 5 | 6 | ### DatasetListParams Objects 7 | 8 | ```python 9 | class DatasetListParams(BaseListParams) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/dataset.py#L48) 13 | 14 | Parameters for listing corpora. 15 | 16 | **Attributes**: 17 | 18 | - `query` - Optional[Text]: A search query. 19 | - `function` - Optional[Function]: The function of the model. 20 | - `suppliers` - Union[Supplier, List[Supplier]: The suppliers of the model. 21 | - `source_languages` - Union[Language, List[Language]: The source languages of the model. 22 | - `target_languages` - Union[Language, List[Language]: The target languages of the model. 23 | - `is_finetunable` - bool: Whether the model is finetunable. 24 | 25 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/enums.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: enums 3 | title: aixplain.v2.enums 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/enums_include.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: enums_include 3 | title: aixplain.v2.enums_include 4 | --- 5 | 6 | ### ErrorHandler Objects 7 | 8 | ```python 9 | class ErrorHandler(str, Enum) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/enums_include.py#L54) 13 | 14 | Enumeration class defining different error handler strategies. 15 | 16 | **Attributes**: 17 | 18 | - `SKIP` _str_ - skip failed rows. 19 | - `FAIL` _str_ - raise an exception. 20 | 21 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/file.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: file 3 | title: aixplain.v2.file 4 | --- 5 | 6 | ### FileCreateParams Objects 7 | 8 | ```python 9 | class FileCreateParams(BaseCreateParams) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/file.py#L10) 13 | 14 | Parameters for creating a file. 15 | 16 | ### File Objects 17 | 18 | ```python 19 | class File(BaseResource, CreateResourceMixin[FileCreateParams, "File"]) 20 | ``` 21 | 22 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/file.py#L19) 23 | 24 | Resource for files. 25 | 26 | #### create 27 | 28 | ```python 29 | @classmethod 30 | def create(cls, *args, **kwargs: Unpack[FileCreateParams]) -> "File" 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/file.py#L25) 34 | 35 | Create a file. 36 | 37 | #### to\_link 38 | 39 | ```python 40 | @classmethod 41 | def to_link(cls, local_path: str) -> str 42 | ``` 43 | 44 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/file.py#L36) 45 | 46 | Convert a local path to a link. 47 | 48 | **Arguments**: 49 | 50 | - `local_path` - str: The local path to the file. 51 | 52 | 53 | **Returns**: 54 | 55 | - `str` - The link to the file. 56 | 57 | #### upload 58 | 59 | ```python 60 | @classmethod 61 | def upload(cls, 62 | local_path: str, 63 | tags: List[str] = None, 64 | license: "License" = None, 65 | is_temp: bool = True) -> str 66 | ``` 67 | 68 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/file.py#L50) 69 | 70 | Upload a file. 71 | 72 | **Arguments**: 73 | 74 | - `local_path` - str: The local path to the file. 75 | 76 | 77 | **Returns**: 78 | 79 | - `str` - The upload URL. 80 | 81 | #### check\_storage\_type 82 | 83 | ```python 84 | @classmethod 85 | def check_storage_type(cls, upload_url: str) -> "StorageType" 86 | ``` 87 | 88 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/file.py#L70) 89 | 90 | Check the storage type of a file. 91 | 92 | **Arguments**: 93 | 94 | - `upload_url` - str: The upload URL. 95 | 96 | 97 | **Returns**: 98 | 99 | - `StorageType` - The storage type of the file. 100 | 101 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/finetune.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: finetune 3 | title: aixplain.v2.finetune 4 | --- 5 | 6 | ### FinetuneCreateParams Objects 7 | 8 | ```python 9 | class FinetuneCreateParams(BareCreateParams) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/finetune.py#L16) 13 | 14 | Parameters for creating a finetune. 15 | 16 | **Attributes**: 17 | 18 | - `name` - str: The name of the finetune. 19 | - `dataset_list` - List[Dataset]: The list of datasets. 20 | - `model` - Union[Model, str]: The model. 21 | - `prompt_template` - str: The prompt template. 22 | - `hyperparameters` - Hyperparameters: The hyperparameters. 23 | - `train_percentage` - float: The train percentage. 24 | - `dev_percentage` - float: The dev percentage. 25 | 26 | ### Finetune Objects 27 | 28 | ```python 29 | class Finetune(BaseResource, CreateResourceMixin[FinetuneCreateParams, 30 | "Finetune"]) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/finetune.py#L38) 34 | 35 | Resource for finetunes. 36 | 37 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: v2 4 | title: aixplain.v2 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/metric.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: metric 3 | title: aixplain.v2.metric 4 | --- 5 | 6 | ### MetricListParams Objects 7 | 8 | ```python 9 | class MetricListParams(BaseListParams) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/metric.py#L13) 13 | 14 | Parameters for listing metrics. 15 | 16 | **Attributes**: 17 | 18 | - `model_id` - str: The model ID. 19 | - `is_source_required` - bool: Whether the source is required. 20 | - `is_reference_required` - bool: Whether the reference is required. 21 | 22 | ### Metric Objects 23 | 24 | ```python 25 | class Metric(BaseResource, ListResourceMixin[MetricListParams, "Metric"], 26 | GetResourceMixin[BareGetParams, "Metric"]) 27 | ``` 28 | 29 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/metric.py#L27) 30 | 31 | Resource for metrics. 32 | 33 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/model.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: model 3 | title: aixplain.v2.model 4 | --- 5 | 6 | ### ModelListParams Objects 7 | 8 | ```python 9 | class ModelListParams(BaseListParams) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/model.py#L18) 13 | 14 | Parameters for listing models. 15 | 16 | **Attributes**: 17 | 18 | - `function` - Function: The function of the model. 19 | - `suppliers` - Union[Supplier, List[Supplier]: The suppliers of the model. 20 | - `source_languages` - Union[Language, List[Language]: The source languages of the model. 21 | - `target_languages` - Union[Language, List[Language]: The target languages of the model. 22 | - `is_finetunable` - bool: Whether the model is finetunable. 23 | 24 | ### Model Objects 25 | 26 | ```python 27 | class Model(BaseResource, ListResourceMixin[ModelListParams, "Model"], 28 | GetResourceMixin[BareGetParams, "Model"]) 29 | ``` 30 | 31 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/model.py#L36) 32 | 33 | Resource for models. 34 | 35 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/pipeline.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: pipeline 3 | title: aixplain.v2.pipeline 4 | --- 5 | 6 | ### PipelineListParams Objects 7 | 8 | ```python 9 | class PipelineListParams(BareListParams) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/pipeline.py#L18) 13 | 14 | Parameters for listing pipelines. 15 | 16 | **Attributes**: 17 | 18 | - `functions` - Union[Function, List[Function]]: The functions of the pipeline. 19 | - `suppliers` - Union[Supplier, List[Supplier]]: The suppliers of the pipeline. 20 | - `models` - Union[Model, List[Model]]: The models of the pipeline. 21 | - `input_data_types` - Union[DataType, List[DataType]]: The input data types of the pipeline. 22 | - `output_data_types` - Union[DataType, List[DataType]]: The output data types of the pipeline. 23 | - `drafts_only` - bool: Whether to list only drafts. 24 | 25 | ### Pipeline Objects 26 | 27 | ```python 28 | class Pipeline(BaseResource, ListResourceMixin[PipelineListParams, "Pipeline"], 29 | GetResourceMixin[BareGetParams, "Pipeline"], 30 | CreateResourceMixin[PipelineCreateParams, "Pipeline"]) 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/pipeline.py#L44) 34 | 35 | Resource for pipelines. 36 | 37 | **Attributes**: 38 | 39 | - `RESOURCE_PATH` - str: The resource path. 40 | 41 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/script.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: script 3 | title: aixplain.v2.script 4 | --- 5 | 6 | ### Script Objects 7 | 8 | ```python 9 | class Script(BaseResource) 10 | ``` 11 | 12 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/script.py#L4) 13 | 14 | #### upload 15 | 16 | ```python 17 | @classmethod 18 | def upload(cls, script_path: str) -> "Script" 19 | ``` 20 | 21 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/script.py#L6) 22 | 23 | Upload a script to the server. 24 | 25 | **Arguments**: 26 | 27 | - `script_path` - str: The path to the script. 28 | 29 | 30 | **Returns**: 31 | 32 | - `Script` - The script. 33 | 34 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/team_agent.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: team_agent 3 | title: aixplain.v2.team_agent 4 | --- 5 | 6 | ### TeamAgent Objects 7 | 8 | ```python 9 | class TeamAgent(BaseResource, ListResourceMixin[BareListParams, "TeamAgent"], 10 | GetResourceMixin[BareGetParams, "TeamAgent"]) 11 | ``` 12 | 13 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/v2/team_agent.py#L41) 14 | 15 | Resource for agents. 16 | 17 | **Attributes**: 18 | 19 | - `RESOURCE_PATH` - str: The resource path. 20 | - `PAGINATE_PATH` - None: The path for pagination. 21 | - `PAGINATE_METHOD` - str: The method for pagination. 22 | - `PAGINATE_ITEMS_KEY` - None: The key for the response. 23 | 24 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/v2/wallet.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: wallet 3 | title: aixplain.v2.wallet 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /docs/assets/aixplain-brandmark-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/edaac86e2c1cf9c823aaf53e08448162f92a4e3a/docs/assets/aixplain-brandmark-line.png -------------------------------------------------------------------------------- /docs/assets/aixplain-workflow-teamagent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/edaac86e2c1cf9c823aaf53e08448162f92a4e3a/docs/assets/aixplain-workflow-teamagent.png -------------------------------------------------------------------------------- /pydoc-markdown.yml: -------------------------------------------------------------------------------- 1 | # pydoc-markdown.yml – works with 4.8.2 2 | loaders: 3 | - type: python 4 | search_path: ["./"] 5 | packages: ["aixplain"] 6 | 7 | renderer: 8 | type: docusaurus 9 | docs_base_path: docs 10 | relative_output_path: api-reference/python 11 | relative_sidebar_path: api_sidebar.js 12 | sidebar_top_level_label: "Python API reference" 13 | markdown: 14 | source_linker: 15 | type: github 16 | repo: aixplain/aiXplain 17 | use_branch: true 18 | header_level_by_type: 19 | Module: 2 20 | Class: 3 21 | Function: 4 22 | Method: 4 23 | 24 | hooks: 25 | post-render: 26 | - python3 post_process_docs.py 27 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | # aixplain/pyproject.toml 2 | [build-system] 3 | requires = ["setuptools", "setuptools-scm"] 4 | build-backend = "setuptools.build_meta" 5 | 6 | [tool.setuptools.packages.find] 7 | where = ["."] 8 | include = ["aixplain", "tests"] 9 | namespaces = true 10 | 11 | [project] 12 | name = "aiXplain" 13 | version = "0.2.36" 14 | description = "aiXplain SDK adds AI functions to software." 15 | readme = "README.md" 16 | requires-python = ">=3.9, <4" 17 | license = { text = "Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0" } 18 | authors = [ 19 | {email = "ahmet@aixplain.com"}, 20 | {email = "hadi@aixplain.com"}, 21 | {email = "kadir.pekel@aixplain.com"}, 22 | {email = "aina.abushaban@aixplain.com"} 23 | ] 24 | classifiers = [ 25 | "Development Status :: 2 - Pre-Alpha", 26 | "Environment :: Web Environment", 27 | "Intended Audience :: Developers", 28 | "License :: OSI Approved :: Apache Software License", 29 | "Natural Language :: English", 30 | "Operating System :: OS Independent", 31 | "Programming Language :: Python", 32 | "Programming Language :: Python :: 3", 33 | "Programming Language :: Python :: 3.9", 34 | "Programming Language :: Python :: 3.10", 35 | "Programming Language :: Python :: 3.11", 36 | "Programming Language :: Python :: 3.12", 37 | "Programming Language :: Python :: 3.13", 38 | "Programming Language :: Python :: 3 :: Only", 39 | "Programming Language :: Python :: Implementation :: CPython", 40 | "Programming Language :: Python :: Implementation :: PyPy", 41 | "Topic :: Internet :: WWW/HTTP", 42 | "Topic :: Software Development :: Libraries", 43 | ] 44 | dependencies = [ 45 | "requests>=2.1.0", 46 | "tqdm>=4.1.0", 47 | "pandas>=2.0.0", 48 | "python-dotenv>=1.0.0", 49 | "validators>=0.20.0", 50 | "filetype>=1.2.0", 51 | "click>=7.1.2", 52 | "PyYAML>=6.0.1", 53 | "dataclasses-json>=0.5.2", 54 | "Jinja2==3.1.6", 55 | "sentry-sdk>=1.0.0", 56 | "pydantic>=2.10.6", 57 | "filelock>=3.0.0" 58 | ] 59 | 60 | [project.urls] 61 | Homepage = "https://github.com/aixplain/aiXplain" 62 | Documentation = "https://github.com/aixplain/pipelines/tree/main/docs" 63 | 64 | [project.scripts] 65 | aixplain = "aixplain.cli_groups:run_cli" 66 | 67 | [project.optional-dependencies] 68 | model-builder = [ 69 | "model-interfaces~=0.0.2" 70 | ] 71 | test = [ 72 | "pytest>=6.1.0", 73 | "docker>=6.1.3", 74 | "requests-mock>=1.11.0", 75 | "pytest-mock>=3.10.0" 76 | ] 77 | 78 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | testpaths = 3 | tests -------------------------------------------------------------------------------- /ruff.toml: -------------------------------------------------------------------------------- 1 | line-length = 120 2 | indent-width = 4 3 | exclude = [] 4 | 5 | [format] 6 | # Like Black, use double quotes for strings. 7 | quote-style = "double" 8 | 9 | # Like Black, indent with spaces, rather than tabs. 10 | indent-style = "space" 11 | 12 | # Like Black, respect magic trailing commas. 13 | skip-magic-trailing-comma = false 14 | 15 | # Like Black, automatically detect the appropriate line ending. 16 | line-ending = "auto" 17 | 18 | [lint] 19 | select = ["D"] 20 | ignore = [] 21 | extend-safe-fixes = [] 22 | 23 | [lint.isort] 24 | known-first-party = ["src"] 25 | 26 | [lint.pydocstyle] 27 | convention = "google" 28 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description_file=README.md 3 | license_files=LICENSE.rst 4 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | aiXplain SDK Library. 3 | --- 4 | 5 | aiXplain SDK enables python programmers to add AI functions 6 | to their software. 7 | 8 | Copyright 2022 The aiXplain SDK authors 9 | 10 | Licensed under the Apache License, Version 2.0 (the "License"); 11 | you may not use this file except in compliance with the License. 12 | You may obtain a copy of the License at 13 | 14 | http://www.apache.org/licenses/LICENSE-2.0 15 | 16 | Unless required by applicable law or agreed to in writing, software 17 | distributed under the License is distributed on an "AS IS" BASIS, 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | See the License for the specific language governing permissions and 20 | limitations under the License. 21 | """ 22 | -------------------------------------------------------------------------------- /tests/functional/agent/data/agent_test_end2end.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "agent_name": "TEST Translation agent", 4 | "llm_id": "67fd9ddfef0365783d06e2ef", 5 | "llm_name": "GPT-4.1 Mini", 6 | "query": "Who is the president of Brazil right now? Translate to pt", 7 | "model_tools": [ 8 | { 9 | "function": "translation", 10 | "supplier": "AWS" 11 | }, 12 | { 13 | "model": "60ddefca8d38c51c58860108", 14 | "function": null, 15 | "supplier": null 16 | } 17 | ] 18 | } 19 | ] 20 | -------------------------------------------------------------------------------- /tests/functional/apikey/README.md: -------------------------------------------------------------------------------- 1 | # API Key Tests 2 | 3 | This directory contains tests for the API Key functionality in the aiXplain SDK. 4 | 5 | ## Prerequisites 6 | 7 | To run these tests, you need: 8 | 9 | 1. An admin API key with permissions to: 10 | - Create new API keys 11 | - Update existing API keys 12 | - Delete API keys 13 | - List API keys 14 | - View API key usage 15 | 16 | 2. Available API key slots: 17 | - The tests create and delete API keys during execution 18 | - Make sure you have at least one available slot for API key creation 19 | - The tests will fail if you've reached the maximum number of allowed API keys 20 | 21 | -------------------------------------------------------------------------------- /tests/functional/apikey/apikey.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Test API Key", 3 | "asset_limits": [ 4 | { 5 | "model": "640b517694bf816d35a59125", 6 | "token_per_minute": 100, 7 | "token_per_day": 1000, 8 | "request_per_day": 1000, 9 | "request_per_minute": 100 10 | } 11 | ], 12 | "global_limits": { 13 | "token_per_minute": 100, 14 | "token_per_day": 1000, 15 | "request_per_day": 1000, 16 | "request_per_minute": 100 17 | }, 18 | "budget": 1000, 19 | "expires_at": "2024-12-12T00:00:00Z" 20 | } 21 | -------------------------------------------------------------------------------- /tests/functional/benchmark/data/benchmark_module_test_data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "benchmark_id" : "64da356e13d879bec2323aa8" 4 | } 5 | ] -------------------------------------------------------------------------------- /tests/functional/benchmark/data/benchmark_test_run_data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "model_ids": ["61b097551efecf30109d32da", "60ddefbe8d38c51c5885f98a"], 4 | "dataset_ids": ["64da34a813d879bec2323aa3"], 5 | "dataset_names": ["EnHi SDK Test - Benchmark Dataset"], 6 | "metric_ids": ["639874ab506c987b1ae1acc6", "6408942f166427039206d71e"] 7 | } 8 | ] 9 | -------------------------------------------------------------------------------- /tests/functional/benchmark/data/benchmark_test_with_parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "Translation With LLMs": { 3 | "models_with_parameters": [ 4 | { 5 | "model_id": "669a63646eb56306647e1091", 6 | "display_name": "EnHi LLM", 7 | "configuration": { 8 | "prompt": "Translate the following text into Hindi." 9 | } 10 | }, 11 | { 12 | "model_id": "669a63646eb56306647e1091", 13 | "display_name": "EnEs LLM", 14 | "configuration": { 15 | "prompt": "Translate the following text into Spanish." 16 | } 17 | } 18 | ], 19 | "dataset_names": ["EnHi SDK Test - Benchmark Dataset"], 20 | "metric_ids": ["639874ab506c987b1ae1acc6", "6408942f166427039206d71e"] 21 | } 22 | } -------------------------------------------------------------------------------- /tests/functional/data_asset/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/edaac86e2c1cf9c823aaf53e08448162f92a4e3a/tests/functional/data_asset/__init__.py -------------------------------------------------------------------------------- /tests/functional/data_asset/input/audio-en_with_invalid_split_url.csv: -------------------------------------------------------------------------------- 1 | ,audio,text,audio_start_time,audio_end_time,split,split-2 2 | 0,https://aixplain-platform-assets.s3.amazonaws.com/samples/en/discovery_demo.wav,Welcome to another episode of Explain using discover to find and benchmark AI models.,0.9,6.56,TRAIN,TRAIN -------------------------------------------------------------------------------- /tests/functional/file_asset/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/edaac86e2c1cf9c823aaf53e08448162f92a4e3a/tests/functional/file_asset/__init__.py -------------------------------------------------------------------------------- /tests/functional/file_asset/file_create_test.py: -------------------------------------------------------------------------------- 1 | __author__ = "mohammedalyafeai" 2 | 3 | """ 4 | Copyright 2022 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | """ 18 | 19 | import pytest 20 | from aixplain.enums import License 21 | from aixplain.factories import FileFactory 22 | from aixplain import aixplain_v2 as v2 23 | 24 | 25 | @pytest.mark.parametrize( 26 | "FileFactory, is_temp, expected_link", 27 | [ 28 | (FileFactory, True, "http"), 29 | (v2.File, True, "http"), 30 | (FileFactory, False, "s3"), 31 | (v2.File, False, "s3"), 32 | ], 33 | ) 34 | def test_file_create(FileFactory, is_temp, expected_link): 35 | upload_file = "tests/functional/file_asset/input/test.csv" 36 | s3_link = FileFactory.create(local_path=upload_file, tags=["test1", "test2"], license=License.MIT, is_temp=is_temp) 37 | assert s3_link.startswith(expected_link) 38 | -------------------------------------------------------------------------------- /tests/functional/file_asset/input/test.csv: -------------------------------------------------------------------------------- 1 | A,B 2 | 1,2 3 | 3,4 -------------------------------------------------------------------------------- /tests/functional/finetune/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/edaac86e2c1cf9c823aaf53e08448162f92a4e3a/tests/functional/finetune/__init__.py -------------------------------------------------------------------------------- /tests/functional/finetune/data/finetune_test_cost_estimation.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"model_name": "Llama 2 7b", "model_id": "6543cb991f695e72028e9428", "dataset_name": "Test text generation dataset"}, 3 | {"model_name": "Llama 2 7B Chat", "model_id": "65519ee7bf42e6037ab109d8", "dataset_name": "Test text generation dataset"}, 4 | {"model_name": "Mistral 7b", "model_id": "6551a9e7bf42e6037ab109de", "dataset_name": "Test text generation dataset"}, 5 | {"model_name": "Mistral 7B Instruct v0.3", "model_id": "6551a9e7bf42e6037ab109de", "dataset_name": "Test text generation dataset"}, 6 | {"model_name": "Falcon 7b", "model_id": "6551bff9bf42e6037ab109e1", "dataset_name": "Test text generation dataset"}, 7 | {"model_name": "Falcon 7b Instruct", "model_id": "65519d57bf42e6037ab109d5", "dataset_name": "Test text generation dataset"}, 8 | {"model_name": "MPT 7b", "model_id": "6551a72bbf42e6037ab109d9", "dataset_name": "Test text generation dataset"}, 9 | {"model_name": "MPT 7b storywriter", "model_id": "6551a870bf42e6037ab109db", "dataset_name": "Test text generation dataset"}, 10 | {"model_name": "BloomZ 7b", "model_id": "6551ab17bf42e6037ab109e0", "dataset_name": "Test text generation dataset"}, 11 | {"model_name": "BloomZ 7b MT", "model_id": "656e80147ca71e334752d5a3", "dataset_name": "Test text generation dataset"} 12 | ] 13 | -------------------------------------------------------------------------------- /tests/functional/finetune/data/finetune_test_end2end.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "model_name": "llama2 7b", 4 | "model_id": "6543cb991f695e72028e9428", 5 | "dataset_name": "Test text generation dataset", 6 | "inference_data": "Hello!", 7 | "required_dev": true, 8 | "search_metadata": false 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /tests/functional/finetune/data/finetune_test_list_data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "function": "text-generation" 4 | } 5 | ] -------------------------------------------------------------------------------- /tests/functional/finetune/data/finetune_test_prompt_validator.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "model_name": "llama2 7b", 4 | "model_id": "6543cb991f695e72028e9428", 5 | "dataset_name": "Test text generation dataset", 6 | "prompt_template": "Source: <>\nReference: <>", 7 | "is_valid": true 8 | }, 9 | { 10 | "model_name": "llama2 7b", 11 | "model_id": "6543cb991f695e72028e9428", 12 | "dataset_name": "Test text generation dataset", 13 | "prompt_template": "Source: <>\nReference: <>", 14 | "is_valid": false 15 | } 16 | ] -------------------------------------------------------------------------------- /tests/functional/general_assets/data/asset_run_test_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "model" : { 3 | "id" : "61b097551efecf30109d32da", 4 | "data": "This is a test sentence." 5 | }, 6 | "model2" : { 7 | "id" : "60ddefab8d38c51c5885ee38", 8 | "data": "https://aixplain-platform-assets.s3.amazonaws.com/samples/en/myname.mp3" 9 | }, 10 | "model3" : { 11 | "id" : "6736411cf127849667606689", 12 | "data": "How to cook a shrimp risotto?" 13 | }, 14 | "pipeline": { 15 | "name": "SingleNodePipeline", 16 | "data": "This is a test sentence." 17 | }, 18 | "metric": { 19 | "id" : "639874ab506c987b1ae1acc6", 20 | "data": { 21 | "hypothesis": "hello world", 22 | "reference": "hello world" 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /tests/functional/model/data/test_file_parser_input.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/edaac86e2c1cf9c823aaf53e08448162f92a4e3a/tests/functional/model/data/test_file_parser_input.pdf -------------------------------------------------------------------------------- /tests/functional/model/data/test_input.txt: -------------------------------------------------------------------------------- 1 | Hello! Here is a robot emoji: 🤖 Response should contain this emoji. -------------------------------------------------------------------------------- /tests/functional/pipelines/data/script.py: -------------------------------------------------------------------------------- 1 | def main(speakers): 2 | # build the response 3 | response = [] 4 | for i, speaker in enumerate(speakers): 5 | print(f"Processing speaker at index={i}") 6 | data = speaker["data"] 7 | data_modified = f"SCRIPT MODIFIED: {data}" 8 | response.append( 9 | { 10 | "index": i, 11 | "success": True, 12 | "input_type": "text", 13 | "is_url": False, 14 | "details": {}, 15 | "data": data_modified, 16 | "input": data_modified, 17 | } 18 | ) 19 | return response 20 | -------------------------------------------------------------------------------- /tests/functional/team_agent/data/team_agent_test_end2end.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "team_agent_name": "TEST Multi agent", 4 | "llm_id": "67fd9ddfef0365783d06e2ef", 5 | "llm_name": "GPT-4.1 Mini", 6 | "query": "Who is the president of Brazil right now? Translate to pt and synthesize in audio", 7 | "agents": [ 8 | { 9 | "agent_name": "TEST Translation agent", 10 | "llm_id": "67fd9ddfef0365783d06e2ef", 11 | "llm_name": "GPT-4.1 Mini", 12 | "model_tools": [ 13 | { 14 | "function": "translation", 15 | "supplier": "AWS" 16 | } 17 | ] 18 | }, 19 | { 20 | "agent_name": "TEST Speech Synthesis agent", 21 | "llm_id": "67fd9ddfef0365783d06e2ef", 22 | "llm_name": "GPT-4.1 Mini", 23 | "model_tools": [ 24 | { 25 | "function": "speech-synthesis", 26 | "supplier": "Google" 27 | } 28 | ] 29 | } 30 | ] 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /tests/mock_responses/create_asset_repo_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "modelId": "mockId" 3 | } -------------------------------------------------------------------------------- /tests/mock_responses/list_host_machines_response.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "64dce914adc92335dc35beb5", 4 | "code": "aix-2c-8g-od", 5 | "type": "on-demand", 6 | "cores": 2, 7 | "memory": 8, 8 | "hourlyCost": 0.12 9 | }, 10 | { 11 | "id": "64dceafdadc92335dc35beb6", 12 | "code": "aix-2c-8g", 13 | "type": "always-on", 14 | "cores": 2, 15 | "memory": 8, 16 | "hourlyCost": 0.096 17 | } 18 | ] -------------------------------------------------------------------------------- /tests/mock_responses/list_image_repo_tags_response.json: -------------------------------------------------------------------------------- 1 | ["tag1", "tag2", "tag3", "tag4"] -------------------------------------------------------------------------------- /tests/mock_responses/login_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "username": "AWS", 3 | "password": "eyJwYXlsb2FkIjoiNlNkQmp0WkRWbDRtQmxYMk5ZWHh0dFJQRTJFeWpScDFVczI1RTl2WUJMRmN5SVU1TE1wd3hiK2FaZWtnbjZidy9Ea3UxQ1FpcnIwRURwNXZNMTJuZXBJVzhITjNkVEtmeFNCa1RwcTNESSt2ZnVtSm5MVXM3KzlPNEo3cmRySDE5NjdnazYyb0NIRVV1WmZvOUFuUm5CeHUyU2ZmZWFndFlYVyt0dDVXeWtMQjRCRlNFaGJUelNtSnllSW9pNTlkNFNYdGtXY3pDT1RZQ281MUVlVEI0L1c4NGZMVVZQRVF6VThmdmtYRVl1TDNEUWFzc3F3dUxxcHp2bWtrSCtNOHNrdFp6bHZubXlxMnFGYkR0aElhamNXNW1Ud1BkVjJMN2w0ZFJVSTlTQ3Y1SlExbnlZZ01obUxHeDRDRG5KYmh0NndzeEtWcVpxbmMzMDR6WXZnQlZTcWFEY2VvWXV0SFEwSTVSQU1DaUtNd09SZHF0Skt1Y3FxRVBwTkxPaDhlcUFScmd4bkVCYnhQZm4zZ0M5L0x2bHBiZ1I5UFRIWGlqZlFWczNnUW5vTzFmd0R2d1dudTRsMjJDWjdSUTN4WlRNL29NdFNtZ2RScmplclpqNWo0RVMycTdQTEFXOU9UcUtieDRpZklMRUVucTIxbDBXaFNtc0xlR2g4Rm9GZkpOSGJ5L2wzUklTY2hjUzBYUUdYMXJ0cFhFOTc3bUVtdzY0WDdYT3h5UGlnZytzNWowMjhFY0VqSzV6R01sNzdDYUprcVVyZjVUUWZraTU4VURCMTNXWDlvVDVGQVUvcU9DY3F0SlQ5TlBZTnFXQ0xhamdFdk93TXFsQndkVzhKTEhwMTkwZ3psNE1nN0YwRDIvTFpScWRDVVh2SXRBSFJJUmROa1U3RDI1Y3VoL0xjSjlhZUQ2MnJiVDA1R2FIWkV5Z0d5MmxnRWlmekUvbWhPSGNUclBOSnlPTGhHaFc2L0F5dCt1MDRxNEdqMzVFQk1GSHZ0a0lLUEQ5MU04NTVKZnVMV3F3d09QR1NlZnNGRXlRNExxRGZtMkNueVpqd3NuNWRFSlR5VUZhTUMyODMwbCtBV3lZMFBQQ3l6eTFJK0FoMHV0VkJvMlBabkFPZVk1c3hOL05uOFhlbmRMbTA0Mm1wTENWOCtHd3lzYnVFM1BHRDdNV3pDaVVicm0rbXdBLzk0c3hTODlTNkJpVWhnUHp5RC84TWhyVUNNL1FTRGNFY3ZUTjVFc0N0UDM1cUdUT28yOWdxc3VzdWRLZHdEQkhWMlpkaGNNR0xQMElWNEZKN01CQVZSMnd4OTRiZXpDMm4xU3V5TGRGVVBQYVFKa2wwWmw2M3E4MU5FRjdMSzQ0M0FJbzlpV3FuazltbFBYRVo1OHdVUERnMUpZbWw4b3BCYVprazJtM2dvYk5HdEFWUHY1dDlXZitXY2Q2MDN3WnJ1TlhwUTNPSlk2WWI4ZXBMNlZpN1ErTkpaa2Z0NWl5M1FQRFpUUFZjSCs0c1VjZ0E2dmFMSUY2aEZCUncwWitRS0pvK0VZUWtFK0RTQXhMaldFYkt5ZzBSN1V3UHg0VThENjQ4My9mMlV2cU5jSFRORHNkbXRKcjlXcUwxNHRoc1BqQTNqZ3Bqc0pydDJJWTA1bEdNOWJJbGpmbUtGWFdsemppQ2ptSUNsSm14SUxIdzgvSTlKb3JYb2NmNXpoSHVzbCswUkdKc1NMTHAyOWc9PSIsImRhdGFrZXkiOiJBUUVCQUhod20wWWFJU0plUnRKbTVuMUc2dXFlZWtYdW9YWFBlNVVGY2U5UnE4LzE0d0FBQUg0d2ZBWUpLb1pJaHZjTkFRY0dvRzh3YlFJQkFEQm9CZ2txaGtpRzl3MEJCd0V3SGdZSllJWklBV1VEQkFFdU1CRUVERGFyODZkalUxNVFHNCtZaEFJQkVJQTdvY0xIeWFpUHViY2VTQ0g5djB6THd2UFZGbHU0WmJqZ09JSGkrdmxiNEpCVTBlNyt5VmpnT3BpcWVmQlkxbFBGWktKalgvMEIwMkJDcU1nPSIsInZlcnNpb24iOiIyIiwidHlwZSI6IkRBVEFfS0VZIiwiZXhwaXJhdGlvbiI6MTY5MjYxNDYwMX0=", 4 | "registry": "https://535945872701.dkr.ecr.us-east-1.amazonaws.com" 5 | } -------------------------------------------------------------------------------- /tests/test_requests/create_asset_request.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mock_name", 3 | "description": "mock_description", 4 | "function": "Text Generation", 5 | "sourceLanguage": "en", 6 | "input_modality": "text", 7 | "output_modality": "text", 8 | "documentation_url": "" 9 | } -------------------------------------------------------------------------------- /tests/test_utils.py: -------------------------------------------------------------------------------- 1 | from aixplain.utils.request_utils import _request_with_retry 2 | from urllib.parse import urljoin 3 | import logging 4 | from aixplain.utils import config 5 | 6 | 7 | def delete_asset(model_id, api_key): 8 | delete_url = urljoin(config.BACKEND_URL, f"sdk/models/{model_id}") 9 | logging.debug(f"URL: {delete_url}") 10 | headers = {"Authorization": f"Token {api_key}", "Content-Type": "application/json"} 11 | _ = _request_with_retry("delete", delete_url, headers=headers) 12 | 13 | 14 | def delete_service_account(api_key): 15 | delete_url = urljoin(config.BACKEND_URL, "sdk/ecr/logout") 16 | logging.debug(f"URL: {delete_url}") 17 | headers = {"Authorization": f"Token {api_key}", "Content-Type": "application/json"} 18 | _ = _request_with_retry("post", delete_url, headers=headers) 19 | -------------------------------------------------------------------------------- /tests/unit/corpus_test.py: -------------------------------------------------------------------------------- 1 | from aixplain.factories import CorpusFactory 2 | import pytest 3 | import requests_mock 4 | from urllib.parse import urljoin 5 | from aixplain.utils import config 6 | 7 | 8 | def test_get_corpus_error_response(): 9 | with requests_mock.Mocker() as mock: 10 | corpus_id = "invalid_corpus_id" 11 | url = urljoin(config.BACKEND_URL, f"sdk/corpora/{corpus_id}/overview") 12 | headers = {"Authorization": f"Token {config.AIXPLAIN_API_KEY}", "Content-Type": "application/json"} 13 | 14 | error_response = {"message": "Not Found"} 15 | mock.get(url, headers=headers, json=error_response, status_code=404) 16 | 17 | with pytest.raises(Exception) as excinfo: 18 | CorpusFactory.get(corpus_id=corpus_id) 19 | 20 | assert "Corpus GET Error: Status 404 - {'message': 'Not Found'}" in str(excinfo.value) 21 | 22 | 23 | def test_list_corpus_error_response(): 24 | with requests_mock.Mocker() as mock: 25 | url = urljoin(config.BACKEND_URL, "sdk/corpora/paginate") 26 | headers = {"Authorization": f"Token {config.AIXPLAIN_API_KEY}", "Content-Type": "application/json"} 27 | 28 | error_response = {"message": "Internal Server Error"} 29 | mock.post(url, headers=headers, json=error_response, status_code=500) 30 | 31 | with pytest.raises(Exception) as excinfo: 32 | CorpusFactory.list(query="test_query", page_number=0, page_size=20) 33 | 34 | assert "Corpus List Error: Status 500 - {'message': 'Internal Server Error'}" in str(excinfo.value) 35 | -------------------------------------------------------------------------------- /tests/unit/data/create_finetune_percentage_exception.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "train_percentage": 0, 4 | "dev_percentage": 100 5 | }, 6 | { 7 | "train_percentage": 0, 8 | "dev_percentage": 0 9 | }, 10 | { 11 | "train_percentage": 80, 12 | "dev_percentage": 30 13 | } 14 | ] -------------------------------------------------------------------------------- /tests/unit/dataset_test.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import requests_mock 3 | from aixplain.factories import DatasetFactory 4 | from urllib.parse import urljoin 5 | from aixplain.utils import config 6 | 7 | 8 | def test_list_dataset_error_response(): 9 | with requests_mock.Mocker() as mock: 10 | url = urljoin(config.BACKEND_URL, "sdk/datasets/paginate") 11 | headers = {"Authorization": f"Token {config.AIXPLAIN_API_KEY}", "Content-Type": "application/json"} 12 | 13 | error_response = {"message": "Internal Server Error"} 14 | mock.post(url, headers=headers, json=error_response, status_code=500) 15 | 16 | with pytest.raises(Exception) as excinfo: 17 | DatasetFactory.list(query="test_query", page_number=0, page_size=20) 18 | 19 | assert "Dataset List Error: Status 500 - {'message': 'Internal Server Error'}" in str(excinfo.value) 20 | 21 | 22 | def test_get_dataset_error_response(): 23 | with requests_mock.Mocker() as mock: 24 | dataset_id = "invalid_dataset_id" 25 | url = urljoin(config.BACKEND_URL, f"sdk/datasets/{dataset_id}/overview") 26 | headers = {"Authorization": f"Token {config.AIXPLAIN_API_KEY}", "Content-Type": "application/json"} 27 | 28 | error_response = {"message": "Not Found"} 29 | mock.get(url, headers=headers, json=error_response, status_code=404) 30 | 31 | with pytest.raises(Exception) as excinfo: 32 | DatasetFactory.get(dataset_id=dataset_id) 33 | 34 | assert "Dataset GET Error: Status 404 - {'message': 'Not Found'}" in str(excinfo.value) 35 | -------------------------------------------------------------------------------- /tests/unit/hyperparameters_test.py: -------------------------------------------------------------------------------- 1 | __author__ = "lucaspavanelli" 2 | 3 | """ 4 | Copyright 2022 The aiXplain SDK authors 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | """ 18 | 19 | from dotenv import load_dotenv 20 | 21 | load_dotenv() 22 | 23 | from aixplain.modules.finetune import Hyperparameters 24 | from aixplain.modules.finetune.hyperparameters import ( 25 | EPOCHS_MAX_VALUE, 26 | BATCH_SIZE_VALUES, 27 | MAX_SEQ_LENGTH_MAX_VALUE, 28 | ) 29 | 30 | 31 | import pytest 32 | 33 | 34 | def test_create(): 35 | hyp = Hyperparameters() 36 | assert hyp is not None 37 | 38 | 39 | @pytest.mark.parametrize( 40 | "params", 41 | [ 42 | {"epochs": "string"}, 43 | {"train_batch_size": "string"}, 44 | {"eval_batch_size": "string"}, 45 | {"learning_rate": "string"}, 46 | {"max_seq_length": "string"}, 47 | {"warmup_ratio": "string"}, 48 | {"warmup_steps": "string"}, 49 | {"lr_scheduler_type": "string"}, 50 | ], 51 | ) 52 | def test_create_invalid_type(params): 53 | with pytest.raises(Exception) as exc_info: 54 | Hyperparameters(**params) 55 | assert exc_info.type is TypeError 56 | 57 | 58 | @pytest.mark.parametrize( 59 | "params", 60 | [ 61 | {"epochs": EPOCHS_MAX_VALUE + 1}, 62 | {"train_batch_size": max(BATCH_SIZE_VALUES) + 1}, 63 | {"eval_batch_size": max(BATCH_SIZE_VALUES) + 1}, 64 | {"max_seq_length": MAX_SEQ_LENGTH_MAX_VALUE + 1}, 65 | ], 66 | ) 67 | def test_create_invalid_values(params): 68 | with pytest.raises(Exception) as exc_info: 69 | Hyperparameters(**params) 70 | assert exc_info.type is ValueError 71 | -------------------------------------------------------------------------------- /tests/unit/mock_responses/cost_estimation_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "trainingCost": { 3 | "total": 1, 4 | "supplierCost": 0, 5 | "overheadCost": 1, 6 | "isDependingOnTrainingTime": false, 7 | "willRefundIfLowerThanMax": false, 8 | "totalVolume": 98.72, 9 | "unitPrice": 0, 10 | "timeScale": null 11 | }, 12 | "inferenceCost": [ 13 | { 14 | "unitPrice": 0.023333333333333334, 15 | "unitType": "TIME", 16 | "unitTypeScale": "MINUTE", 17 | "volume": 0 18 | } 19 | ], 20 | "hostingCost": { 21 | "currentMonthPrice": 28.3526, 22 | "monthlyPrice": 38.736, 23 | "pricePerCycle": 0.0538, 24 | "supplierBillingCycle": "HOUR", 25 | "willRefundIfLowerThanMax": true 26 | } 27 | } -------------------------------------------------------------------------------- /tests/unit/mock_responses/finetune_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "MODEL_ID", 3 | "status": "MODEL_STATUS" 4 | } -------------------------------------------------------------------------------- /tests/unit/mock_responses/finetune_status_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "finetuneStatus": "onboarding", 3 | "modelStatus": "onboarded", 4 | "logs": [ 5 | { 6 | "epoch": 1, 7 | "learningRate": 9.938725490196079e-05, 8 | "trainLoss": 0.1, 9 | "evalLoss": 0.1106, 10 | "step": 10 11 | }, 12 | { 13 | "epoch": 2, 14 | "learningRate": 9.877450980392157e-05, 15 | "trainLoss": 0.2, 16 | "evalLoss": 0.0482, 17 | "step": 20 18 | }, 19 | { 20 | "epoch": 3, 21 | "learningRate": 9.816176470588235e-05, 22 | "trainLoss": 0.3, 23 | "evalLoss": 0.0251, 24 | "step": 30 25 | }, 26 | { 27 | "epoch": 4, 28 | "learningRate": 9.754901960784314e-05, 29 | "trainLoss": 0.9, 30 | "evalLoss": 0.0228, 31 | "step": 40 32 | }, 33 | { 34 | "epoch": 5, 35 | "learningRate": 9.693627450980392e-05, 36 | "trainLoss": 0.4, 37 | "evalLoss": 0.0217, 38 | "step": 50 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /tests/unit/mock_responses/finetune_status_response_2.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "65fb26268fe9153a6c9c29c4", 3 | "finetuneStatus": "in_progress", 4 | "modelStatus": "training", 5 | "logs": [ 6 | { 7 | "epoch": 1, 8 | "learningRate": null, 9 | "trainLoss": null, 10 | "validationLoss": null, 11 | "step": null, 12 | "evalLoss": 2.684150457382, 13 | "totalFlos": null, 14 | "evalRuntime": 12.4129, 15 | "trainRuntime": null, 16 | "evalStepsPerSecond": 0.322, 17 | "trainStepsPerSecond": null, 18 | "evalSamplesPerSecond": 16.112 19 | }, 20 | { 21 | "epoch": 2, 22 | "learningRate": null, 23 | "trainLoss": null, 24 | "validationLoss": null, 25 | "step": null, 26 | "evalLoss": 2.596168756485, 27 | "totalFlos": null, 28 | "evalRuntime": 11.8249, 29 | "trainRuntime": null, 30 | "evalStepsPerSecond": 0.338, 31 | "trainStepsPerSecond": null, 32 | "evalSamplesPerSecond": 16.913 33 | }, 34 | { 35 | "epoch": 2, 36 | "learningRate": null, 37 | "trainLoss": 2.657801408034, 38 | "validationLoss": null, 39 | "step": null, 40 | "evalLoss": null, 41 | "totalFlos": 11893948284928, 42 | "evalRuntime": null, 43 | "trainRuntime": 221.7946, 44 | "evalStepsPerSecond": null, 45 | "trainStepsPerSecond": 0.117, 46 | "evalSamplesPerSecond": null 47 | } 48 | ] 49 | } -------------------------------------------------------------------------------- /tests/unit/wallet_test.py: -------------------------------------------------------------------------------- 1 | __author__ = "aixplain" 2 | 3 | from aixplain.factories import WalletFactory 4 | import aixplain.utils.config as config 5 | import requests_mock 6 | 7 | 8 | def test_wallet_service(): 9 | with requests_mock.Mocker() as mock: 10 | url = f"{config.BACKEND_URL}/sdk/billing/wallet" 11 | headers = {"x-api-key": config.TEAM_API_KEY, "Content-Type": "application/json"} 12 | ref_response = {"totalBalance": 5, "reservedBalance": "0"} 13 | mock.get(url, headers=headers, json=ref_response) 14 | wallet = WalletFactory.get() 15 | assert wallet.total_balance == float(ref_response["totalBalance"]) 16 | assert wallet.reserved_balance == float(ref_response["reservedBalance"]) 17 | assert wallet.available_balance == float(ref_response["totalBalance"]) - float(ref_response["reservedBalance"]) 18 | --------------------------------------------------------------------------------