risicare 0.9.1 → 0.10.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/CHANGELOG.md +1419 -0
- package/README.md +37 -19
- package/dist/frameworks/instructor.cjs +65 -5
- package/dist/frameworks/instructor.cjs.map +1 -1
- package/dist/frameworks/instructor.js +65 -5
- package/dist/frameworks/instructor.js.map +1 -1
- package/dist/frameworks/langchain.cjs +65 -5
- package/dist/frameworks/langchain.cjs.map +1 -1
- package/dist/frameworks/langchain.js +65 -5
- package/dist/frameworks/langchain.js.map +1 -1
- package/dist/frameworks/langgraph.cjs +65 -5
- package/dist/frameworks/langgraph.cjs.map +1 -1
- package/dist/frameworks/langgraph.js +65 -5
- package/dist/frameworks/langgraph.js.map +1 -1
- package/dist/frameworks/llamaindex.cjs +65 -5
- package/dist/frameworks/llamaindex.cjs.map +1 -1
- package/dist/frameworks/llamaindex.js +65 -5
- package/dist/frameworks/llamaindex.js.map +1 -1
- package/dist/index.cjs +405 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +405 -27
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic/index.cjs +141 -13
- package/dist/providers/anthropic/index.cjs.map +1 -1
- package/dist/providers/anthropic/index.d.cts +3 -0
- package/dist/providers/anthropic/index.d.ts +3 -0
- package/dist/providers/anthropic/index.js +141 -13
- package/dist/providers/anthropic/index.js.map +1 -1
- package/dist/providers/bedrock/index.cjs +88 -9
- package/dist/providers/bedrock/index.cjs.map +1 -1
- package/dist/providers/bedrock/index.d.cts +3 -0
- package/dist/providers/bedrock/index.d.ts +3 -0
- package/dist/providers/bedrock/index.js +88 -9
- package/dist/providers/bedrock/index.js.map +1 -1
- package/dist/providers/cerebras/index.cjs +88 -9
- package/dist/providers/cerebras/index.cjs.map +1 -1
- package/dist/providers/cerebras/index.d.cts +3 -0
- package/dist/providers/cerebras/index.d.ts +3 -0
- package/dist/providers/cerebras/index.js +88 -9
- package/dist/providers/cerebras/index.js.map +1 -1
- package/dist/providers/cohere/index.cjs +88 -9
- package/dist/providers/cohere/index.cjs.map +1 -1
- package/dist/providers/cohere/index.d.cts +3 -0
- package/dist/providers/cohere/index.d.ts +3 -0
- package/dist/providers/cohere/index.js +88 -9
- package/dist/providers/cohere/index.js.map +1 -1
- package/dist/providers/google/index.cjs +88 -9
- package/dist/providers/google/index.cjs.map +1 -1
- package/dist/providers/google/index.d.cts +3 -0
- package/dist/providers/google/index.d.ts +3 -0
- package/dist/providers/google/index.js +88 -9
- package/dist/providers/google/index.js.map +1 -1
- package/dist/providers/groq/index.cjs +88 -9
- package/dist/providers/groq/index.cjs.map +1 -1
- package/dist/providers/groq/index.d.cts +3 -0
- package/dist/providers/groq/index.d.ts +3 -0
- package/dist/providers/groq/index.js +88 -9
- package/dist/providers/groq/index.js.map +1 -1
- package/dist/providers/huggingface/index.cjs +86 -8
- package/dist/providers/huggingface/index.cjs.map +1 -1
- package/dist/providers/huggingface/index.js +86 -8
- package/dist/providers/huggingface/index.js.map +1 -1
- package/dist/providers/mistral/index.cjs +88 -9
- package/dist/providers/mistral/index.cjs.map +1 -1
- package/dist/providers/mistral/index.d.cts +3 -0
- package/dist/providers/mistral/index.d.ts +3 -0
- package/dist/providers/mistral/index.js +88 -9
- package/dist/providers/mistral/index.js.map +1 -1
- package/dist/providers/ollama/index.cjs +88 -9
- package/dist/providers/ollama/index.cjs.map +1 -1
- package/dist/providers/ollama/index.d.cts +3 -0
- package/dist/providers/ollama/index.d.ts +3 -0
- package/dist/providers/ollama/index.js +88 -9
- package/dist/providers/ollama/index.js.map +1 -1
- package/dist/providers/openai/index.cjs +126 -11
- package/dist/providers/openai/index.cjs.map +1 -1
- package/dist/providers/openai/index.d.cts +3 -0
- package/dist/providers/openai/index.d.ts +3 -0
- package/dist/providers/openai/index.js +126 -11
- package/dist/providers/openai/index.js.map +1 -1
- package/dist/providers/together/index.cjs +88 -9
- package/dist/providers/together/index.cjs.map +1 -1
- package/dist/providers/together/index.d.cts +3 -0
- package/dist/providers/together/index.d.ts +3 -0
- package/dist/providers/together/index.js +88 -9
- package/dist/providers/together/index.js.map +1 -1
- package/dist/providers/vercel-ai/index.cjs +67 -7
- package/dist/providers/vercel-ai/index.cjs.map +1 -1
- package/dist/providers/vercel-ai/index.js +67 -7
- package/dist/providers/vercel-ai/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -95,6 +95,51 @@ function hasCredentials(url) {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// src/masking.ts
|
|
99
|
+
var CONTENT_IN_JSON_OBJECT = /* @__PURE__ */ new Map([
|
|
100
|
+
[
|
|
101
|
+
"llm.invocation_parameters",
|
|
102
|
+
/* @__PURE__ */ new Set([
|
|
103
|
+
"additionalinstructions",
|
|
104
|
+
// OpenAI assistants run
|
|
105
|
+
"chathistory",
|
|
106
|
+
// Cohere
|
|
107
|
+
"contents",
|
|
108
|
+
// Gemini
|
|
109
|
+
"documents",
|
|
110
|
+
// Cohere RAG
|
|
111
|
+
"functions",
|
|
112
|
+
"input",
|
|
113
|
+
"inputtext",
|
|
114
|
+
// Bedrock Titan
|
|
115
|
+
"instructions",
|
|
116
|
+
"message",
|
|
117
|
+
// Cohere
|
|
118
|
+
"messages",
|
|
119
|
+
"preamble",
|
|
120
|
+
// Cohere
|
|
121
|
+
"prediction",
|
|
122
|
+
// OpenAI predicted output
|
|
123
|
+
"prompt",
|
|
124
|
+
"system",
|
|
125
|
+
// Anthropic
|
|
126
|
+
"systeminstruction",
|
|
127
|
+
// Gemini
|
|
128
|
+
"texts",
|
|
129
|
+
// Cohere embed
|
|
130
|
+
"toolconfig",
|
|
131
|
+
// Gemini
|
|
132
|
+
"tools"
|
|
133
|
+
])
|
|
134
|
+
]
|
|
135
|
+
]);
|
|
136
|
+
var VALUE_RULE_PREFIXES = new Set(
|
|
137
|
+
[...CONTENT_IN_JSON_OBJECT.keys()].flatMap((key) => {
|
|
138
|
+
const segments = key.split(".");
|
|
139
|
+
return segments.slice(1).map((_, i) => segments.slice(0, i + 1).join("."));
|
|
140
|
+
})
|
|
141
|
+
);
|
|
142
|
+
|
|
98
143
|
// src/exporters/batch.ts
|
|
99
144
|
var MAX_TIMEOUT_MS = 2 ** 31 - 1;
|
|
100
145
|
var MAX_BATCH_BYTES = 8 * 1024 * 1024;
|
|
@@ -231,7 +276,7 @@ var SUPPLEMENTAL_RULES = [
|
|
|
231
276
|
];
|
|
232
277
|
|
|
233
278
|
// src/version.ts
|
|
234
|
-
var SDK_VERSION = "0.
|
|
279
|
+
var SDK_VERSION = "0.10.0";
|
|
235
280
|
|
|
236
281
|
// src/exporters/quota.ts
|
|
237
282
|
var QUOTA_REASON = "monthly_quota_exceeded";
|
|
@@ -376,6 +421,8 @@ var HttpExporter = class {
|
|
|
376
421
|
_calls = /* @__PURE__ */ new Map();
|
|
377
422
|
/** The ack of each finished call, by its batch. Read once by `takeAck(spans)`. */
|
|
378
423
|
_acks = /* @__PURE__ */ new WeakMap();
|
|
424
|
+
/** The requests that each finished call sent, by its batch. Read once by `takeAttempts(spans)`. */
|
|
425
|
+
_requests = /* @__PURE__ */ new WeakMap();
|
|
379
426
|
/** The batch processor dropped span(s) from a full queue in the quota pause (S-1). */
|
|
380
427
|
noteQuotaDrop(count = 1) {
|
|
381
428
|
this._quota.addDrops(count);
|
|
@@ -427,6 +474,18 @@ var HttpExporter = class {
|
|
|
427
474
|
get attemptsPerExport() {
|
|
428
475
|
return this._maxRetries;
|
|
429
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Returns the number of HTTP requests that the `export()` call for `spans` sent, and clears
|
|
479
|
+
* it. This is the number that was sent, not the most that the call may send
|
|
480
|
+
* (`attemptsPerExport`): a 401 or 403 stops the loop after one request, and an open circuit
|
|
481
|
+
* breaker sends none. Returns `null` when no call is on record for `spans`. The answer is
|
|
482
|
+
* kept per batch, as `takeAck` keeps the ack.
|
|
483
|
+
*/
|
|
484
|
+
takeAttempts(spans) {
|
|
485
|
+
const n = this._requests.get(spans) ?? null;
|
|
486
|
+
this._requests.delete(spans);
|
|
487
|
+
return n;
|
|
488
|
+
}
|
|
430
489
|
/**
|
|
431
490
|
* Returns the counts of the ack that the `export()` call for `spans` received, and clears
|
|
432
491
|
* them. The answer is kept per batch, not on the instance: two processors that share this
|
|
@@ -471,13 +530,15 @@ var HttpExporter = class {
|
|
|
471
530
|
misroute: null,
|
|
472
531
|
noRetry: false,
|
|
473
532
|
status: null,
|
|
474
|
-
error: null
|
|
533
|
+
error: null,
|
|
534
|
+
attempts: 0
|
|
475
535
|
};
|
|
476
536
|
this._calls.set(spans, call);
|
|
477
537
|
try {
|
|
478
538
|
return await this._export(spans, call);
|
|
479
539
|
} finally {
|
|
480
540
|
this._calls.delete(spans);
|
|
541
|
+
this._requests.set(spans, this._endpointHasCredentials ? 0 : call.attempts);
|
|
481
542
|
}
|
|
482
543
|
}
|
|
483
544
|
async _export(spans, call) {
|
|
@@ -517,14 +578,13 @@ var HttpExporter = class {
|
|
|
517
578
|
isHalfOpen = true;
|
|
518
579
|
}
|
|
519
580
|
const maxAttempts = isHalfOpen ? 1 : this._maxRetries;
|
|
520
|
-
let attempts = 0;
|
|
521
581
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
522
582
|
call.refusalAfterMs = null;
|
|
523
583
|
call.misroute = null;
|
|
524
584
|
call.noRetry = false;
|
|
525
585
|
call.status = null;
|
|
526
586
|
call.error = null;
|
|
527
|
-
attempts++;
|
|
587
|
+
call.attempts++;
|
|
528
588
|
const result = await this._sendRequest(payload, parts.length, call, spans);
|
|
529
589
|
if (cancelled.aborted) {
|
|
530
590
|
this._acks.delete(spans);
|
|
@@ -546,7 +606,7 @@ var HttpExporter = class {
|
|
|
546
606
|
}
|
|
547
607
|
if (call.refusalAfterMs !== null) {
|
|
548
608
|
warn(
|
|
549
|
-
`Risicare: the ingest endpoint refused this batch for capacity (HTTP 429/503) after ${attempts} attempt(s). This is a healthy server shedding load, not an outage. This export of the batch failed; the circuit breaker does not count it. Reduce batch size or export rate if it persists.`
|
|
609
|
+
`Risicare: the ingest endpoint refused this batch for capacity (HTTP 429/503) after ${call.attempts} attempt(s). This is a healthy server shedding load, not an outage. This export of the batch failed; the circuit breaker does not count it. Reduce batch size or export rate if it persists.`
|
|
550
610
|
);
|
|
551
611
|
return "failure" /* FAILURE */;
|
|
552
612
|
}
|