@mastra/perplexity 0.2.1-alpha.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -53
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,79 +1,40 @@
|
|
|
1
1
|
# @mastra/perplexity
|
|
2
2
|
|
|
3
3
|
Web search tool for [Mastra](https://mastra.ai) agents, backed by the [Perplexity Search API](https://docs.perplexity.ai/docs/search/quickstart).
|
|
4
|
-
|
|
5
4
|
## Installation
|
|
6
5
|
|
|
7
6
|
```bash
|
|
8
|
-
npm install @mastra/perplexity
|
|
7
|
+
npm install @mastra/perplexity
|
|
9
8
|
```
|
|
10
9
|
|
|
11
|
-
##
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Set `PERPLEXITY_API_KEY` before creating the search tool.
|
|
12
14
|
|
|
13
15
|
```typescript
|
|
14
16
|
import { Agent } from '@mastra/core/agent';
|
|
15
17
|
import { createPerplexitySearchTool } from '@mastra/perplexity';
|
|
16
18
|
|
|
17
|
-
const
|
|
19
|
+
export const researchAgent = new Agent({
|
|
18
20
|
id: 'research-agent',
|
|
19
21
|
name: 'Research Agent',
|
|
20
|
-
model: '
|
|
21
|
-
instructions:
|
|
22
|
-
'You are a research assistant. Use the perplexity-search tool to find up-to-date information from the web before answering.',
|
|
22
|
+
model: 'openai/gpt-5.6-sol',
|
|
23
|
+
instructions: 'Use web search to find current sources before answering.',
|
|
23
24
|
tools: {
|
|
24
25
|
search: createPerplexitySearchTool(),
|
|
25
26
|
},
|
|
26
27
|
});
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Filtering
|
|
32
|
-
|
|
33
|
-
The Search API supports filtering by domain and date. All filters are optional.
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
const tool = createPerplexitySearchTool();
|
|
37
|
-
|
|
38
|
-
await tool.execute!({
|
|
39
|
-
query: 'recent papers on agent evaluation',
|
|
40
|
-
maxResults: 10,
|
|
41
|
-
searchRecencyFilter: 'month',
|
|
42
|
-
searchDomainFilter: ['arxiv.org', 'openreview.net'],
|
|
43
|
-
}, {} as any);
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
To exclude domains, prefix them with `-`. Don't mix allow- and deny-list entries in the same call.
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
searchDomainFilter: ['-pinterest.com', '-quora.com'];
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Using Perplexity as a Model Provider
|
|
53
|
-
|
|
54
|
-
Perplexity is also a first-class model provider in Mastra's model router. To chat with Perplexity models (separate from this search tool), set `PERPLEXITY_API_KEY` and reference the model directly:
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
import { Agent } from '@mastra/core/agent';
|
|
58
|
-
|
|
59
|
-
const agent = new Agent({
|
|
60
|
-
id: 'agent-api',
|
|
61
|
-
name: 'Perplexity Agent',
|
|
62
|
-
model: 'perplexity-agent/openai/gpt-5',
|
|
63
|
-
instructions: 'You are a research assistant powered by the Perplexity Agent API.',
|
|
64
|
-
});
|
|
65
|
-
```
|
|
30
|
+
## Documentation
|
|
66
31
|
|
|
67
|
-
|
|
32
|
+
- [@mastra/perplexity documentation](https://mastra.ai/integrations/tools/perplexity)
|
|
68
33
|
|
|
69
|
-
##
|
|
34
|
+
## Changelog
|
|
70
35
|
|
|
71
|
-
|
|
72
|
-
|--------|------|---------|-------------|
|
|
73
|
-
| `apiKey` | `string` | `PERPLEXITY_API_KEY` → `PPLX_API_KEY` | Perplexity API key. |
|
|
74
|
-
| `baseUrl` | `string` | `https://api.perplexity.ai` | Override the API base URL (useful for proxies and tests). |
|
|
75
|
-
| `fetch` | `typeof fetch` | global `fetch` | Inject a custom `fetch` implementation. |
|
|
36
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/integrations/perplexity/CHANGELOG.md) for version history and release notes.
|
|
76
37
|
|
|
77
|
-
##
|
|
38
|
+
## Support
|
|
78
39
|
|
|
79
|
-
|
|
40
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/perplexity",
|
|
3
|
-
"version": "0.2.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Perplexity Search tool for Mastra agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"typescript": "^7.0.2",
|
|
51
51
|
"vitest": "4.1.10",
|
|
52
52
|
"zod": "^4.4.3",
|
|
53
|
-
"@internal/
|
|
54
|
-
"@internal/
|
|
55
|
-
"@mastra/core": "1.64.0
|
|
53
|
+
"@internal/types-builder": "0.0.105",
|
|
54
|
+
"@internal/lint": "0.0.130",
|
|
55
|
+
"@mastra/core": "1.64.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build:lib": "tsdown --silent --config tsdown.config.ts",
|