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.6 #158

Merged
merged 10 commits into from
Dec 19, 2024
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ yarn add @ainize-team/ainize-js
```

Then import the libraries in your code:

```typescript
// ES6
import Ainize from '@ainize-team/ainize-js';
Expand All @@ -25,9 +26,6 @@ import Ainize from '@ainize-team/ainize-js';
const Ainize = require('@ainize-team/ainize-js').default;
```


## Usage

### Create account

You should login to ainize with AI Network account before deploy the container.\
Expand All @@ -45,6 +43,7 @@ console.log(wallet);
```

### Login

```typescript
import Ainize from '@ainize-team/ainize-js';
const ainize = new Ainize(1);// 0 for testnet, 1 for mainnet. You can earn testnet AIN at https://faucet.ainetwork.ai/.
Expand Down Expand Up @@ -91,23 +90,27 @@ main();
```

### Currently supported models

| Model | MODEL_NAME | Insight Link |
| -------- | ------- | ------- |
| LLaMA 3.1 8B | meta-llama/Llama-3.1-8B-instruct | [Link](https://insight.ainetwork.ai/database/values/apps/meta_llama_llama_3_1_8b_instruct/) |

<!--
### Deploy

You can deploy your AI model to ainize. Anyone can use your AI model with AIN token.
You can deploy your AI model to ainize. Anyone can use your AI model with AIN token. **You need AIN tokens for deploying models.**

CONFIGURATION(JSON)

- modelName: The name you want to deploying model.
- modelUrl: Inference URL wrapped with ainize-wrapper-server.

<!--
- billingConfig: Billing configuration required for model usage.
- depositAddress: The address for receiving AIN deposits.
- costPerToken: Cost per token for model usage.
- minCost: Minimum cost.
- maxCost: Maximum cost. (optional)
-->

```typescript
import { Ainize } from '@ainize-team/ainize-js';
Expand All @@ -118,23 +121,24 @@ const main = async () => {
const ainize = new Ainize(1);
await ainize.login(ainPrivateKey);
const deployConfig = {
modelName: 'YOUR_MODEL_NAME',// e.g. meta-llama/Llama-3.1-8B-instruct
modelUrl: 'YOUR_MODEL_INFERENCE_URL' // e.g. https://ainize-free-inference.ainetwork.xyz
modelName: 'YOUR_MODEL_NAME', // e.g. meta-llama/Llama-3.1-8B-instruct
modelUrl: 'https://ainize-free-inference.ainetwork.xyz' // This URL is for tutorial.
}
const model = await ainize.deploy(deployConfig);
console.log(model.modelName);
ainize.logout();
}catch(e) {
} catch(e) {
console.log(e);
}
}
main();
```

<!--
You can stop or run your model container. Only model deployer can use this.

```typescript
model.stop();
model.run();
```
-->
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ainize-team/ainize-js",
"version": "1.3.5",
"version": "1.3.6",
"main": "dist/ainize.js",
"types": "dist/ainize.d.ts",
"scripts": {
Expand Down
37 changes: 24 additions & 13 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export const Path = {
depositOfUser: (userAddress: string) => `${Path.app(appName).deposit()}/${userAddress}`,
billingConfig: () => `${Path.app(appName).root()}/billingConfig`,
model: () => `${Path.app(appName).root()}/model`,
userOfModel: (userAddress: string) =>
requestUser: (userAddress: string) =>
`${Path.app(appName).model()}/${userAddress}`,
requestKey: (userAddress: string, requestKey: string) =>
`${Path.app(appName).userOfModel(userAddress)}/${requestKey}`,
`${Path.app(appName).requestUser(userAddress)}/${requestKey}`,
request: (userAddress: string, requestKey: string) =>
`${Path.app(appName).requestKey(userAddress, requestKey)}/request`,
response: (userAddress: string, requestKey: string) =>
Expand Down Expand Up @@ -65,17 +65,28 @@ export const defaultAppRules = (appName: string): { [type: string]: { ref: strin
},
},
},
// requestKey: {
// ref: Path.app(appName).requestKey("$userAddress", "$requestKey"),
// value: {
// ".rule": {
// state: {
// gc_max_siblings: 20,
// gc_num_siblings_deleted: 10,
// },
// },
// }
// },
requestUser: {
ref: Path.app(appName).requestUser("$userAddress"),
value: {
".rule": {
state: {
gc_max_siblings: 50,
gc_num_siblings_deleted: 10,
},
}
}
},
requestKey: {
ref: Path.app(appName).requestKey("$userAddress", "$requestKey"),
value: {
".rule": {
state: {
gc_max_siblings: 20,
gc_num_siblings_deleted: 10,
},
},
}
},
request: {
ref: Path.app(appName).request("$userAddress", "$requestKey"),
value: {
Expand Down
Loading