risicare 0.9.1 → 0.9.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/CHANGELOG.md +1236 -0
- package/dist/frameworks/instructor.cjs +20 -5
- package/dist/frameworks/instructor.cjs.map +1 -1
- package/dist/frameworks/instructor.js +20 -5
- package/dist/frameworks/instructor.js.map +1 -1
- package/dist/frameworks/langchain.cjs +20 -5
- package/dist/frameworks/langchain.cjs.map +1 -1
- package/dist/frameworks/langchain.js +20 -5
- package/dist/frameworks/langchain.js.map +1 -1
- package/dist/frameworks/langgraph.cjs +20 -5
- package/dist/frameworks/langgraph.cjs.map +1 -1
- package/dist/frameworks/langgraph.js +20 -5
- package/dist/frameworks/langgraph.js.map +1 -1
- package/dist/frameworks/llamaindex.cjs +20 -5
- package/dist/frameworks/llamaindex.cjs.map +1 -1
- package/dist/frameworks/llamaindex.js +20 -5
- package/dist/frameworks/llamaindex.js.map +1 -1
- package/dist/index.cjs +77 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +77 -13
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic/index.cjs +25 -6
- 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 +25 -6
- package/dist/providers/anthropic/index.js.map +1 -1
- package/dist/providers/bedrock/index.cjs +25 -6
- 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 +25 -6
- package/dist/providers/bedrock/index.js.map +1 -1
- package/dist/providers/cerebras/index.cjs +25 -6
- 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 +25 -6
- package/dist/providers/cerebras/index.js.map +1 -1
- package/dist/providers/cohere/index.cjs +25 -6
- 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 +25 -6
- package/dist/providers/cohere/index.js.map +1 -1
- package/dist/providers/google/index.cjs +25 -6
- 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 +25 -6
- package/dist/providers/google/index.js.map +1 -1
- package/dist/providers/groq/index.cjs +25 -6
- 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 +25 -6
- package/dist/providers/groq/index.js.map +1 -1
- package/dist/providers/huggingface/index.cjs +23 -5
- package/dist/providers/huggingface/index.cjs.map +1 -1
- package/dist/providers/huggingface/index.js +23 -5
- package/dist/providers/huggingface/index.js.map +1 -1
- package/dist/providers/mistral/index.cjs +25 -6
- 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 +25 -6
- package/dist/providers/mistral/index.js.map +1 -1
- package/dist/providers/ollama/index.cjs +25 -6
- 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 +25 -6
- package/dist/providers/ollama/index.js.map +1 -1
- package/dist/providers/openai/index.cjs +25 -6
- 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 +25 -6
- package/dist/providers/openai/index.js.map +1 -1
- package/dist/providers/together/index.cjs +25 -6
- 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 +25 -6
- package/dist/providers/together/index.js.map +1 -1
- package/dist/providers/vercel-ai/index.cjs +20 -5
- package/dist/providers/vercel-ai/index.cjs.map +1 -1
- package/dist/providers/vercel-ai/index.js +20 -5
- package/dist/providers/vercel-ai/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
* Returns a Proxy that intercepts chat.completions.create and embeddings.create.
|
|
25
25
|
* The original client is NOT modified.
|
|
26
26
|
*
|
|
27
|
+
* Patching a proxy that this function returned gives back the same proxy, so the
|
|
28
|
+
* second patch adds no second span.
|
|
29
|
+
*
|
|
27
30
|
* @param client - An OpenAI client instance
|
|
28
31
|
* @returns A proxied client with automatic tracing
|
|
29
32
|
*/
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
* Returns a Proxy that intercepts chat.completions.create and embeddings.create.
|
|
25
25
|
* The original client is NOT modified.
|
|
26
26
|
*
|
|
27
|
+
* Patching a proxy that this function returned gives back the same proxy, so the
|
|
28
|
+
* second patch adds no second span.
|
|
29
|
+
*
|
|
27
30
|
* @param client - An OpenAI client instance
|
|
28
31
|
* @returns A proxied client with automatic tracing
|
|
29
32
|
*/
|
|
@@ -460,7 +460,7 @@ function attachErrorCode(span, error) {
|
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
// src/version.ts
|
|
463
|
-
var SDK_VERSION = "0.9.
|
|
463
|
+
var SDK_VERSION = "0.9.2";
|
|
464
464
|
|
|
465
465
|
// src/exporters/quota.ts
|
|
466
466
|
var QUOTA_REASON = "monthly_quota_exceeded";
|
|
@@ -605,6 +605,8 @@ var HttpExporter = class {
|
|
|
605
605
|
_calls = /* @__PURE__ */ new Map();
|
|
606
606
|
/** The ack of each finished call, by its batch. Read once by `takeAck(spans)`. */
|
|
607
607
|
_acks = /* @__PURE__ */ new WeakMap();
|
|
608
|
+
/** The requests that each finished call sent, by its batch. Read once by `takeAttempts(spans)`. */
|
|
609
|
+
_requests = /* @__PURE__ */ new WeakMap();
|
|
608
610
|
/** The batch processor dropped span(s) from a full queue in the quota pause (S-1). */
|
|
609
611
|
noteQuotaDrop(count = 1) {
|
|
610
612
|
this._quota.addDrops(count);
|
|
@@ -656,6 +658,18 @@ var HttpExporter = class {
|
|
|
656
658
|
get attemptsPerExport() {
|
|
657
659
|
return this._maxRetries;
|
|
658
660
|
}
|
|
661
|
+
/**
|
|
662
|
+
* Returns the number of HTTP requests that the `export()` call for `spans` sent, and clears
|
|
663
|
+
* it. This is the number that was sent, not the most that the call may send
|
|
664
|
+
* (`attemptsPerExport`): a 401 or 403 stops the loop after one request, and an open circuit
|
|
665
|
+
* breaker sends none. Returns `null` when no call is on record for `spans`. The answer is
|
|
666
|
+
* kept per batch, as `takeAck` keeps the ack.
|
|
667
|
+
*/
|
|
668
|
+
takeAttempts(spans) {
|
|
669
|
+
const n = this._requests.get(spans) ?? null;
|
|
670
|
+
this._requests.delete(spans);
|
|
671
|
+
return n;
|
|
672
|
+
}
|
|
659
673
|
/**
|
|
660
674
|
* Returns the counts of the ack that the `export()` call for `spans` received, and clears
|
|
661
675
|
* them. The answer is kept per batch, not on the instance: two processors that share this
|
|
@@ -700,13 +714,15 @@ var HttpExporter = class {
|
|
|
700
714
|
misroute: null,
|
|
701
715
|
noRetry: false,
|
|
702
716
|
status: null,
|
|
703
|
-
error: null
|
|
717
|
+
error: null,
|
|
718
|
+
attempts: 0
|
|
704
719
|
};
|
|
705
720
|
this._calls.set(spans, call);
|
|
706
721
|
try {
|
|
707
722
|
return await this._export(spans, call);
|
|
708
723
|
} finally {
|
|
709
724
|
this._calls.delete(spans);
|
|
725
|
+
this._requests.set(spans, this._endpointHasCredentials ? 0 : call.attempts);
|
|
710
726
|
}
|
|
711
727
|
}
|
|
712
728
|
async _export(spans, call) {
|
|
@@ -746,14 +762,13 @@ var HttpExporter = class {
|
|
|
746
762
|
isHalfOpen = true;
|
|
747
763
|
}
|
|
748
764
|
const maxAttempts = isHalfOpen ? 1 : this._maxRetries;
|
|
749
|
-
let attempts = 0;
|
|
750
765
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
751
766
|
call.refusalAfterMs = null;
|
|
752
767
|
call.misroute = null;
|
|
753
768
|
call.noRetry = false;
|
|
754
769
|
call.status = null;
|
|
755
770
|
call.error = null;
|
|
756
|
-
attempts++;
|
|
771
|
+
call.attempts++;
|
|
757
772
|
const result = await this._sendRequest(payload, parts.length, call, spans);
|
|
758
773
|
if (cancelled.aborted) {
|
|
759
774
|
this._acks.delete(spans);
|
|
@@ -775,7 +790,7 @@ var HttpExporter = class {
|
|
|
775
790
|
}
|
|
776
791
|
if (call.refusalAfterMs !== null) {
|
|
777
792
|
warn(
|
|
778
|
-
`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.`
|
|
793
|
+
`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.`
|
|
779
794
|
);
|
|
780
795
|
return "failure" /* FAILURE */;
|
|
781
796
|
}
|
|
@@ -2039,10 +2054,12 @@ function createEmbeddingsProxy(originalCreate, provider) {
|
|
|
2039
2054
|
);
|
|
2040
2055
|
};
|
|
2041
2056
|
}
|
|
2057
|
+
var PATCHED = /* @__PURE__ */ new WeakSet();
|
|
2042
2058
|
function patchOpenAI(client) {
|
|
2043
2059
|
assertClient("patchOpenAI", client);
|
|
2060
|
+
if (PATCHED.has(client)) return client;
|
|
2044
2061
|
const provider = detectProvider(client);
|
|
2045
|
-
|
|
2062
|
+
const proxy = new Proxy(client, {
|
|
2046
2063
|
get(target, prop, receiver) {
|
|
2047
2064
|
const value = Reflect.get(target, prop, receiver);
|
|
2048
2065
|
if (prop === "chat" && value && typeof value === "object") {
|
|
@@ -2078,6 +2095,8 @@ function patchOpenAI(client) {
|
|
|
2078
2095
|
return value;
|
|
2079
2096
|
}
|
|
2080
2097
|
});
|
|
2098
|
+
PATCHED.add(proxy);
|
|
2099
|
+
return proxy;
|
|
2081
2100
|
}
|
|
2082
2101
|
export {
|
|
2083
2102
|
patchOpenAI
|