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
|
@@ -101,6 +101,51 @@ function hasCredentials(url) {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
// src/masking.ts
|
|
105
|
+
var CONTENT_IN_JSON_OBJECT = /* @__PURE__ */ new Map([
|
|
106
|
+
[
|
|
107
|
+
"llm.invocation_parameters",
|
|
108
|
+
/* @__PURE__ */ new Set([
|
|
109
|
+
"additionalinstructions",
|
|
110
|
+
// OpenAI assistants run
|
|
111
|
+
"chathistory",
|
|
112
|
+
// Cohere
|
|
113
|
+
"contents",
|
|
114
|
+
// Gemini
|
|
115
|
+
"documents",
|
|
116
|
+
// Cohere RAG
|
|
117
|
+
"functions",
|
|
118
|
+
"input",
|
|
119
|
+
"inputtext",
|
|
120
|
+
// Bedrock Titan
|
|
121
|
+
"instructions",
|
|
122
|
+
"message",
|
|
123
|
+
// Cohere
|
|
124
|
+
"messages",
|
|
125
|
+
"preamble",
|
|
126
|
+
// Cohere
|
|
127
|
+
"prediction",
|
|
128
|
+
// OpenAI predicted output
|
|
129
|
+
"prompt",
|
|
130
|
+
"system",
|
|
131
|
+
// Anthropic
|
|
132
|
+
"systeminstruction",
|
|
133
|
+
// Gemini
|
|
134
|
+
"texts",
|
|
135
|
+
// Cohere embed
|
|
136
|
+
"toolconfig",
|
|
137
|
+
// Gemini
|
|
138
|
+
"tools"
|
|
139
|
+
])
|
|
140
|
+
]
|
|
141
|
+
]);
|
|
142
|
+
var VALUE_RULE_PREFIXES = new Set(
|
|
143
|
+
[...CONTENT_IN_JSON_OBJECT.keys()].flatMap((key) => {
|
|
144
|
+
const segments = key.split(".");
|
|
145
|
+
return segments.slice(1).map((_, i) => segments.slice(0, i + 1).join("."));
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
|
|
104
149
|
// src/exporters/batch.ts
|
|
105
150
|
var MAX_TIMEOUT_MS = 2 ** 31 - 1;
|
|
106
151
|
var MAX_BATCH_BYTES = 8 * 1024 * 1024;
|
|
@@ -250,7 +295,7 @@ function runWithContext(overrides, fn) {
|
|
|
250
295
|
}
|
|
251
296
|
|
|
252
297
|
// src/version.ts
|
|
253
|
-
var SDK_VERSION = "0.
|
|
298
|
+
var SDK_VERSION = "0.10.0";
|
|
254
299
|
|
|
255
300
|
// src/exporters/quota.ts
|
|
256
301
|
var QUOTA_REASON = "monthly_quota_exceeded";
|
|
@@ -395,6 +440,8 @@ var HttpExporter = class {
|
|
|
395
440
|
_calls = /* @__PURE__ */ new Map();
|
|
396
441
|
/** The ack of each finished call, by its batch. Read once by `takeAck(spans)`. */
|
|
397
442
|
_acks = /* @__PURE__ */ new WeakMap();
|
|
443
|
+
/** The requests that each finished call sent, by its batch. Read once by `takeAttempts(spans)`. */
|
|
444
|
+
_requests = /* @__PURE__ */ new WeakMap();
|
|
398
445
|
/** The batch processor dropped span(s) from a full queue in the quota pause (S-1). */
|
|
399
446
|
noteQuotaDrop(count = 1) {
|
|
400
447
|
this._quota.addDrops(count);
|
|
@@ -446,6 +493,18 @@ var HttpExporter = class {
|
|
|
446
493
|
get attemptsPerExport() {
|
|
447
494
|
return this._maxRetries;
|
|
448
495
|
}
|
|
496
|
+
/**
|
|
497
|
+
* Returns the number of HTTP requests that the `export()` call for `spans` sent, and clears
|
|
498
|
+
* it. This is the number that was sent, not the most that the call may send
|
|
499
|
+
* (`attemptsPerExport`): a 401 or 403 stops the loop after one request, and an open circuit
|
|
500
|
+
* breaker sends none. Returns `null` when no call is on record for `spans`. The answer is
|
|
501
|
+
* kept per batch, as `takeAck` keeps the ack.
|
|
502
|
+
*/
|
|
503
|
+
takeAttempts(spans) {
|
|
504
|
+
const n = this._requests.get(spans) ?? null;
|
|
505
|
+
this._requests.delete(spans);
|
|
506
|
+
return n;
|
|
507
|
+
}
|
|
449
508
|
/**
|
|
450
509
|
* Returns the counts of the ack that the `export()` call for `spans` received, and clears
|
|
451
510
|
* them. The answer is kept per batch, not on the instance: two processors that share this
|
|
@@ -490,13 +549,15 @@ var HttpExporter = class {
|
|
|
490
549
|
misroute: null,
|
|
491
550
|
noRetry: false,
|
|
492
551
|
status: null,
|
|
493
|
-
error: null
|
|
552
|
+
error: null,
|
|
553
|
+
attempts: 0
|
|
494
554
|
};
|
|
495
555
|
this._calls.set(spans, call);
|
|
496
556
|
try {
|
|
497
557
|
return await this._export(spans, call);
|
|
498
558
|
} finally {
|
|
499
559
|
this._calls.delete(spans);
|
|
560
|
+
this._requests.set(spans, this._endpointHasCredentials ? 0 : call.attempts);
|
|
500
561
|
}
|
|
501
562
|
}
|
|
502
563
|
async _export(spans, call) {
|
|
@@ -536,14 +597,13 @@ var HttpExporter = class {
|
|
|
536
597
|
isHalfOpen = true;
|
|
537
598
|
}
|
|
538
599
|
const maxAttempts = isHalfOpen ? 1 : this._maxRetries;
|
|
539
|
-
let attempts = 0;
|
|
540
600
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
541
601
|
call.refusalAfterMs = null;
|
|
542
602
|
call.misroute = null;
|
|
543
603
|
call.noRetry = false;
|
|
544
604
|
call.status = null;
|
|
545
605
|
call.error = null;
|
|
546
|
-
attempts++;
|
|
606
|
+
call.attempts++;
|
|
547
607
|
const result = await this._sendRequest(payload, parts.length, call, spans);
|
|
548
608
|
if (cancelled.aborted) {
|
|
549
609
|
this._acks.delete(spans);
|
|
@@ -565,7 +625,7 @@ var HttpExporter = class {
|
|
|
565
625
|
}
|
|
566
626
|
if (call.refusalAfterMs !== null) {
|
|
567
627
|
warn(
|
|
568
|
-
`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.`
|
|
628
|
+
`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.`
|
|
569
629
|
);
|
|
570
630
|
return "failure" /* FAILURE */;
|
|
571
631
|
}
|