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.
IMPORTANT: Note that both the API and the client library 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
AccessTokenSource
Used by the client to get (and eventually refresh) access tokens
Client
Implements all requests to the Aitta API servers on a low level and is used by all other classes.
Useful members:
get_model_list(): Lists all models served by the API that can be accessed with the configured access credentials.
Model
Represents a model and provides methods to perform inference.
Useful members:
load(model_id, client): Creates a Model instance given the models id, loading the relevant data from the Aitta API server.
Example usage
The below shows an example 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. You can obtain an access token by authenticating
with your CSC user account at the Generate token page
(also accessible from the main website by following the "Generate token" link in
the navigation bar after logging in).
With the token thus obtained, then have to create an instance of StaticAccessTokenSource for use
with the client library.
Chat completion with the LumiOpen/Llama-Poro-2-70B-Instruct model
This example shows how to start a conversation with the model using OpenAI’s chat completion feature.
NOTE: It is recommended to specify the
max_tokensvalue to a high enough number in order to avoid responses being cut out.
from aitta_client import Model, Client, StaticAccessTokenSource
import openai
# configure Client instance with API URL and access token
access_token = "token_for_given_model"
token_source = StaticAccessTokenSource(access_token)
aitta_client = Client("https://api-aitta.csc.fi", token_source)
# load the LumiOpen/Llama-Poro-2-70B-Instruct model
model = Model.load("LumiOpen/Llama-Poro-2-70B-Instruct", aitta_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": "Write a novel about bear talking about how to combine HPC with QC."
}
],
model=model.id,
max_tokens=8000,
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aitta_client-0.3.3.tar.gz.
File metadata
- Download URL: aitta_client-0.3.3.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36860f436185a717dfec8d6a4f11a6f7eb27bd57b0bd6cf49a925fc147d09b03
|
|
| MD5 |
a0ad3741121151cf5c3c20741fa7a611
|
|
| BLAKE2b-256 |
ae618346a04c2227a542d0bc8fe9585fd8b16b6ee29451ddc7112ed1b4f08271
|
File details
Details for the file aitta_client-0.3.3-py3-none-any.whl.
File metadata
- Download URL: aitta_client-0.3.3-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a26bfe137b2bcad847007d131f43d34646556d81b10c179c5389d877e92b36dd
|
|
| MD5 |
86d7da73d9b100e2ee74d144abb1248c
|
|
| BLAKE2b-256 |
68c023d3eb8e4800f54d1ae54918f17da1266e9c653566456a4eb86df8e9b61e
|