-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from ainize-team/develop
develop -> main
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |