Initial commit
This commit is contained in:
66
packages/ai/README.md
Normal file
66
packages/ai/README.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# @dbis-thirdweb/ai
|
||||
|
||||
Chain-aware AI prompts and actions for Chain 138.
|
||||
|
||||
## Usage
|
||||
|
||||
### Prompt Generation
|
||||
|
||||
```typescript
|
||||
import { createReadPrompt, createWritePrompt, validatePromptForChain138 } from '@dbis-thirdweb/ai';
|
||||
|
||||
// Create read prompt
|
||||
const readPrompt = createReadPrompt('getBalance', { address: '0x...' });
|
||||
|
||||
// Create write prompt
|
||||
const writePrompt = createWritePrompt('transferNative', {
|
||||
to: '0x...',
|
||||
amount: '1000000000000000000', // 1 ETH in wei
|
||||
});
|
||||
|
||||
// Validate prompt targets Chain 138
|
||||
validatePromptForChain138(userPrompt);
|
||||
```
|
||||
|
||||
### Read Actions
|
||||
|
||||
```typescript
|
||||
import {
|
||||
createReadBalanceAction,
|
||||
createReadBlockHeightAction,
|
||||
executeReadAction,
|
||||
} from '@dbis-thirdweb/ai';
|
||||
import { ThirdwebSDK } from '@thirdweb-dev/sdk';
|
||||
import { chain138 } from '@dbis-thirdweb/chain';
|
||||
|
||||
const sdk = new ThirdwebSDK(chain138);
|
||||
const provider = sdk.getProvider();
|
||||
|
||||
// Create action
|
||||
const action = createReadBalanceAction('0x...');
|
||||
|
||||
// Execute
|
||||
const result = await executeReadAction(action, sdk, provider);
|
||||
console.log(result); // { address, balance, balanceFormatted }
|
||||
```
|
||||
|
||||
### Write Actions
|
||||
|
||||
```typescript
|
||||
import { createTransferAction, executeWriteAction } from '@dbis-thirdweb/ai';
|
||||
|
||||
// Create transfer action
|
||||
const action = createTransferAction('0x...', '1000000000000000000');
|
||||
|
||||
// Execute (requires signer)
|
||||
const result = await executeWriteAction(action, sdk);
|
||||
console.log(result); // { txHash, chainId }
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Chain-aware prompt templates with Chain 138 guardrails
|
||||
- Read action templates (balance, block height, token info)
|
||||
- Write action templates (transfers, contract interactions)
|
||||
- Chain ID routing validation
|
||||
- Error handling for unsupported operations
|
||||
Reference in New Issue
Block a user