Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade version to 1.3.5 #153

Merged
merged 8 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- uses: actions/setup-node@v3
with:
node-version: 16 # typedoc require node version >= 14.14
node-version: 18 # typedoc require node version >= 14.14
- name: Build Docs
run: yarn && yarn docs
- name: Deploy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16 ]
node: [ 18 ]
name: Run Test on Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr_test_when_merged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16 ]
node: [ 18 ]
name: Run Test on Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
Expand All @@ -30,7 +30,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: yarn
Expand Down
6 changes: 3 additions & 3 deletions examples/charge.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Ainize } from '@ainize-team/ainize-js';
import Ainize from '@ainize-team/ainize-js';
const ainPrivateKey = ''; // Insert your private key here
const main = async () => {
try {
const ainize = new Ainize(1); // 0 for testnet, 1 for mainnet. You can earn testnet AIN at https://faucet.ainetwork.ai/.
await ainize.login(ainPrivateKey);
console.log('balance: ',await ainize.getAinBalance());
const model = await ainize.getModel('ainize_free_inference');
const model = await ainize.getModel('meta-llama/Llama-3.1-8B-instruct');
console.log(model.modelName);
console.log("before charge: ",await model.getCreditBalance());
await model.chargeCredit(10);
console.log("after charge: ",await model.getCreditBalance());
ainize.logout();
}catch(e) {
} catch(e) {
console.log(e);
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Ainize } from '@ainize-team/ainize-js';
import Ainize from '@ainize-team/ainize-js';
const ainPrivateKey = ''; // Insert your private key here

const main = async () => {
try {
const ainize = new Ainize(1); // 0 for testnet, 1 for mainnet. You can earn testnet AIN at https://faucet.ainetwork.ai/.
await ainize.login(ainPrivateKey);
console.log('balance: ',await ainize.getAinBalance());
console.log('balance: ', await ainize.getAinBalance());
const deployConfig = {
modelName: 'YOUR_MODEL_NAME',
modelUrl: 'YOUR_MODEL_INFERENCE_URL' // e.g. https://ainize-free-inference.ainetwork.xyz
modelUrl: 'YOUR_MODEL_INFERENCE_URL'
}
const model = await ainize.deploy(deployConfig);
console.log(model.modelName);
ainize.logout();
}catch(e) {
} catch(e) {
console.log(e);
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/request.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Ainize } from '@ainize-team/ainize-js';
import Ainize from '@ainize-team/ainize-js';
const ainPrivateKey = ''; // Insert your private key here

const main = async () => {
try {
const ainize = new Ainize(1); // 0 for testnet, 1 for mainnet. You can earn testnet AIN at https://faucet.ainetwork.ai/.
await ainize.login(ainPrivateKey);
console.log('balance: ',await ainize.getAinBalance());
const inferenceModel = await ainize.getModel('ainize_free_inference');
const inferenceModel = await ainize.getModel('meta-llama/Llama-3.1-8B-instruct');
console.log(inferenceModel.modelName);
console.log(await inferenceModel.getCreditBalance());
const request = {
Expand All @@ -17,7 +17,7 @@ const main = async () => {
const response = await inferenceModel.request(request);
console.log(response);
ainize.logout();
}catch(e) {
} catch(e) {
console.log(e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ainize-team/ainize-js",
"version": "1.3.4",
"version": "1.3.5",
"main": "dist/ainize.js",
"types": "dist/ainize.d.ts",
"scripts": {
Expand All @@ -10,7 +10,7 @@
"docs": "yarn build && typedoc --options typedoc.json --out docs"
},
"engines": {
"node": ">=16"
"node": ">=18"
},
"repository": {
"type": "git",
Expand Down
19 changes: 11 additions & 8 deletions src/ain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@ export default class AinModule {
return AinModule.instance;
}

static createAccount() {
const blockchainAPIEndpoint = getBlockChainAPIEndpoint(0);
const blockchainEventEndpoint = getBlockChainEventEndpoint(0);
const ain = new Ain(blockchainAPIEndpoint, blockchainEventEndpoint, 0);

const newAccount = ain.wallet.create(1)[0];
const wallet = ain.wallet.accounts[newAccount];

return wallet;
}

initAin(chainId: 0 | 1) {
const blockchainAPIEndpoint = getBlockChainAPIEndpoint(chainId);
const blockchainEventEndpoint = getBlockChainEventEndpoint(chainId);
this.ain = new Ain(blockchainAPIEndpoint, blockchainEventEndpoint, chainId);
}

createAccount() {
this.checkAinInitiated();
const newAccount = this.ain!.wallet.create(1)[0];
const wallet = this.ain!.wallet.accounts[newAccount];
this.ain!.wallet.remove(newAccount);
return wallet;
}

setDefaultAccount(privateKey: string) {
this.checkAinInitiated();
this.ain!.wallet.addAndSetDefaultAccount(privateKey);
Expand Down
2 changes: 1 addition & 1 deletion src/ainize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class Ainize {
* @returns {Account} created account.
*/
static createAinAccount (): Account {
return AinModule.getInstance().createAccount();
return AinModule.createAccount();
}

/**
Expand Down
Loading