Skip to content

Commit 629fccc

Browse files
add documentation on how to use webSearchService
1 parent 9b2518a commit 629fccc

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

packages/plugin-web-search/README.MD

+23-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ TAVILY_API_KEY=your_api_key # Required: API key for search service
2828

2929
## Usage
3030

31-
Import and register the plugin in your Eliza configuration:
31+
Import and register the plugin in your Eliza configuration. In
3232

3333
```typescript
3434
import { webSearchPlugin } from "@elizaos/plugin-web-search";
@@ -39,6 +39,28 @@ export default {
3939
};
4040
```
4141

42+
**Custom Usage**
43+
If you want custom usage, for example, twitter-client to search the web before posting a tweet, you can also import the webSearchService and use it directly. Here's how you can do it:
44+
45+
```typescript
46+
// packages/client-twitter/src/post.ts
47+
const webSearchService = new WebSearchService();
48+
await webSearchService.initialize(runtime);
49+
const latestNews = await webSearchService.search(
50+
"latest news on AI Agents",
51+
// searchOptions
52+
);
53+
54+
const state = await this.runtime.composeState(
55+
{ } // memory,
56+
{ // additional keys
57+
latestNews: latestNews,
58+
}
59+
);
60+
61+
// Then modify the tweet template to include the {{latestNews}} and however you need
62+
```
63+
4264
## Features
4365

4466
### Web Search

0 commit comments

Comments
 (0)