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

Add readme #28

Merged
merged 3 commits into from
Sep 11, 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
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 @@ -251,6 +251,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