@pitcher/js-api 1.27.2 → 1.27.3
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/js-api.esm.js +12 -13
- package/js-api.esm.js.map +1 -1
- package/js-api.umd.min.js +5 -5
- package/js-api.umd.min.js.map +1 -1
- package/package.json +1 -1
package/js-api.esm.js
CHANGED
|
@@ -2476,9 +2476,8 @@ async function piaSearchAnswer(payload) {
|
|
|
2476
2476
|
}
|
|
2477
2477
|
const controller = new AbortController();
|
|
2478
2478
|
const timer = setTimeout(() => controller.abort(), ONLINE_TIMEOUT_MS);
|
|
2479
|
-
let response;
|
|
2480
2479
|
try {
|
|
2481
|
-
response = await fetch(`${apiOriginFromEnv(env)}${PIA_SEARCH_ROUTE}`, {
|
|
2480
|
+
const response = await fetch(`${apiOriginFromEnv(env)}${PIA_SEARCH_ROUTE}`, {
|
|
2482
2481
|
method: "POST",
|
|
2483
2482
|
signal: controller.signal,
|
|
2484
2483
|
headers: {
|
|
@@ -2491,6 +2490,17 @@ async function piaSearchAnswer(payload) {
|
|
|
2491
2490
|
...Array.isArray(payload.file_ids) && payload.file_ids.length > 0 && { file_ids: payload.file_ids }
|
|
2492
2491
|
})
|
|
2493
2492
|
});
|
|
2493
|
+
if (!response.ok) {
|
|
2494
|
+
throw new Error(`pia_search ${response.status}`);
|
|
2495
|
+
}
|
|
2496
|
+
const data = await response.json();
|
|
2497
|
+
const output = data?.pia_search ?? {};
|
|
2498
|
+
return {
|
|
2499
|
+
answer: typeof output.answer === "string" ? output.answer : "",
|
|
2500
|
+
cited_file_ids: Array.isArray(output.cited_file_ids) ? output.cited_file_ids : [],
|
|
2501
|
+
...output.confidence && { confidence: output.confidence },
|
|
2502
|
+
source: "online"
|
|
2503
|
+
};
|
|
2494
2504
|
} catch (error) {
|
|
2495
2505
|
if (error?.name === "AbortError") {
|
|
2496
2506
|
throw new Error(`pia_search online request timed out after ${ONLINE_TIMEOUT_MS}ms`);
|
|
@@ -2499,17 +2509,6 @@ async function piaSearchAnswer(payload) {
|
|
|
2499
2509
|
} finally {
|
|
2500
2510
|
clearTimeout(timer);
|
|
2501
2511
|
}
|
|
2502
|
-
if (!response.ok) {
|
|
2503
|
-
throw new Error(`pia_search ${response.status}`);
|
|
2504
|
-
}
|
|
2505
|
-
const data = await response.json();
|
|
2506
|
-
const output = data?.pia_search ?? {};
|
|
2507
|
-
return {
|
|
2508
|
-
answer: typeof output.answer === "string" ? output.answer : "",
|
|
2509
|
-
cited_file_ids: Array.isArray(output.cited_file_ids) ? output.cited_file_ids : [],
|
|
2510
|
-
...output.confidence && { confidence: output.confidence },
|
|
2511
|
-
source: "online"
|
|
2512
|
-
};
|
|
2513
2512
|
}
|
|
2514
2513
|
|
|
2515
2514
|
function open$2(payload = {}) {
|