BalanceAI Wrapper enables connection of AI models (API endpoints to AI models) to the BalanceAI blockchain. Wrapper is a Python utility (command-line tools and libraries) that wraps API calls from locally run model APIs, exposing them to BalanceAI users. It provides security by validating requests from authenticated users, checking authorization, and storing information about requests/responses on-chain and in the InterPlanetary File System (IPFS).
Project description
balance-ai-wrapper
Requirements
- python 12
setup venv
python3.12 -m venv venv
source venv/bin/activate
python
> Python 3.12.2 (...)
which python
> (...)venv/bin/python
pip install -r requirements.txt
Run all locally from sources
export PYTHONPATH=$PYTHONPATH:src
OR
export PYTHONPATH=src
python src/balanceai/cli_runner.py init
# update generated config file
python src/balanceai/cli_runner.py dev
Other commands
python src/balanceai/cli_runner.py zkml
python src/balanceai/cli_runner.py help
python src/balanceai/cli_runner.py init --config my-ai-model-wrapper-config.json
python src/balanceai/cli_runner.py dev --config my-ai-model-wrapper-config.json
Start mocked services
python mock/chain-app.py
python mock/ipfs-app.py
python mock/ai-app.py
bai wrapper - sample call
curl --location 'http://127.0.0.1:9000/baiwrapper/aimodel' \
--header 'Content-Type: application/json' \
--data '{
"caller_address": "CALLER_ADDR_5CSRVkQYi8P25Jidzhp9t1qzmnhEuTQim8L",
"id": "request_id_guid_gen_by_client_4364977e-c1b0-4e85-bb35-53538fab0909",
"model_id": "MODEL_ID_47djsnv9483ghj9idsv",
"encryption_key": "PUB_ENC_KEY_TO_IPFS_rzyw8Hwb7KkZQGxnMgWm2EXb1zh6DmRKX22",
"transparency": {
"request_store": true,
"response_store": false,
"encrypt": true
},
"request": {
"model_api_request": {
"x": 45,
"y": 123.45
}
},
"signature": "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
}'
# AI model
curl http://127.0.0.1:9300/ai
curl http://127.0.0.1:9300/ai/model333 -d {}
# IPFS
curl http://127.0.0.1:9100/ipfs
curl --location 'http://127.0.0.1:9100/ipfs/transaction' \
--header 'Content-Type: application/json' \
--data '{
"model": 222,
"timestamp": "2012-04-23T18:25:43.511Z",
"request": {
"p1": 2
},
"response": {
"r1": "response data"
}
}'
# CHAIN
curl http://127.0.0.1:9200/chain
curl --location 'http://127.0.0.1:9200/chain/updateModelUsageInfo' \
--header 'Content-Type: application/json' \
--data '{
"model_address": "0123123123",
"usage_info": "encrypted_usage"
}'
Build module
python3 -m build
install & run module
mkdir balanceai
cd balanceai
python3.12 -m venv venv
source venv/bin/activate
pip install ../../dist/balanceai-0.0.2.tar.gz
balanceai init
balanceai dev
Args & Parse
balanceai dev
balanceai zkml
balanceai help
Project details
Release history Release notifications | RSS feed
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 balanceai-0.0.2.tar.gz.
File metadata
- Download URL: balanceai-0.0.2.tar.gz
- Upload date:
- Size: 34.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89608a7cc7aaf5f3e5add30b80aadbcdff9bc39aafd4b3673441e8bceeaf1591
|
|
| MD5 |
4b4f995fb440f10a3343e5f00905c838
|
|
| BLAKE2b-256 |
4db7e91413d60813da682a817de0caa4e87bb98155d837a6c44c205d701533ac
|
File details
Details for the file balanceai-0.0.2-py3-none-any.whl.
File metadata
- Download URL: balanceai-0.0.2-py3-none-any.whl
- Upload date:
- Size: 39.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93cd09501bf9b2ab3e5a35d2919c4abc9da0e869600aa1261f301af945ec306e
|
|
| MD5 |
d32dec8b8a6827e2d5802745f9dd025d
|
|
| BLAKE2b-256 |
fd97e42cc1bd4a7dcba36c06fb2e21930f9d51d3b44a3ff4d22044e7d1845e72
|