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
|
@@ -137,6 +137,51 @@ function hasCredentials(url) {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
// src/masking.ts
|
|
141
|
+
var CONTENT_IN_JSON_OBJECT = /* @__PURE__ */ new Map([
|
|
142
|
+
[
|
|
143
|
+
"llm.invocation_parameters",
|
|
144
|
+
/* @__PURE__ */ new Set([
|
|
145
|
+
"additionalinstructions",
|
|
146
|
+
// OpenAI assistants run
|
|
147
|
+
"chathistory",
|
|
148
|
+
// Cohere
|
|
149
|
+
"contents",
|
|
150
|
+
// Gemini
|
|
151
|
+
"documents",
|
|
152
|
+
// Cohere RAG
|
|
153
|
+
"functions",
|
|
154
|
+
"input",
|
|
155
|
+
"inputtext",
|
|
156
|
+
// Bedrock Titan
|
|
157
|
+
"instructions",
|
|
158
|
+
"message",
|
|
159
|
+
// Cohere
|
|
160
|
+
"messages",
|
|
161
|
+
"preamble",
|
|
162
|
+
// Cohere
|
|
163
|
+
"prediction",
|
|
164
|
+
// OpenAI predicted output
|
|
165
|
+
"prompt",
|
|
166
|
+
"system",
|
|
167
|
+
// Anthropic
|
|
168
|
+
"systeminstruction",
|
|
169
|
+
// Gemini
|
|
170
|
+
"texts",
|
|
171
|
+
// Cohere embed
|
|
172
|
+
"toolconfig",
|
|
173
|
+
// Gemini
|
|
174
|
+
"tools"
|
|
175
|
+
])
|
|
176
|
+
]
|
|
177
|
+
]);
|
|
178
|
+
var VALUE_RULE_PREFIXES = new Set(
|
|
179
|
+
[...CONTENT_IN_JSON_OBJECT.keys()].flatMap((key) => {
|
|
180
|
+
const segments = key.split(".");
|
|
181
|
+
return segments.slice(1).map((_, i) => segments.slice(0, i + 1).join("."));
|
|
182
|
+
})
|
|
183
|
+
);
|
|
184
|
+
|
|
140
185
|
// src/exporters/batch.ts
|
|
141
186
|
var MAX_TIMEOUT_MS = 2 ** 31 - 1;
|
|
142
187
|
var MAX_BATCH_BYTES = 8 * 1024 * 1024;
|
|
@@ -286,7 +331,7 @@ function runWithContext(overrides, fn) {
|
|
|
286
331
|
}
|
|
287
332
|
|
|
288
333
|
// src/version.ts
|
|
289
|
-
var SDK_VERSION = "0.
|
|
334
|
+
var SDK_VERSION = "0.10.0";
|
|
290
335
|
|
|
291
336
|
// src/exporters/quota.ts
|
|
292
337
|
var QUOTA_REASON = "monthly_quota_exceeded";
|
|
@@ -431,6 +476,8 @@ var HttpExporter = class {
|
|
|
431
476
|
_calls = /* @__PURE__ */ new Map();
|
|
432
477
|
/** The ack of each finished call, by its batch. Read once by `takeAck(spans)`. */
|
|
433
478
|
_acks = /* @__PURE__ */ new WeakMap();
|
|
479
|
+
/** The requests that each finished call sent, by its batch. Read once by `takeAttempts(spans)`. */
|
|
480
|
+
_requests = /* @__PURE__ */ new WeakMap();
|
|
434
481
|
/** The batch processor dropped span(s) from a full queue in the quota pause (S-1). */
|
|
435
482
|
noteQuotaDrop(count = 1) {
|
|
436
483
|
this._quota.addDrops(count);
|
|
@@ -482,6 +529,18 @@ var HttpExporter = class {
|
|
|
482
529
|
get attemptsPerExport() {
|
|
483
530
|
return this._maxRetries;
|
|
484
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* Returns the number of HTTP requests that the `export()` call for `spans` sent, and clears
|
|
534
|
+
* it. This is the number that was sent, not the most that the call may send
|
|
535
|
+
* (`attemptsPerExport`): a 401 or 403 stops the loop after one request, and an open circuit
|
|
536
|
+
* breaker sends none. Returns `null` when no call is on record for `spans`. The answer is
|
|
537
|
+
* kept per batch, as `takeAck` keeps the ack.
|
|
538
|
+
*/
|
|
539
|
+
takeAttempts(spans) {
|
|
540
|
+
const n = this._requests.get(spans) ?? null;
|
|
541
|
+
this._requests.delete(spans);
|
|
542
|
+
return n;
|
|
543
|
+
}
|
|
485
544
|
/**
|
|
486
545
|
* Returns the counts of the ack that the `export()` call for `spans` received, and clears
|
|
487
546
|
* them. The answer is kept per batch, not on the instance: two processors that share this
|
|
@@ -526,13 +585,15 @@ var HttpExporter = class {
|
|
|
526
585
|
misroute: null,
|
|
527
586
|
noRetry: false,
|
|
528
587
|
status: null,
|
|
529
|
-
error: null
|
|
588
|
+
error: null,
|
|
589
|
+
attempts: 0
|
|
530
590
|
};
|
|
531
591
|
this._calls.set(spans, call);
|
|
532
592
|
try {
|
|
533
593
|
return await this._export(spans, call);
|
|
534
594
|
} finally {
|
|
535
595
|
this._calls.delete(spans);
|
|
596
|
+
this._requests.set(spans, this._endpointHasCredentials ? 0 : call.attempts);
|
|
536
597
|
}
|
|
537
598
|
}
|
|
538
599
|
async _export(spans, call) {
|
|
@@ -572,14 +633,13 @@ var HttpExporter = class {
|
|
|
572
633
|
isHalfOpen = true;
|
|
573
634
|
}
|
|
574
635
|
const maxAttempts = isHalfOpen ? 1 : this._maxRetries;
|
|
575
|
-
let attempts = 0;
|
|
576
636
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
577
637
|
call.refusalAfterMs = null;
|
|
578
638
|
call.misroute = null;
|
|
579
639
|
call.noRetry = false;
|
|
580
640
|
call.status = null;
|
|
581
641
|
call.error = null;
|
|
582
|
-
attempts++;
|
|
642
|
+
call.attempts++;
|
|
583
643
|
const result = await this._sendRequest(payload, parts.length, call, spans);
|
|
584
644
|
if (cancelled.aborted) {
|
|
585
645
|
this._acks.delete(spans);
|
|
@@ -601,7 +661,7 @@ var HttpExporter = class {
|
|
|
601
661
|
}
|
|
602
662
|
if (call.refusalAfterMs !== null) {
|
|
603
663
|
warn(
|
|
604
|
-
`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.`
|
|
664
|
+
`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.`
|
|
605
665
|
);
|
|
606
666
|
return "failure" /* FAILURE */;
|
|
607
667
|
}
|