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

Update readme #62

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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