Skip to content

Commit

Permalink
Merge pull request #140 from ainize-team/develop
Browse files Browse the repository at this point in the history
develop -> main
  • Loading branch information
akaster99 authored Dec 13, 2024
2 parents c6e3184 + 0b81663 commit cbf3f24
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/charge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Ainize } from '@ainize-team/ainize-js';
const ainPrivateKey = ''; // Insert your private key here
const main = async () => {
try {
const ainize = new Ainize(0); // 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');
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) {
console.log(e);
}
}
main();
20 changes: 20 additions & 0 deletions examples/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Ainize } from '@ainize-team/ainize-js';
const ainPrivateKey = ''; // Insert your private key here

const main = async () => {
try {
const ainize = new Ainize(0); // 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 deployConfig = {
modelName: 'YOUR_MODEL_NAME',
modelUrl: 'YOUR_MODEL_INFERENCE_URL' // e.g. https://ainize-free-inference.ainetwork.xyz
}
const model = await ainize.deploy(deployConfig);
console.log(model.modelName);
ainize.logout();
}catch(e) {
console.log(e);
}
}
main();
24 changes: 24 additions & 0 deletions examples/request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Ainize } from '@ainize-team/ainize-js';
const ainPrivateKey = ''; // Insert your private key here

const main = async () => {
try {
const ainize = new Ainize(0); // 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');
console.log(inferenceModel.modelName);
console.log(await inferenceModel.getCreditBalance());
const request = {
"prompt": "hi"
};
const cost = await inferenceModel.calculateCost(request.prompt);
console.log(cost);
const response = await inferenceModel.request(request);
console.log(response);
ainize.logout();
}catch(e) {
console.log(e);
}
}
main();

0 comments on commit cbf3f24

Please sign in to comment.