Skip to main content

The official Python SDK for the ACI API by Aipolabs (Aipotheosis Labs)

Project description

Aipolabs ACI Python SDK

PyPI version

The official Python SDK for the Aipolabs ACI API. Currently in private beta, breaking changes are expected.

The Aipolabs ACI Python SDK provides convenient access to the Aipolabs ACI REST API from any Python 3.10+ application.

Documentation

The REST API documentation is available here.

Installation

pip install aipolabs

or with poetry:

poetry add aipolabs

Usage

Aipolabs ACI platform is built with agent-first principles. Although you can call each of the APIs below any way you prefer in your application, we strongly recommend trying the Agent-centric features and taking a look at the examples to get the most out of the platform and to enable the full potential and vision of future agentic applications.

Client

from aipolabs import ACI

client = ACI(
    # it reads from environment variable by default so you can omit it if you set it in your environment
    api_key=os.environ.get("AIPOLABS_ACI_API_KEY")
)

Apps

Types

from aipolabs.types.apps import AppBasic, AppDetails

Methods

# search for apps, returns list of basic app data, sorted by relevance to the intent
# all parameters are optional
apps: list[AppBasic] = client.apps.search(
    intent="I want to search the web",
    allowed_apps_only=False, # If true, only return apps that are allowed by the agent/accessor, identified by the api key.
    include_functions=False, # If true, include functions (name and description) in the search results.
    categories=["search"],
    limit=10,
    offset=0
)
# get detailed information about an app, including functions supported by the app
app_details: AppDetails = client.apps.get(app_name="BRAVE_SEARCH")

Functions

Types

from aipolabs.types.functions import FunctionExecutionResult, FunctionDefinitionFormat

Methods

# search for functions, returns list of basic function data, sorted by relevance to the intent
# all parameters are optional
functions: list[dict] = client.functions.search(
    app_names=["BRAVE_SEARCH", "TAVILY"],
    intent="I want to search the web",
    allowed_apps_only=False, # If true, only returns functions of apps that are allowed by the agent/accessor, identified by the api key.
    format=FunctionDefinitionFormat.OPENAI, # The format of the functions, can be OPENAI, ANTHROPIC, BASIC (name and description only)
    limit=10,
    offset=0
)
# get function definition of a specific function, this is the schema you can feed into LLM
# the actual format is defined by the format parameter: OPENAI, ANTHROPIC, BASIC (name and description only)
function_definition: dict = client.functions.get_definition(
    function_name="BRAVE_SEARCH__WEB_SEARCH",
    format=FunctionDefinitionFormat.OPENAI
)
# execute a function with the provided parameters
result: FunctionExecutionResult = client.functions.execute(
    function_name="BRAVE_SEARCH__WEB_SEARCH",
    function_parameters={"query": {"q": "what is the weather in barcelona"}},
    linked_account_owner_id="john_doe"
)

if result.success:
    print(result.data)
else:
    print(result.error)

Agent-centric features

The SDK provides a suite of features and helper functions to make it easier and more seamless to use functions in LLM powered agentic applications. This is our vision and the recommended way of trying out the SDK.

Meta Functions and Unified Function Calling Handler

We provide 4 meta functions that can be used with LLMs as tools directly, and a unified handler for function calls. With these the LLM can discover apps and functions (that our platform supports) and execute them autonomously.

from aipolabs import meta_functions

# meta functions
tools = [
    meta_functions.ACISearchApps.SCHEMA,
    meta_functions.ACISearchFunctions.SCHEMA,
    meta_functions.ACIGetFunctionDefinition.SCHEMA,
    meta_functions.ACIExecuteFunction.SCHEMA,
]
# unified function calling handler
result = client.handle_function_call(
    tool_call.function.name,
    json.loads(tool_call.function.arguments),
    linked_account_owner_id="john_doe",
    allowed_apps_only=True,
    format=FunctionDefinitionFormat.OPENAI
)

There are mainly two ways to use the platform with the meta functions:

Please also see agent_with_preplanned_tools.py for comparison where the specific functions are pre selected and provided to the LLM.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aipolabs-0.0.1b6.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aipolabs-0.0.1b6-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file aipolabs-0.0.1b6.tar.gz.

File metadata

  • Download URL: aipolabs-0.0.1b6.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/24.3.0

File hashes

Hashes for aipolabs-0.0.1b6.tar.gz
Algorithm Hash digest
SHA256 54d39726aa83d56a3ca4a563c4bb7d947e01b4372754946de87841b1e5cd3df8
MD5 344b86b859538e09c3c1a2b9973ed673
BLAKE2b-256 eddb0277eb82694f3ba1af7740c89ba6a8ea9aab635ba4cec5d714b607a99cbd

See more details on using hashes here.

File details

Details for the file aipolabs-0.0.1b6-py3-none-any.whl.

File metadata

  • Download URL: aipolabs-0.0.1b6-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/24.3.0

File hashes

Hashes for aipolabs-0.0.1b6-py3-none-any.whl
Algorithm Hash digest
SHA256 e9b4e527fc9811799ac0d35d93eb2be0b07a0d387d8eedf8a3d2050ca74b44be
MD5 f5ec1592a1c8f0ab381f0008a02a669c
BLAKE2b-256 c0ab9dcdb410a9f86c9c73edac9d480f24f1aba29879a11f42473ee09a268b6a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page