@normful/parallel-web-pi-extension 1.0.0 → 1.1.0
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 +18 -0
- package/package.json +2 -1
- package/src/parallel-responses.ts +24 -2
package/README.md
CHANGED
|
@@ -196,6 +196,24 @@ pi --no-extensions --no-skills -e ./src/index.ts
|
|
|
196
196
|
|
|
197
197
|
This changes the browser login endpoints used by `/login parallel`.
|
|
198
198
|
|
|
199
|
+
### Override The API Base URL
|
|
200
|
+
|
|
201
|
+
`PARALLEL_BASE_URL` redirects every Parallel API call the tools make — search,
|
|
202
|
+
extract and research all follow it, so they can be pointed at a staging or local
|
|
203
|
+
host together:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
export PARALLEL_BASE_URL=https://your-api-host
|
|
207
|
+
pi --no-extensions --no-skills -e ./src/index.ts
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The value is an **origin**, not a full URL: the `/v1/search`, `/v1/extract` and
|
|
211
|
+
`/v1/responses` paths are appended to it, and a trailing slash is tolerated.
|
|
212
|
+
Unset it to use `https://api.parallel.ai`.
|
|
213
|
+
|
|
214
|
+
This is separate from `PARALLEL_PLATFORM_URL`, which only affects the OAuth
|
|
215
|
+
login flow (that host is `platform.parallel.ai`, not `api.parallel.ai`).
|
|
216
|
+
|
|
199
217
|
## Quick Smoke Test
|
|
200
218
|
|
|
201
219
|
Once Pi is running with the extension loaded, ask something that should force web usage, for example:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@normful/parallel-web-pi-extension",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Add Parallel web search, fetch, and research tools to your pi agent",
|
|
5
5
|
"author": "Norman Sue",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"test": "vitest run",
|
|
40
|
+
"coverage": "vitest run --coverage",
|
|
40
41
|
"typecheck": "tsc --noEmit",
|
|
41
42
|
"lint": "eslint .",
|
|
42
43
|
"lint:fix": "eslint . --fix",
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import pkg from '../package.json' with { type: 'json' };
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Default API origin used when PARALLEL_BASE_URL is unset. Matches the value
|
|
5
|
+
* hardcoded into the parallel-web SDK, so a single variable can point every
|
|
6
|
+
* web tool at the same host.
|
|
7
|
+
*/
|
|
8
|
+
export const PARALLEL_API_ORIGIN = 'https://api.parallel.ai';
|
|
9
|
+
export const PARALLEL_RESPONSES_PATH = '/v1/responses';
|
|
10
|
+
/** Responses endpoint on the default origin. */
|
|
11
|
+
export const PARALLEL_RESPONSES_URL = `${PARALLEL_API_ORIGIN}${PARALLEL_RESPONSES_PATH}`;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the Responses endpoint, honoring PARALLEL_BASE_URL exactly as the
|
|
15
|
+
* parallel-web SDK does for web_search and web_fetch. The value is an origin:
|
|
16
|
+
* the `/v1/...` path is always appended, and a trailing slash is tolerated.
|
|
17
|
+
*/
|
|
18
|
+
export function resolveParallelResponsesUrl(
|
|
19
|
+
baseUrl: string | undefined = process.env.PARALLEL_BASE_URL
|
|
20
|
+
) {
|
|
21
|
+
const origin = baseUrl?.trim().replace(/\/+$/, '');
|
|
22
|
+
return origin
|
|
23
|
+
? `${origin}${PARALLEL_RESPONSES_PATH}`
|
|
24
|
+
: PARALLEL_RESPONSES_URL;
|
|
25
|
+
}
|
|
4
26
|
export const PARALLEL_RESPONSES_MAX_INPUT_CHARS = 20_000;
|
|
5
27
|
export const PARALLEL_RESPONSES_TIMEOUT_MS = 120_000;
|
|
6
28
|
export const DEFAULT_RESEARCH_EFFORT = 'medium';
|
|
@@ -217,7 +239,7 @@ export async function runParallelResearch(
|
|
|
217
239
|
timeout.unref?.();
|
|
218
240
|
try {
|
|
219
241
|
requestSignal.throwIfAborted();
|
|
220
|
-
const response = await fetch(
|
|
242
|
+
const response = await fetch(resolveParallelResponsesUrl(), {
|
|
221
243
|
method: 'POST',
|
|
222
244
|
headers: {
|
|
223
245
|
Authorization: `Bearer ${apiKey}`,
|