Skip to content

Commit

Permalink
Merge pull request #62 from ainize-team/docs/yoojin/readme2
Browse files Browse the repository at this point in the history
Update readme
  • Loading branch information
yoojinko authored Sep 25, 2023
2 parents 812e3eb + 4e92b0e commit 8eac130
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
55 changes: 32 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,51 @@ yarn install @ainize-team/ainize-sdk
### Import
```typescript
import Ainize from '@ainize-team/ainize-sdk'
const ainize = new Ainize(<CHAIN_ID>, <YOUR_PRIVATE_KEY>);
const ainize = new Ainize(<CHAIN_ID>);
```

CHAIN_ID
- 0: AI Network test net
- 1: AI Network main net

### App
You can manage the AI Network app required for operating AI Services.
### Login
You should login to ainize with AI Network account before deploy the container.
```typescript
ainize.app.create(<APP_NAME>, <SERVICE_URL>);
ainize.app.setTriggerFunction(<APP_NAME>, <TRIGGER_URLS>);
ainize.app.setBillingConfig(<APP_NAME>, <BILLING_CONFIG>);
ainize.app.setRules(<APP_NAME>, <RULES>);
ainize.app.addAdmin(<APP_NAME>, <ADDRESS>);
ainize.app.deleteAdmin(<APP_NAME>, <ADDRESS>);
ainize.login(<YOUR_PRIVATE_KEY>);
```

- APP_NAME: The app name to be registered on AI Network.
- SERVICE_URL: The URL for sending API requests to your AI Service.
### Deploy
You can deploy your AI model to ainize.
```typescript
const model = await ainize.deploy(<CONFIGURATION>);
```
CONFIGURATION
- modelName: The name you want to deploying model.
- 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)

### Service
You can use AI Service.
You can stop or run your model container. Model deployer only can use this.
```typescript
ainize.service.deposit(<APP_NAME>, <AMOUNT>);
ainize.service.writeRequest(<APP_NAME>, <SERVICE_NAME>, <PROMPT>);
model.stop();
model.run();
```

### Admin
You can get user requests.
### Using Model
You can use a model using `ainize.model(<MODEL_NAME>)`.
```typescript
ainize.admin.deposit(<REQUEST>);
ainize.admin.writeResponse(<REQUEST>, <COST_AMOUNT>, <RESPONSE_DATA>, <RESPONSE_STATUS>);
const model = await ainize.model(<MODEL_NAME>);
```

## Test
```bash
yarn test
```
You should deposit AIN to credit before using model.
```typescript
await model.deposit(<AMOUNT>);
const balance = await model.getCreditBalance();
```

If you have enough credit, you can use the model.
```typescript
const result = await model.use(<REQUEST_DATA>);
```
1 change: 0 additions & 1 deletion src/types/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type appBillingConfig = {
costPerToken: number;
minCost: number;
maxCost?: number;
responseTimeout?: number;
};

export enum HISTORY_TYPE {
Expand Down

0 comments on commit 8eac130

Please sign in to comment.