docs: update READMEs to use AI SDK v6 streamText API
- Replace deprecated Agent class with streamText - Add anthropic provider import - Add system prompt example
This commit is contained in:
parent
b4acee2895
commit
84f40f2bb4
2 changed files with 14 additions and 6 deletions
|
|
@ -13,16 +13,20 @@ pnpm add @tpmjs/registry-execute
|
|||
## Usage
|
||||
|
||||
```typescript
|
||||
import { Agent } from 'ai';
|
||||
import { streamText } from 'ai';
|
||||
import { anthropic } from '@ai-sdk/anthropic';
|
||||
import { registrySearchTool } from '@tpmjs/registry-search';
|
||||
import { registryExecuteTool } from '@tpmjs/registry-execute';
|
||||
|
||||
const agent = new Agent({
|
||||
model: 'anthropic/claude-sonnet-4-20250514',
|
||||
const result = streamText({
|
||||
model: anthropic('claude-sonnet-4-20250514'),
|
||||
tools: {
|
||||
registrySearch: registrySearchTool,
|
||||
registryExecute: registryExecuteTool,
|
||||
},
|
||||
system: `You have access to the TPMJS tool registry.
|
||||
Use registrySearch to find tools, then registryExecute to run them.`,
|
||||
prompt: 'Search for web scraping tools and scrape https://example.com',
|
||||
});
|
||||
|
||||
// The agent can now:
|
||||
|
|
|
|||
|
|
@ -13,16 +13,20 @@ pnpm add @tpmjs/registry-search
|
|||
## Usage
|
||||
|
||||
```typescript
|
||||
import { Agent } from 'ai';
|
||||
import { streamText } from 'ai';
|
||||
import { anthropic } from '@ai-sdk/anthropic';
|
||||
import { registrySearchTool } from '@tpmjs/registry-search';
|
||||
import { registryExecuteTool } from '@tpmjs/registry-execute';
|
||||
|
||||
const agent = new Agent({
|
||||
model: 'anthropic/claude-sonnet-4-20250514',
|
||||
const result = streamText({
|
||||
model: anthropic('claude-sonnet-4-20250514'),
|
||||
tools: {
|
||||
registrySearch: registrySearchTool,
|
||||
registryExecute: registryExecuteTool,
|
||||
},
|
||||
system: `You have access to the TPMJS tool registry.
|
||||
Use registrySearch to find tools, then registryExecute to run them.`,
|
||||
prompt: 'Search for web scraping tools and scrape https://example.com',
|
||||
});
|
||||
|
||||
// The agent can now:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue