Skip to content

Commit

Permalink
Merge pull request #28 from ainize-team/docs/yoojin/readme
Browse files Browse the repository at this point in the history
Add readme
  • Loading branch information
yoojinko authored Sep 11, 2023
2 parents 7ee3a84 + b5a6288 commit 1d829c3
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
# ainize-sdk
# ainize-sdk

A Typescript SDK for the Ainize, a system for running AI services on the AI Network.

## Requirements
node >= 16

## usage
### Install
```bash
npm install @ainize-team/ainize-sdk

yarn install @ainize-team/ainize-sdk
```

### Import
```typescript
import Ainize from '@ainize-team/ainize-sdk'
const ainize = new Ainize(<CHAIN_ID>, <YOUR_PRIVATE_KEY>);
```

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.
```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>);
```

- APP_NAME: The app name to be registered on AI Network.
- SERVICE_URL: The URL for sending API requests to your AI Service.

### Service
You can use AI Service.
```typescript
ainize.service.deposit(<APP_NAME>, <AMOUNT>);
ainize.service.writeRequest(<APP_NAME>, <SERVICE_NAME>, <PROMPT>);
```

### Admin
You can get user requests.
```typescript
ainize.admin.deposit(<REQUEST>);
ainize.admin.writeResponse(<REQUEST>, <COST_AMOUNT>, <RESPONSE_DATA>, <RESPONSE_STATUS>);
```

## Test
```bash
yarn test
```
1 change: 1 addition & 0 deletions src/modules/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default class App extends ModuleBase {
const balancePath = Path.app(appName).balanceOfUser(userAddress);
return await this.ain.db.ref(balancePath).getValue();
}

private buildSetBillingConfigOp(appName: string, config: appBillingConfig) {
const path = Path.app(appName).billingConfig();
return buildSetOperation("SET_VALUE", path, config);
Expand Down

0 comments on commit 1d829c3

Please sign in to comment.