Skip to main content

Python client for Aitta HPC ML inference platform

Project description

Python client for Aitta HPC ML inference platform

A Python client library for the Aitta ML inference platform for HPC systems.

Note that both the API as well as the client libary are still under heavy development and while we try to keep changes mostly backwards-compatible, breaking changes may happen. Access to Aitta is currently restricted to selected beta users.

Main client API classes

  • Client: implements all requests to the Aitta API servers on a low level and is used by all other classes
  • AccessTokenSource: used by the client to get (and eventually refresh) access tokens
  • Model: represents a model and provides methods to perform inference
  • Task: represents an active inference task and provides methods to query the current status and results

Example usage

The below shows two examples for usage of the Aitta API using the Python client library.

For accessing the Aitta API the client will need a way to obtain access tokens, which is implemented in the form of an AccessTokenSource. For the time being, you can generate a static model-specific token at the web frontend by opening the model's page, switching to the "API Key" tab and pressing the "Generate API key" button.

With the token thus obtained, then have to create an instance of StaticAccessTokenSource for use with the client library.

Performing text completion with the LumiOpen/Poro model

from aitta_client import Model, Client, StaticAccessTokenSource

# configure Client instance with access token and API URL
poro_access_token = "<generate your model-specific token from https://staging-aitta.2.rahtiapp.fi/ and enter it here>"

token_source = StaticAccessTokenSource(poro_access_token)
client = Client("https://api-staging-aitta.2.rahtiapp.fi", token_source)

# load the LumiOpen/Poro model
model = Model.load("LumiOpen/Poro", client)

print(model.description)

# declare inputs and parameters for a text completion inference task
inputs = {
    'input': 'Suomen paras kaupunki on'
}

params = {
    'do_sample': True,
    'max_new_tokens': 20
}

print(f"INPUT:\n{inputs}")

# start the inference and wait for completion
result = model.start_and_await_inference(inputs, params)
print(f"OUTPUT:\n{result}")

Performing OpenAI chat completion with the LumiOpen/Poro-34b-chat model

from aitta_client import Model, Client, StaticAccessTokenSource
import openai

# configure Client instance with access token and API URL
poro_access_token = "<generate your model-specific token from https://staging-aitta.2.rahtiapp.fi/ and enter it here>"

token_source = StaticAccessTokenSource(poro_access_token)
client = Client("https://api-staging-aitta.2.rahtiapp.fi", token_source)

# load the LumiOpen/Poro-34B-chat model
model = Model.load("LumiOpen/Poro-34B-chat", client)

print(model.description)

# configure OpenAI client to use the Aitta OpenAI compatibility endpoints
client = openai.OpenAI(api_key=token_source.get_access_token(), base_url=model.openai_api_url)

# perform chat completion with the OpenAI client
chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test"
        }
    ],
    model=model.id,
    stream=False  # response streaming is currently not supported by Aitta
)

print(chat_completion.choices[0].message.content)

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

aitta_client-0.2.2.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

aitta_client-0.2.2-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file aitta_client-0.2.2.tar.gz.

File metadata

  • Download URL: aitta_client-0.2.2.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for aitta_client-0.2.2.tar.gz
Algorithm Hash digest
SHA256 fe4413fd84550b3bff8ddea0e48d5d817da44a7754b6f6fdb1763c0165490df3
MD5 71427ec5c7c9d563fdd830016e670713
BLAKE2b-256 b825d6a5fe541bf0dfd03d7d30005396f605c7de47a78ba02ea4297531056968

See more details on using hashes here.

File details

Details for the file aitta_client-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: aitta_client-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for aitta_client-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c4e7f006f7fddadf74e219daad6efad8a0d6d7027715e31d33598c722a48e4b0
MD5 8381bbe769aed04c65ab523268ddb8dc
BLAKE2b-256 8c6f2bea91747ac89f5f391eb91b44923f74a2d42a19470e5897d3bf478a9dc7

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