├── aixplain ├── processes │ ├── __init__.py │ └── data_onboarding │ │ └── __init__.py ├── decorators │ ├── __init__.py │ └── api_key_checker.py ├── modules │ ├── pipeline │ │ ├── __init__.py │ │ ├── designer │ │ │ ├── utils.py │ │ │ ├── enums.py │ │ │ └── __init__.py │ │ └── default.py │ ├── model │ │ ├── model_parameters.py │ │ └── model_response_streamer.py │ ├── __init__.py │ ├── agent │ │ ├── output_format.py │ │ └── model_with_params.py │ ├── wallet.py │ ├── finetune │ │ ├── status.py │ │ └── cost.py │ └── file.py ├── enums │ ├── license.py │ ├── language.py │ ├── supplier.py │ ├── function.py │ ├── status.py │ ├── evolve_type.py │ ├── code_interpreter.py │ ├── __init__.py │ ├── error_handler.py │ ├── sort_order.py │ ├── privacy.py │ ├── sort_by.py │ ├── data_split.py │ ├── onboard_status.py │ ├── index_stores.py │ ├── storage_type.py │ ├── ownership_type.py │ ├── response_status.py │ ├── splitting_options.py │ ├── embedding_model.py │ ├── database_source.py │ ├── data_subtype.py │ ├── function_type.py │ ├── data_type.py │ └── file_type.py ├── factories │ ├── model_factory │ │ └── mixins │ │ │ └── __init__.py │ ├── __init__.py │ ├── asset_factory.py │ ├── script_factory.py │ └── wallet_factory.py ├── utils │ ├── __init__.py │ ├── request_utils.py │ ├── llm_utils.py │ ├── evolve_utils.py │ └── convert_datatype_utils.py ├── v2 │ ├── enums_include.py │ └── __init__.py ├── __init__.py └── cli_groups.py ├── tests ├── functional │ ├── finetune │ │ ├── __init__.py │ │ └── data │ │ │ ├── finetune_test_list_data.json │ │ │ ├── finetune_test_end2end.json │ │ │ ├── finetune_test_prompt_validator.json │ │ │ └── finetune_test_cost_estimation.json │ ├── data_asset │ │ ├── __init__.py │ │ ├── input │ │ │ └── audio-en_with_invalid_split_url.csv │ │ └── corpus_onboarding_test.py │ ├── file_asset │ │ ├── __init__.py │ │ ├── input │ │ │ └── test.csv │ │ └── file_create_test.py │ ├── model │ │ └── data │ │ │ ├── test_input.txt │ │ │ └── test_file_parser_input.pdf │ ├── benchmark │ │ └── data │ │ │ ├── benchmark_module_test_data.json │ │ │ ├── benchmark_test_run_data.json │ │ │ └── benchmark_test_with_parameters.json │ ├── apikey │ │ ├── apikey.json │ │ └── README.md │ ├── agent │ │ └── data │ │ │ └── agent_test_end2end.json │ ├── pipelines │ │ └── data │ │ │ └── script.py │ ├── general_assets │ │ └── data │ │ │ └── asset_run_test_data.json │ ├── team_agent │ │ └── data │ │ │ └── team_agent_test_end2end.json │ └── v2 │ │ └── conftest.py ├── mock_responses │ ├── create_asset_repo_response.json │ ├── list_image_repo_tags_response.json │ ├── list_host_machines_response.json │ └── login_response.json ├── unit │ ├── mock_responses │ │ ├── finetune_response.json │ │ ├── cost_estimation_response.json │ │ ├── finetune_status_response.json │ │ └── finetune_status_response_2.json │ ├── data │ │ └── create_finetune_percentage_exception.json │ ├── wallet_test.py │ ├── corpus_test.py │ ├── dataset_test.py │ └── hyperparameters_test.py ├── test_requests │ └── create_asset_request.json ├── __init__.py └── test_utils.py ├── pytest.ini ├── setup.cfg ├── docs ├── api-reference │ └── python │ │ └── aixplain │ │ ├── v2 │ │ ├── enums.md │ │ ├── init.md │ │ ├── enums_include.md │ │ ├── model.md │ │ └── file.md │ │ ├── enums │ │ ├── init.md │ │ ├── status.md │ │ ├── evolve_type.md │ │ ├── code_interpreter.md │ │ ├── error_handler.md │ │ ├── sort_order.md │ │ ├── sort_by.md │ │ ├── privacy.md │ │ ├── data_split.md │ │ ├── onboard_status.md │ │ ├── index_stores.md │ │ ├── storage_type.md │ │ ├── ownership_type.md │ │ ├── response_status.md │ │ ├── splitting_options.md │ │ ├── embedding_model.md │ │ ├── database_source.md │ │ ├── function_type.md │ │ ├── data_subtype.md │ │ ├── file_type.md │ │ ├── supplier.md │ │ ├── data_type.md │ │ └── asset_status.md │ │ ├── processes │ │ ├── init.md │ │ └── data_onboarding │ │ │ └── init.md │ │ ├── decorators │ │ ├── init.md │ │ └── api_key_checker.md │ │ ├── utils │ │ ├── request_utils.md │ │ ├── evolve_utils.md │ │ ├── init.md │ │ ├── llm_utils.md │ │ ├── convert_datatype_utils.md │ │ ├── config.md │ │ └── cache_utils.md │ │ ├── modules │ │ ├── pipeline │ │ │ ├── init.md │ │ │ ├── designer │ │ │ │ ├── enums.md │ │ │ │ ├── init.md │ │ │ │ └── utils.md │ │ │ └── default.md │ │ ├── model │ │ │ ├── model_parameters.md │ │ │ ├── model_response_streamer.md │ │ │ └── record.md │ │ ├── init.md │ │ ├── agent │ │ │ ├── output_format.md │ │ │ ├── utils.md │ │ │ └── model_with_params.md │ │ ├── finetune │ │ │ ├── status.md │ │ │ └── cost.md │ │ ├── wallet.md │ │ ├── mixins.md │ │ └── file.md │ │ ├── factories │ │ ├── model_factory │ │ │ └── mixins │ │ │ │ ├── init.md │ │ │ │ └── model_getter.md │ │ ├── init.md │ │ ├── script_factory.md │ │ ├── wallet_factory.md │ │ ├── finetune_factory │ │ │ └── prompt_validator.md │ │ ├── pipeline_factory │ │ │ └── utils.md │ │ ├── asset_factory.md │ │ ├── data_factory.md │ │ └── team_agent_factory │ │ │ └── utils.md │ │ ├── init.md │ │ ├── cli_groups.md │ │ └── exceptions │ │ └── init.md ├── assets │ ├── aixplain-brandmark-line.png │ └── aixplain-workflow-teamagent.png └── README.md ├── .env.example ├── pydoc-markdown.yml ├── ruff.toml ├── .pre-commit-config.yaml ├── .github └── workflows │ └── docs.yaml ├── pyproject.toml └── .gitignore /aixplain/processes/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/functional/finetune/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/functional/data_asset/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/functional/file_asset/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /aixplain/processes/data_onboarding/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | testpaths = 3 | tests -------------------------------------------------------------------------------- /tests/functional/file_asset/input/test.csv: -------------------------------------------------------------------------------- 1 | A,B 2 | 1,2 3 | 3,4 -------------------------------------------------------------------------------- /aixplain/decorators/__init__.py: -------------------------------------------------------------------------------- 1 | from .api_key_checker import check_api_key 2 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description_file=README.md 3 | license_files=LICENSE.rst 4 | -------------------------------------------------------------------------------- /tests/mock_responses/create_asset_repo_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "modelId": "mockId" 3 | } -------------------------------------------------------------------------------- /tests/mock_responses/list_image_repo_tags_response.json: -------------------------------------------------------------------------------- 1 | ["tag1", "tag2", "tag3", "tag4"] -------------------------------------------------------------------------------- /aixplain/modules/pipeline/__init__.py: -------------------------------------------------------------------------------- 1 | from .pipeline import Pipeline 2 | 3 | __all__ = ["Pipeline"] 4 | -------------------------------------------------------------------------------- /tests/functional/model/data/test_input.txt: -------------------------------------------------------------------------------- 1 | Hello! Here is a robot emoji: 🤖 Response should contain this emoji. -------------------------------------------------------------------------------- /tests/unit/mock_responses/finetune_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "MODEL_ID", 3 | "status": "MODEL_STATUS" 4 | } -------------------------------------------------------------------------------- /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/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: v2 4 | title: aixplain.v2 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /tests/functional/finetune/data/finetune_test_list_data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "function": "text-generation" 4 | } 5 | ] -------------------------------------------------------------------------------- /docs/assets/aixplain-brandmark-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/HEAD/docs/assets/aixplain-brandmark-line.png -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/enums/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: enums 4 | title: aixplain.enums 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /docs/assets/aixplain-workflow-teamagent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/HEAD/docs/assets/aixplain-workflow-teamagent.png -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/processes/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: processes 4 | title: aixplain.processes 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /tests/functional/benchmark/data/benchmark_module_test_data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "benchmark_id" : "64da356e13d879bec2323aa8" 4 | } 5 | ] -------------------------------------------------------------------------------- /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/utils/request_utils.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: request_utils 3 | title: aixplain.utils.request_utils 4 | --- 5 | 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/functional/model/data/test_file_parser_input.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aixplain/aiXplain/HEAD/tests/functional/model/data/test_file_parser_input.pdf -------------------------------------------------------------------------------- /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/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/processes/data_onboarding/init.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | sidebar_label: data_onboarding 4 | title: aixplain.processes.data_onboarding 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /.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= -------------------------------------------------------------------------------- /aixplain/enums/license.py: -------------------------------------------------------------------------------- 1 | # This file has been replaced with static enums generated by generate.py 2 | # Please use the static enums from generated_enums.py instead 3 | 4 | from .generated_enums import License 5 | 6 | __all__ = ["License"] 7 | -------------------------------------------------------------------------------- /aixplain/enums/language.py: -------------------------------------------------------------------------------- 1 | # This file has been replaced with static enums generated by generate.py 2 | # Please use the static enums from generated_enums.py instead 3 | 4 | from .generated_enums import Language 5 | 6 | __all__ = ["Language"] 7 | -------------------------------------------------------------------------------- /aixplain/enums/supplier.py: -------------------------------------------------------------------------------- 1 | # This file has been replaced with static enums generated by generate.py 2 | # Please use the static enums from generated_enums.py instead 3 | 4 | from .generated_enums import Supplier 5 | 6 | __all__ = ["Supplier"] 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 -------------------------------------------------------------------------------- /aixplain/enums/function.py: -------------------------------------------------------------------------------- 1 | # This file has been replaced with static enums generated by generate.py 2 | # Please use the static enums from generated_enums.py instead 3 | 4 | from .generated_enums import Function, FunctionInputOutput, FunctionParameters 5 | 6 | __all__ = ["Function", "FunctionInputOutput", "FunctionParameters"] 7 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | ] -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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.per-file-ignores] 24 | "tests/**/*.py" = ["D"] 25 | 26 | [lint.isort] 27 | known-first-party = ["src"] 28 | 29 | [lint.pydocstyle] 30 | convention = "google" 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/v2/enums_include.py: -------------------------------------------------------------------------------- 1 | # This is an auto generated module. PLEASE DO NOT EDIT 2 | # This module provides compatibility imports from legacy enums for v2 3 | 4 | # Import all enums from legacy system for compatibility 5 | from aixplain.enums import ( 6 | AssetStatus, 7 | ErrorHandler, 8 | FileType, 9 | Function, 10 | Language, 11 | License, 12 | OnboardStatus, 13 | OwnershipType, 14 | Privacy, 15 | ResponseStatus, 16 | SortBy, 17 | SortOrder, 18 | StorageType, 19 | Supplier, 20 | FunctionType, 21 | EvolveType, 22 | CodeInterpreterModel, 23 | ) 24 | 25 | # Re-export for compatibility 26 | __all__ = [ 27 | "AssetStatus", 28 | "ErrorHandler", 29 | "FileType", 30 | "Function", 31 | "Language", 32 | "License", 33 | "OnboardStatus", 34 | "OwnershipType", 35 | "Privacy", 36 | "ResponseStatus", 37 | "SortBy", 38 | "SortOrder", 39 | "StorageType", 40 | "Supplier", 41 | "FunctionType", 42 | "EvolveType", 43 | "CodeInterpreterModel", 44 | ] 45 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/functional/v2/conftest.py: -------------------------------------------------------------------------------- 1 | import os 2 | import pytest 3 | 4 | 5 | @pytest.fixture(scope="module") 6 | def client(): 7 | """Initialize Aixplain client with test configuration for v2 tests.""" 8 | # Require credentials from environment variables for security 9 | api_key = os.getenv("TEAM_API_KEY") 10 | if not api_key: 11 | pytest.skip( 12 | "TEAM_API_KEY environment variable is required for functional tests" 13 | ) 14 | 15 | backend_url = os.getenv("BACKEND_URL") or "https://dev-platform-api.aixplain.com" 16 | model_url = ( 17 | os.getenv("MODELS_RUN_URL") or "https://dev-models.aixplain.com/api/v2/execute" 18 | ) 19 | 20 | from aixplain import Aixplain 21 | 22 | return Aixplain( 23 | api_key=api_key, 24 | backend_url=backend_url, 25 | model_url=model_url, 26 | ) 27 | 28 | 29 | @pytest.fixture(scope="module") 30 | def slack_token(): 31 | """Get Slack token for integration tests.""" 32 | # Require Slack token from environment variable for security 33 | token = os.getenv("SLACK_TOKEN") 34 | if not token: 35 | pytest.skip( 36 | "SLACK_TOKEN environment variable is required for Slack integration tests" 37 | ) 38 | return token 39 | -------------------------------------------------------------------------------- /.github/workflows/docs.yaml: -------------------------------------------------------------------------------- 1 | name: Generate API docs 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: write 10 | pull-requests: write 11 | 12 | jobs: 13 | build-docs: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout repo 18 | uses: actions/checkout@v4 19 | with: 20 | persist-credentials: false 21 | 22 | - name: Set up Python 23 | uses: actions/setup-python@v4 24 | with: 25 | python-version: '3.x' 26 | 27 | - name: Install dependencies 28 | run: | 29 | pip install pydoc-markdown 30 | 31 | - name: Run pydoc-markdown 32 | run: | 33 | pydoc-markdown pydoc-markdown.yml 34 | 35 | - name: Create Pull Request if docs changed 36 | uses: peter-evans/create-pull-request@v7 37 | with: 38 | branch: docs/regenerate-api-docs 39 | commit-message: "chore(docs): regenerate API docs" 40 | title: "chore(docs): regenerate API docs" 41 | body: | 42 | This PR was automatically generated by the workflow to regenerate the API documentation. 43 | add-paths: | 44 | docs/api-reference/python/** 45 | delete-branch: true 46 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 23 | 24 | @pytest.mark.parametrize( 25 | "FileFactory, is_temp, expected_link", 26 | [ 27 | (FileFactory, True, "http"), 28 | (FileFactory, False, "s3"), 29 | ], 30 | ) 31 | def test_file_create(FileFactory, is_temp, expected_link): 32 | upload_file = "tests/functional/file_asset/input/test.csv" 33 | s3_link = FileFactory.create(local_path=upload_file, tags=["test1", "test2"], license=License.MIT, is_temp=is_temp) 34 | assert s3_link.startswith(expected_link) 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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)) -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /aixplain/v2/__init__.py: -------------------------------------------------------------------------------- 1 | from .core import Aixplain 2 | from .utility import Utility 3 | from .agent import Agent 4 | from .tool import Tool 5 | from .file import Resource 6 | from .upload_utils import FileUploader, upload_file, validate_file_for_upload 7 | from .inspector import ( 8 | Inspector, 9 | InspectorTarget, 10 | InspectorAction, 11 | InspectorPolicy, 12 | InspectorAuto, 13 | InspectorOutput, 14 | ModelResponse, 15 | ) 16 | from .exceptions import ( 17 | AixplainV2Error, 18 | ResourceError, 19 | APIError, 20 | ValidationError, 21 | TimeoutError, 22 | FileUploadError, 23 | ) 24 | from .enums import ( 25 | AuthenticationScheme, 26 | FileType, 27 | Function, 28 | Language, 29 | License, 30 | AssetStatus, 31 | Privacy, 32 | OnboardStatus, 33 | OwnershipType, 34 | SortBy, 35 | SortOrder, 36 | ErrorHandler, 37 | ResponseStatus, 38 | StorageType, 39 | Supplier, 40 | FunctionType, 41 | EvolveType, 42 | CodeInterpreterModel, 43 | ) 44 | 45 | __all__ = [ 46 | "Aixplain", 47 | "Utility", 48 | "Agent", 49 | "Tool", 50 | "Resource", 51 | "FileUploader", 52 | "upload_file", 53 | "validate_file_for_upload", 54 | # Inspector classes 55 | "Inspector", 56 | "InspectorTarget", 57 | "InspectorAction", 58 | "InspectorPolicy", 59 | "InspectorAuto", 60 | "InspectorOutput", 61 | "ModelResponse", 62 | # Exceptions 63 | "AixplainV2Error", 64 | "ResourceError", 65 | "APIError", 66 | "ValidationError", 67 | "TimeoutError", 68 | "FileUploadError", 69 | # V2 enum exports 70 | "AuthenticationScheme", 71 | "FileType", 72 | "Function", 73 | "Language", 74 | "License", 75 | "AssetStatus", 76 | "Privacy", 77 | "OnboardStatus", 78 | "OwnershipType", 79 | "SortBy", 80 | "SortOrder", 81 | "ErrorHandler", 82 | "ResponseStatus", 83 | "StorageType", 84 | "Supplier", 85 | "FunctionType", 86 | "EvolveType", 87 | "CodeInterpreterModel", 88 | "SplittingOptions", 89 | ] 90 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/mock_responses/login_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "username": "AWS", 3 | "password": "eyJwYXlsb2FkIjoiNlNkQmp0WkRWbDRtQmxYMk5ZWHh0dFJQRTJFeWpScDFVczI1RTl2WUJMRmN5SVU1TE1wd3hiK2FaZWtnbjZidy9Ea3UxQ1FpcnIwRURwNXZNMTJuZXBJVzhITjNkVEtmeFNCa1RwcTNESSt2ZnVtSm5MVXM3KzlPNEo3cmRySDE5NjdnazYyb0NIRVV1WmZvOUFuUm5CeHUyU2ZmZWFndFlYVyt0dDVXeWtMQjRCRlNFaGJUelNtSnllSW9pNTlkNFNYdGtXY3pDT1RZQ281MUVlVEI0L1c4NGZMVVZQRVF6VThmdmtYRVl1TDNEUWFzc3F3dUxxcHp2bWtrSCtNOHNrdFp6bHZubXlxMnFGYkR0aElhamNXNW1Ud1BkVjJMN2w0ZFJVSTlTQ3Y1SlExbnlZZ01obUxHeDRDRG5KYmh0NndzeEtWcVpxbmMzMDR6WXZnQlZTcWFEY2VvWXV0SFEwSTVSQU1DaUtNd09SZHF0Skt1Y3FxRVBwTkxPaDhlcUFScmd4bkVCYnhQZm4zZ0M5L0x2bHBiZ1I5UFRIWGlqZlFWczNnUW5vTzFmd0R2d1dudTRsMjJDWjdSUTN4WlRNL29NdFNtZ2RScmplclpqNWo0RVMycTdQTEFXOU9UcUtieDRpZklMRUVucTIxbDBXaFNtc0xlR2g4Rm9GZkpOSGJ5L2wzUklTY2hjUzBYUUdYMXJ0cFhFOTc3bUVtdzY0WDdYT3h5UGlnZytzNWowMjhFY0VqSzV6R01sNzdDYUprcVVyZjVUUWZraTU4VURCMTNXWDlvVDVGQVUvcU9DY3F0SlQ5TlBZTnFXQ0xhamdFdk93TXFsQndkVzhKTEhwMTkwZ3psNE1nN0YwRDIvTFpScWRDVVh2SXRBSFJJUmROa1U3RDI1Y3VoL0xjSjlhZUQ2MnJiVDA1R2FIWkV5Z0d5MmxnRWlmekUvbWhPSGNUclBOSnlPTGhHaFc2L0F5dCt1MDRxNEdqMzVFQk1GSHZ0a0lLUEQ5MU04NTVKZnVMV3F3d09QR1NlZnNGRXlRNExxRGZtMkNueVpqd3NuNWRFSlR5VUZhTUMyODMwbCtBV3lZMFBQQ3l6eTFJK0FoMHV0VkJvMlBabkFPZVk1c3hOL05uOFhlbmRMbTA0Mm1wTENWOCtHd3lzYnVFM1BHRDdNV3pDaVVicm0rbXdBLzk0c3hTODlTNkJpVWhnUHp5RC84TWhyVUNNL1FTRGNFY3ZUTjVFc0N0UDM1cUdUT28yOWdxc3VzdWRLZHdEQkhWMlpkaGNNR0xQMElWNEZKN01CQVZSMnd4OTRiZXpDMm4xU3V5TGRGVVBQYVFKa2wwWmw2M3E4MU5FRjdMSzQ0M0FJbzlpV3FuazltbFBYRVo1OHdVUERnMUpZbWw4b3BCYVprazJtM2dvYk5HdEFWUHY1dDlXZitXY2Q2MDN3WnJ1TlhwUTNPSlk2WWI4ZXBMNlZpN1ErTkpaa2Z0NWl5M1FQRFpUUFZjSCs0c1VjZ0E2dmFMSUY2aEZCUncwWitRS0pvK0VZUWtFK0RTQXhMaldFYkt5ZzBSN1V3UHg0VThENjQ4My9mMlV2cU5jSFRORHNkbXRKcjlXcUwxNHRoc1BqQTNqZ3Bqc0pydDJJWTA1bEdNOWJJbGpmbUtGWFdsemppQ2ptSUNsSm14SUxIdzgvSTlKb3JYb2NmNXpoSHVzbCswUkdKc1NMTHAyOWc9PSIsImRhdGFrZXkiOiJBUUVCQUhod20wWWFJU0plUnRKbTVuMUc2dXFlZWtYdW9YWFBlNVVGY2U5UnE4LzE0d0FBQUg0d2ZBWUpLb1pJaHZjTkFRY0dvRzh3YlFJQkFEQm9CZ2txaGtpRzl3MEJCd0V3SGdZSllJWklBV1VEQkFFdU1CRUVERGFyODZkalUxNVFHNCtZaEFJQkVJQTdvY0xIeWFpUHViY2VTQ0g5djB6THd2UFZGbHU0WmJqZ09JSGkrdmxiNEpCVTBlNyt5VmpnT3BpcWVmQlkxbFBGWktKalgvMEIwMkJDcU1nPSIsInZlcnNpb24iOiIyIiwidHlwZSI6IkRBVEFfS0VZIiwiZXhwaXJhdGlvbiI6MTY5MjYxNDYwMX0=", 4 | "registry": "https://535945872701.dkr.ecr.us-east-1.amazonaws.com" 5 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/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 | -------------------------------------------------------------------------------- /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.39" 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.10", 34 | "Programming Language :: Python :: 3.11", 35 | "Programming Language :: Python :: 3.12", 36 | "Programming Language :: Python :: 3 :: Only", 37 | "Programming Language :: Python :: Implementation :: CPython", 38 | "Programming Language :: Python :: Implementation :: PyPy", 39 | "Topic :: Internet :: WWW/HTTP", 40 | "Topic :: Software Development :: Libraries", 41 | ] 42 | dependencies = [ 43 | "requests>=2.1.0", 44 | "tqdm>=4.1.0", 45 | "pandas>=2.0.0", 46 | "python-dotenv>=1.0.0", 47 | "validators>=0.20.0", 48 | "filetype>=1.2.0", 49 | "click>=7.1.2", 50 | "PyYAML>=6.0.1", 51 | "dataclasses-json>=0.5.2", 52 | "Jinja2==3.1.6", 53 | "sentry-sdk>=1.0.0", 54 | "pydantic>=2.10.6", 55 | "filelock>=3.0.0" 56 | ] 57 | 58 | [project.urls] 59 | Homepage = "https://github.com/aixplain/aiXplain" 60 | Documentation = "https://github.com/aixplain/pipelines/tree/main/docs" 61 | 62 | [project.scripts] 63 | aixplain = "aixplain.cli_groups:run_cli" 64 | 65 | [project.optional-dependencies] 66 | model-builder = [ 67 | "model-interfaces~=0.0.2" 68 | ] 69 | test = [ 70 | "pytest>=6.1.0", 71 | "docker>=6.1.3", 72 | "requests-mock>=1.11.0", 73 | "pytest-mock>=3.10.0", 74 | "pytest-rerunfailures>=16.0" 75 | ] 76 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/modules/finetune/cost.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: cost 3 | title: aixplain.modules.finetune.cost 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: June 14th 2023 24 | Description: 25 | FinetuneCost Class 26 | 27 | ### FinetuneCost Objects 28 | 29 | ```python 30 | class FinetuneCost() 31 | ``` 32 | 33 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/finetune/cost.py#L27) 34 | 35 | A class representing the cost structure for a fine-tuning job. 36 | 37 | This class encapsulates the cost information for training, inference, and hosting 38 | components of a fine-tuning job. It provides methods to convert the cost data 39 | into a dictionary format for serialization. 40 | 41 | **Attributes**: 42 | 43 | - `training` _Dict_ - Dictionary containing training cost information. 44 | - `inference` _Dict_ - Dictionary containing inference cost information. 45 | - `hosting` _Dict_ - Dictionary containing hosting cost information. 46 | 47 | #### \_\_init\_\_ 48 | 49 | ```python 50 | def __init__(training: Dict, inference: Dict, hosting: Dict) -> None 51 | ``` 52 | 53 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/finetune/cost.py#L40) 54 | 55 | Create a FinetuneCost object with training, inference, and hosting cost information. 56 | 57 | **Arguments**: 58 | 59 | - `training` _Dict_ - Dictionary containing training cost information. 60 | - `inference` _Dict_ - Dictionary containing inference cost information. 61 | - `hosting` _Dict_ - Dictionary containing hosting cost information. 62 | 63 | #### to\_dict 64 | 65 | ```python 66 | def to_dict() -> Dict 67 | ``` 68 | 69 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/finetune/cost.py#L57) 70 | 71 | Convert the FinetuneCost object to a dictionary. 72 | 73 | **Returns**: 74 | 75 | - `Dict` - A dictionary representation of the FinetuneCost object. 76 | 77 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | .aixplain_cache/ 6 | 7 | setup_env_ahmet.sh 8 | # C extensions 9 | *.so 10 | *.ipynb 11 | 12 | # Distribution / packaging 13 | .Python 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | wheels/ 26 | pip-wheel-metadata/ 27 | share/python-wheels/ 28 | *.egg-info/ 29 | .installed.cfg 30 | *.egg 31 | MANIFEST 32 | 33 | # PyInstaller 34 | # Usually these files are written by a python script from a template 35 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 36 | *.manifest 37 | *.spec 38 | 39 | # Installer logs 40 | pip-log.txt 41 | pip-delete-this-directory.txt 42 | 43 | # Unit test / coverage reports 44 | htmlcov/ 45 | .tox/ 46 | .nox/ 47 | .coverage 48 | .coverage.* 49 | .cache 50 | nosetests.xml 51 | coverage.xml 52 | *.cover 53 | *.py,cover 54 | .hypothesis/ 55 | .pytest_cache/ 56 | 57 | # Translations 58 | *.mo 59 | *.pot 60 | 61 | # Django stuff: 62 | *.log 63 | local_settings.py 64 | db.sqlite3 65 | db.sqlite3-journal 66 | 67 | # Flask stuff: 68 | instance/ 69 | .webassets-cache 70 | 71 | # Scrapy stuff: 72 | .scrapy 73 | 74 | # Sphinx documentation 75 | docs/_build/ 76 | 77 | # PyBuilder 78 | target/ 79 | 80 | # Jupyter Notebook 81 | .ipynb_checkpoints 82 | 83 | # IPython 84 | profile_default/ 85 | ipython_config.py 86 | 87 | # pyenv 88 | .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # Vscode 135 | .vscode 136 | .DS_Store 137 | 138 | .env.dev 139 | .env.prod 140 | .env.test 141 | 142 | aixplain-dev/ 143 | -------------------------------------------------------------------------------- /aixplain/modules/file.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: aiXplain team 19 | Date: March 20th 2023 20 | Description: 21 | File Class 22 | """ 23 | 24 | import pathlib 25 | 26 | from aixplain.enums.data_split import DataSplit 27 | from aixplain.enums.file_type import FileType 28 | from typing import Optional, Text, Union 29 | 30 | 31 | class File: 32 | """A class representing a file in the aiXplain platform. 33 | 34 | This class provides functionality for managing files, which are used to store 35 | data samples in the platform. It supports various file types, compression formats, 36 | and data splits. 37 | 38 | Attributes: 39 | path (Union[Text, pathlib.Path]): File path 40 | extension (Union[Text, FileType]): File extension (e.g. CSV, TXT, etc.) 41 | data_split (Optional[DataSplit]): Data split of the file. 42 | compression (Optional[Text]): Compression extension (e.g., .gz). 43 | """ 44 | def __init__( 45 | self, 46 | path: Union[Text, pathlib.Path], 47 | extension: Union[Text, FileType], 48 | data_split: Optional[DataSplit] = None, 49 | compression: Optional[Text] = None, 50 | ) -> None: 51 | """Initialize a new File instance. 52 | 53 | Args: 54 | path (Union[Text, pathlib.Path]): File path 55 | extension (Union[Text, FileType]): File extension (e.g. CSV, TXT, etc.) 56 | data_split (Optional[DataSplit], optional): Data split of the file. Defaults to None. 57 | compression (Optional[Text], optional): Compression extension (e.g., .gz). Defaults to None. 58 | """ 59 | self.path = path 60 | 61 | if isinstance(extension, FileType): 62 | self.extension = extension 63 | else: 64 | try: 65 | self.extension = FileType(extension) 66 | except Exception as e: 67 | raise Exception("File Error: This file extension is not supported.") 68 | 69 | self.compression = compression 70 | self.data_split = data_split 71 | -------------------------------------------------------------------------------- /docs/api-reference/python/aixplain/modules/agent/model_with_params.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_label: model_with_params 3 | title: aixplain.modules.agent.model_with_params 4 | --- 5 | 6 | A generic class that wraps a model with extra parameters. 7 | 8 | This is an abstract base class that must be extended by specific model wrappers. 9 | 10 | Example usage: 11 | 12 | class MyModel(ModelWithParams): 13 | model_id: Text = "my_model" 14 | extra_param: int = 10 15 | 16 | @field_validator("extra_param") 17 | def validate_extra_param(cls, v: int) -> int: 18 | if v < 0: 19 | raise ValueError("Extra parameter must be positive") 20 | return v 21 | 22 | ### ModelWithParams Objects 23 | 24 | ```python 25 | class ModelWithParams(BaseModel, ABC) 26 | ``` 27 | 28 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/agent/model_with_params.py#L25) 29 | 30 | A generic class that wraps a model with extra parameters. 31 | 32 | The extra parameters are not part of the model's input/output parameters. 33 | This is an abstract base class that must be extended by specific model wrappers. 34 | 35 | **Attributes**: 36 | 37 | - `model_id` - The ID of the model to wrap. 38 | 39 | #### validate\_model\_id 40 | 41 | ```python 42 | @field_validator("model_id") 43 | def validate_model_id(cls, v: Text) -> Text 44 | ``` 45 | 46 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/agent/model_with_params.py#L43) 47 | 48 | Validate the model_id field. 49 | 50 | This validator ensures that the model_id is not empty or whitespace-only. 51 | 52 | **Arguments**: 53 | 54 | - `cls` - The class (automatically provided by pydantic). 55 | - `v` _Text_ - The value to validate. 56 | 57 | 58 | **Returns**: 59 | 60 | - `Text` - The validated model ID. 61 | 62 | 63 | **Raises**: 64 | 65 | - `ValueError` - If the model ID is empty or contains only whitespace. 66 | 67 | #### \_\_new\_\_ 68 | 69 | ```python 70 | def __new__(cls, *args, **kwargs) 71 | ``` 72 | 73 | [[view_source]](https://github.com/aixplain/aiXplain/blob/main/aixplain/modules/agent/model_with_params.py#L62) 74 | 75 | Create a new instance of a ModelWithParams subclass. 76 | 77 | This method prevents direct instantiation of the abstract base class while 78 | allowing subclasses to be instantiated normally. 79 | 80 | **Arguments**: 81 | 82 | - `cls` - The class being instantiated. 83 | - `*args` - Positional arguments for instance creation. 84 | - `**kwargs` - Keyword arguments for instance creation. 85 | 86 | 87 | **Returns**: 88 | 89 | - `ModelWithParams` - A new instance of a ModelWithParams subclass. 90 | 91 | 92 | **Raises**: 93 | 94 | - `TypeError` - If attempting to instantiate ModelWithParams directly. 95 | 96 | -------------------------------------------------------------------------------- /aixplain/modules/agent/model_with_params.py: -------------------------------------------------------------------------------- 1 | """A generic class that wraps a model with extra parameters. 2 | 3 | This is an abstract base class that must be extended by specific model wrappers. 4 | 5 | Example usage: 6 | 7 | class MyModel(ModelWithParams): 8 | model_id: Text = "my_model" 9 | extra_param: int = 10 10 | 11 | @field_validator("extra_param") 12 | def validate_extra_param(cls, v: int) -> int: 13 | if v < 0: 14 | raise ValueError("Extra parameter must be positive") 15 | return v 16 | """ 17 | 18 | from abc import ABC 19 | from typing import Text 20 | 21 | from pydantic import BaseModel, ConfigDict, field_validator 22 | from pydantic.alias_generators import to_camel 23 | 24 | 25 | class ModelWithParams(BaseModel, ABC): 26 | """A generic class that wraps a model with extra parameters. 27 | 28 | The extra parameters are not part of the model's input/output parameters. 29 | This is an abstract base class that must be extended by specific model wrappers. 30 | 31 | Attributes: 32 | model_id: The ID of the model to wrap. 33 | """ 34 | 35 | model_config = ConfigDict( 36 | alias_generator=to_camel, 37 | populate_by_name=True, 38 | ) 39 | 40 | model_id: Text 41 | 42 | @field_validator("model_id") 43 | def validate_model_id(cls, v: Text) -> Text: 44 | """Validate the model_id field. 45 | 46 | This validator ensures that the model_id is not empty or whitespace-only. 47 | 48 | Args: 49 | cls: The class (automatically provided by pydantic). 50 | v (Text): The value to validate. 51 | 52 | Returns: 53 | Text: The validated model ID. 54 | 55 | Raises: 56 | ValueError: If the model ID is empty or contains only whitespace. 57 | """ 58 | if not v or not v.strip(): 59 | raise ValueError("Model ID is required") 60 | return v 61 | 62 | def __new__(cls, *args, **kwargs): 63 | """Create a new instance of a ModelWithParams subclass. 64 | 65 | This method prevents direct instantiation of the abstract base class while 66 | allowing subclasses to be instantiated normally. 67 | 68 | Args: 69 | cls: The class being instantiated. 70 | *args: Positional arguments for instance creation. 71 | **kwargs: Keyword arguments for instance creation. 72 | 73 | Returns: 74 | ModelWithParams: A new instance of a ModelWithParams subclass. 75 | 76 | Raises: 77 | TypeError: If attempting to instantiate ModelWithParams directly. 78 | """ 79 | if cls is ModelWithParams: 80 | raise TypeError("ModelWithParams is an abstract base class and cannot be instantiated directly") 81 | return super().__new__(cls) 82 | -------------------------------------------------------------------------------- /tests/functional/data_asset/corpus_onboarding_test.py: -------------------------------------------------------------------------------- 1 | __author__ = "thiagocastroferreira" 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 | import time 21 | from aixplain.enums import Language, License, OnboardStatus 22 | from aixplain.factories.corpus_factory import CorpusFactory 23 | from uuid import uuid4 24 | 25 | 26 | @pytest.mark.parametrize("CorpusFactory", [CorpusFactory]) 27 | def test_corpus_onboard_get_delete(CorpusFactory): 28 | upload_file = "tests/functional/data_asset/input/audio-en_url.csv" 29 | schema = [ 30 | { 31 | "name": "audio", 32 | "dtype": "audio", 33 | "storage_type": "url", 34 | "start_column": "audio_start_time", 35 | "end_column": "audio_end_time", 36 | "languages": [Language.ENGLISH_UNITED_STATES], 37 | }, 38 | { 39 | "name": "text", 40 | "dtype": "text", 41 | "storage_type": "text", 42 | "languages": [Language.ENGLISH_UNITED_STATES], 43 | }, 44 | ] 45 | 46 | response = CorpusFactory.create( 47 | name=str(uuid4()), 48 | description="This corpus contain 20 English audios with their corresponding transcriptions.", 49 | license=License.MIT, 50 | content_path=upload_file, 51 | schema=schema, 52 | ) 53 | asset_id = response["asset_id"] 54 | onboard_status = OnboardStatus(response["status"]) 55 | while onboard_status == OnboardStatus.ONBOARDING: 56 | corpus = CorpusFactory.get(asset_id) 57 | onboard_status = corpus.onboard_status 58 | time.sleep(1) 59 | # assert the asset was onboarded 60 | assert onboard_status == OnboardStatus.ONBOARDED 61 | # assert the asset was deleted 62 | corpus.delete() 63 | with pytest.raises(Exception): 64 | corpus = CorpusFactory.get(asset_id) 65 | 66 | 67 | @pytest.mark.parametrize("CorpusFactory", [CorpusFactory]) 68 | def test_corpus_listing(CorpusFactory): 69 | response = CorpusFactory.list() 70 | assert "results" in response 71 | 72 | 73 | @pytest.mark.parametrize("CorpusFactory", [CorpusFactory]) 74 | def test_corpus_get_error(CorpusFactory): 75 | with pytest.raises(Exception): 76 | response = CorpusFactory.get("131312") 77 | --------------------------------------------------------------------------------