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.1.tar.gz (12.9 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.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aitta_client-0.2.1.tar.gz
  • Upload date:
  • Size: 12.9 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.1.tar.gz
Algorithm Hash digest
SHA256 39de9bb0dd7d83a677f5794e3465f6edc1e0f7fc73217c1ca072e15e2d1aea97
MD5 227a04450fb19fc754eccfc2dc1858bf
BLAKE2b-256 55069ad6421a485c2d5376d166ba930a6b1b4ffc6603a5dfa9dd101f2592e7e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aitta_client-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f4048074902f17e967e1985adbbb8233fcce2e01c29c8b2f8a5d47e4b6de49af
MD5 287d282268503b67898596b2d8e993fa
BLAKE2b-256 13daddfd0ff84cd8ca1e085f3b58dde436319c3ac20a7edc5e590a00b0ce6326

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