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
|
@@ -108,6 +108,51 @@ function hasCredentials(url) {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
// src/masking.ts
|
|
112
|
+
var CONTENT_IN_JSON_OBJECT = /* @__PURE__ */ new Map([
|
|
113
|
+
[
|
|
114
|
+
"llm.invocation_parameters",
|
|
115
|
+
/* @__PURE__ */ new Set([
|
|
116
|
+
"additionalinstructions",
|
|
117
|
+
// OpenAI assistants run
|
|
118
|
+
"chathistory",
|
|
119
|
+
// Cohere
|
|
120
|
+
"contents",
|
|
121
|
+
// Gemini
|
|
122
|
+
"documents",
|
|
123
|
+
// Cohere RAG
|
|
124
|
+
"functions",
|
|
125
|
+
"input",
|
|
126
|
+
"inputtext",
|
|
127
|
+
// Bedrock Titan
|
|
128
|
+
"instructions",
|
|
129
|
+
"message",
|
|
130
|
+
// Cohere
|
|
131
|
+
"messages",
|
|
132
|
+
"preamble",
|
|
133
|
+
// Cohere
|
|
134
|
+
"prediction",
|
|
135
|
+
// OpenAI predicted output
|
|
136
|
+
"prompt",
|
|
137
|
+
"system",
|
|
138
|
+
// Anthropic
|
|
139
|
+
"systeminstruction",
|
|
140
|
+
// Gemini
|
|
141
|
+
"texts",
|
|
142
|
+
// Cohere embed
|
|
143
|
+
"toolconfig",
|
|
144
|
+
// Gemini
|
|
145
|
+
"tools"
|
|
146
|
+
])
|
|
147
|
+
]
|
|
148
|
+
]);
|
|
149
|
+
var VALUE_RULE_PREFIXES = new Set(
|
|
150
|
+
[...CONTENT_IN_JSON_OBJECT.keys()].flatMap((key) => {
|
|
151
|
+
const segments = key.split(".");
|
|
152
|
+
return segments.slice(1).map((_, i) => segments.slice(0, i + 1).join("."));
|
|
153
|
+
})
|
|
154
|
+
);
|
|
155
|
+
|
|
111
156
|
// src/exporters/batch.ts
|
|
112
157
|
var MAX_TIMEOUT_MS = 2 ** 31 - 1;
|
|
113
158
|
var MAX_BATCH_BYTES = 8 * 1024 * 1024;
|
|
@@ -257,7 +302,7 @@ function runWithContext(overrides, fn) {
|
|
|
257
302
|
}
|
|
258
303
|
|
|
259
304
|
// src/version.ts
|
|
260
|
-
var SDK_VERSION = "0.
|
|
305
|
+
var SDK_VERSION = "0.10.0";
|
|
261
306
|
|
|
262
307
|
// src/exporters/quota.ts
|
|
263
308
|
var QUOTA_REASON = "monthly_quota_exceeded";
|
|
@@ -402,6 +447,8 @@ var HttpExporter = class {
|
|
|
402
447
|
_calls = /* @__PURE__ */ new Map();
|
|
403
448
|
/** The ack of each finished call, by its batch. Read once by `takeAck(spans)`. */
|
|
404
449
|
_acks = /* @__PURE__ */ new WeakMap();
|
|
450
|
+
/** The requests that each finished call sent, by its batch. Read once by `takeAttempts(spans)`. */
|
|
451
|
+
_requests = /* @__PURE__ */ new WeakMap();
|
|
405
452
|
/** The batch processor dropped span(s) from a full queue in the quota pause (S-1). */
|
|
406
453
|
noteQuotaDrop(count = 1) {
|
|
407
454
|
this._quota.addDrops(count);
|
|
@@ -453,6 +500,18 @@ var HttpExporter = class {
|
|
|
453
500
|
get attemptsPerExport() {
|
|
454
501
|
return this._maxRetries;
|
|
455
502
|
}
|
|
503
|
+
/**
|
|
504
|
+
* Returns the number of HTTP requests that the `export()` call for `spans` sent, and clears
|
|
505
|
+
* it. This is the number that was sent, not the most that the call may send
|
|
506
|
+
* (`attemptsPerExport`): a 401 or 403 stops the loop after one request, and an open circuit
|
|
507
|
+
* breaker sends none. Returns `null` when no call is on record for `spans`. The answer is
|
|
508
|
+
* kept per batch, as `takeAck` keeps the ack.
|
|
509
|
+
*/
|
|
510
|
+
takeAttempts(spans) {
|
|
511
|
+
const n = this._requests.get(spans) ?? null;
|
|
512
|
+
this._requests.delete(spans);
|
|
513
|
+
return n;
|
|
514
|
+
}
|
|
456
515
|
/**
|
|
457
516
|
* Returns the counts of the ack that the `export()` call for `spans` received, and clears
|
|
458
517
|
* them. The answer is kept per batch, not on the instance: two processors that share this
|
|
@@ -497,13 +556,15 @@ var HttpExporter = class {
|
|
|
497
556
|
misroute: null,
|
|
498
557
|
noRetry: false,
|
|
499
558
|
status: null,
|
|
500
|
-
error: null
|
|
559
|
+
error: null,
|
|
560
|
+
attempts: 0
|
|
501
561
|
};
|
|
502
562
|
this._calls.set(spans, call);
|
|
503
563
|
try {
|
|
504
564
|
return await this._export(spans, call);
|
|
505
565
|
} finally {
|
|
506
566
|
this._calls.delete(spans);
|
|
567
|
+
this._requests.set(spans, this._endpointHasCredentials ? 0 : call.attempts);
|
|
507
568
|
}
|
|
508
569
|
}
|
|
509
570
|
async _export(spans, call) {
|
|
@@ -543,14 +604,13 @@ var HttpExporter = class {
|
|
|
543
604
|
isHalfOpen = true;
|
|
544
605
|
}
|
|
545
606
|
const maxAttempts = isHalfOpen ? 1 : this._maxRetries;
|
|
546
|
-
let attempts = 0;
|
|
547
607
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
548
608
|
call.refusalAfterMs = null;
|
|
549
609
|
call.misroute = null;
|
|
550
610
|
call.noRetry = false;
|
|
551
611
|
call.status = null;
|
|
552
612
|
call.error = null;
|
|
553
|
-
attempts++;
|
|
613
|
+
call.attempts++;
|
|
554
614
|
const result = await this._sendRequest(payload, parts.length, call, spans);
|
|
555
615
|
if (cancelled.aborted) {
|
|
556
616
|
this._acks.delete(spans);
|
|
@@ -572,7 +632,7 @@ var HttpExporter = class {
|
|
|
572
632
|
}
|
|
573
633
|
if (call.refusalAfterMs !== null) {
|
|
574
634
|
warn(
|
|
575
|
-
`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.`
|
|
635
|
+
`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.`
|
|
576
636
|
);
|
|
577
637
|
return "failure" /* FAILURE */;
|
|
578
638
|
}
|