Skip to content

Commit

Permalink
docs: fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
yoojinko committed Sep 25, 2023
1 parent 812e3eb commit 5562e43
Showing 1 changed file with 32 additions and 23 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>);
```

0 comments on commit 5562e43

Please sign in to comment.