@broberg/ai-sdk 0.62.1 → 0.62.2
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/dist/index.d.ts +2 -2
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2334,8 +2334,8 @@ declare const falStubAdapter: ProviderAdapter;
|
|
|
2334
2334
|
* wires the live adapters. */
|
|
2335
2335
|
declare const stubProviders: Record<string, ProviderAdapter>;
|
|
2336
2336
|
|
|
2337
|
-
declare const VERSION: "0.62.
|
|
2338
|
-
declare const SDK_TAG: "@broberg/ai-sdk@0.62.
|
|
2337
|
+
declare const VERSION: "0.62.2";
|
|
2338
|
+
declare const SDK_TAG: "@broberg/ai-sdk@0.62.2";
|
|
2339
2339
|
|
|
2340
2340
|
/** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
|
|
2341
2341
|
* per-call override.
|
package/dist/index.js
CHANGED
|
@@ -340,11 +340,13 @@ async function search(req, opts = {}) {
|
|
|
340
340
|
const nowMs = () => (opts.now ?? (() => /* @__PURE__ */ new Date()))().getTime();
|
|
341
341
|
let lastErr;
|
|
342
342
|
for (const [i, provider] of chain.entries()) {
|
|
343
|
-
const coolKey = cooldownKey(provider, opts);
|
|
344
|
-
if (i < chain.length - 1 && (coolingUntil.get(coolKey) ?? 0) > nowMs()) continue;
|
|
345
343
|
const key = searchCacheKey(provider, req);
|
|
346
344
|
const hit = cache?.get(key);
|
|
347
345
|
if (hit) return { items: hit.items, meta: { ...hit.meta, cached: true, costUsd: 0, latencyMs: 0 } };
|
|
346
|
+
const coolKey = cooldownKey(provider, opts);
|
|
347
|
+
const until = coolingUntil.get(coolKey);
|
|
348
|
+
if (until !== void 0 && until <= nowMs()) coolingUntil.delete(coolKey);
|
|
349
|
+
else if (until !== void 0 && i < chain.length - 1) continue;
|
|
348
350
|
const price = SEARCH_PRICE_USD[provider];
|
|
349
351
|
const cap = opts.dailyCapUsd ?? Infinity;
|
|
350
352
|
if (!await capStore.reserve(capKey, price, cap)) {
|
|
@@ -3916,8 +3918,8 @@ var aiConfigSchema = z.object({
|
|
|
3916
3918
|
import { randomUUID } from "crypto";
|
|
3917
3919
|
|
|
3918
3920
|
// src/version.ts
|
|
3919
|
-
var VERSION = "0.62.
|
|
3920
|
-
var SDK_TAG = "@broberg/ai-sdk@0.62.
|
|
3921
|
+
var VERSION = "0.62.2";
|
|
3922
|
+
var SDK_TAG = "@broberg/ai-sdk@0.62.2";
|
|
3921
3923
|
|
|
3922
3924
|
// src/cost/sinks/upmetrics.ts
|
|
3923
3925
|
function isRetryableStatus(status) {
|