risicare 0.4.0 → 0.5.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/README.md +30 -0
- package/dist/frameworks/instructor.cjs +93 -73
- package/dist/frameworks/instructor.cjs.map +1 -1
- package/dist/frameworks/instructor.d.cts +19 -7
- package/dist/frameworks/instructor.d.ts +19 -7
- package/dist/frameworks/instructor.js +85 -67
- package/dist/frameworks/instructor.js.map +1 -1
- package/dist/frameworks/langchain.cjs +192 -94
- package/dist/frameworks/langchain.cjs.map +1 -1
- package/dist/frameworks/langchain.d.cts +97 -3
- package/dist/frameworks/langchain.d.ts +97 -3
- package/dist/frameworks/langchain.js +190 -88
- package/dist/frameworks/langchain.js.map +1 -1
- package/dist/frameworks/langgraph.cjs +192 -94
- package/dist/frameworks/langgraph.cjs.map +1 -1
- package/dist/frameworks/langgraph.js +190 -88
- package/dist/frameworks/langgraph.js.map +1 -1
- package/dist/frameworks/llamaindex.cjs +94 -69
- package/dist/frameworks/llamaindex.cjs.map +1 -1
- package/dist/frameworks/llamaindex.d.cts +33 -17
- package/dist/frameworks/llamaindex.d.ts +33 -17
- package/dist/frameworks/llamaindex.js +85 -62
- package/dist/frameworks/llamaindex.js.map +1 -1
- package/dist/index.cjs +2684 -1934
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +234 -46
- package/dist/index.d.ts +234 -46
- package/dist/index.js +2492 -1762
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic/index.cjs +33 -34
- package/dist/providers/anthropic/index.cjs.map +1 -1
- package/dist/providers/anthropic/index.js +25 -28
- package/dist/providers/anthropic/index.js.map +1 -1
- package/dist/providers/bedrock/index.cjs +56 -44
- package/dist/providers/bedrock/index.cjs.map +1 -1
- package/dist/providers/bedrock/index.d.cts +13 -1
- package/dist/providers/bedrock/index.d.ts +13 -1
- package/dist/providers/bedrock/index.js +47 -38
- package/dist/providers/bedrock/index.js.map +1 -1
- package/dist/providers/cerebras/index.cjs +33 -34
- package/dist/providers/cerebras/index.cjs.map +1 -1
- package/dist/providers/cerebras/index.js +25 -28
- package/dist/providers/cerebras/index.js.map +1 -1
- package/dist/providers/cohere/index.cjs +35 -36
- package/dist/providers/cohere/index.cjs.map +1 -1
- package/dist/providers/cohere/index.js +27 -30
- package/dist/providers/cohere/index.js.map +1 -1
- package/dist/providers/google/index.cjs +33 -34
- package/dist/providers/google/index.cjs.map +1 -1
- package/dist/providers/google/index.js +25 -28
- package/dist/providers/google/index.js.map +1 -1
- package/dist/providers/groq/index.cjs +33 -34
- package/dist/providers/groq/index.cjs.map +1 -1
- package/dist/providers/groq/index.js +25 -28
- package/dist/providers/groq/index.js.map +1 -1
- package/dist/providers/huggingface/index.cjs +33 -34
- package/dist/providers/huggingface/index.cjs.map +1 -1
- package/dist/providers/huggingface/index.js +25 -28
- package/dist/providers/huggingface/index.js.map +1 -1
- package/dist/providers/mistral/index.cjs +37 -38
- package/dist/providers/mistral/index.cjs.map +1 -1
- package/dist/providers/mistral/index.js +29 -32
- package/dist/providers/mistral/index.js.map +1 -1
- package/dist/providers/ollama/index.cjs +41 -34
- package/dist/providers/ollama/index.cjs.map +1 -1
- package/dist/providers/ollama/index.js +33 -28
- package/dist/providers/ollama/index.js.map +1 -1
- package/dist/providers/openai/index.cjs +36 -35
- package/dist/providers/openai/index.cjs.map +1 -1
- package/dist/providers/openai/index.js +28 -29
- package/dist/providers/openai/index.js.map +1 -1
- package/dist/providers/together/index.cjs +33 -34
- package/dist/providers/together/index.cjs.map +1 -1
- package/dist/providers/together/index.js +25 -28
- package/dist/providers/together/index.js.map +1 -1
- package/dist/providers/vercel-ai/index.cjs +27 -35
- package/dist/providers/vercel-ai/index.cjs.map +1 -1
- package/dist/providers/vercel-ai/index.js +19 -29
- package/dist/providers/vercel-ai/index.js.map +1 -1
- package/package.json +94 -33
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
4
|
-
};
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import { createHash as createHash2 } from "crypto";
|
|
5
3
|
|
|
6
4
|
// src/globals.ts
|
|
7
5
|
import { AsyncLocalStorage } from "async_hooks";
|
|
6
|
+
var G = globalThis;
|
|
7
|
+
var PREFIX = "__risicare_";
|
|
8
8
|
function getTracer() {
|
|
9
9
|
return G[PREFIX + "tracer"];
|
|
10
10
|
}
|
|
@@ -17,14 +17,6 @@ function getContextStorage() {
|
|
|
17
17
|
function getDebug() {
|
|
18
18
|
return G[PREFIX + "debug"] ?? false;
|
|
19
19
|
}
|
|
20
|
-
var G, PREFIX;
|
|
21
|
-
var init_globals = __esm({
|
|
22
|
-
"src/globals.ts"() {
|
|
23
|
-
"use strict";
|
|
24
|
-
G = globalThis;
|
|
25
|
-
PREFIX = "__risicare_";
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
20
|
|
|
29
21
|
// src/utils/log.ts
|
|
30
22
|
function debug(msg) {
|
|
@@ -33,12 +25,10 @@ function debug(msg) {
|
|
|
33
25
|
`);
|
|
34
26
|
}
|
|
35
27
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
});
|
|
28
|
+
|
|
29
|
+
// src/exporters/batch.ts
|
|
30
|
+
var MAX_BATCH_BYTES = 8 * 1024 * 1024;
|
|
31
|
+
var utf8ByteLength = typeof Buffer !== "undefined" && typeof Buffer.byteLength === "function" ? (s) => Buffer.byteLength(s, "utf8") : (s) => s.length * 3;
|
|
42
32
|
|
|
43
33
|
// src/ids.ts
|
|
44
34
|
import { randomBytes } from "crypto";
|
|
@@ -114,7 +104,6 @@ var NOOP_SPAN = Object.freeze({
|
|
|
114
104
|
});
|
|
115
105
|
|
|
116
106
|
// src/context/storage.ts
|
|
117
|
-
init_globals();
|
|
118
107
|
function storage() {
|
|
119
108
|
return getContextStorage();
|
|
120
109
|
}
|
|
@@ -122,15 +111,10 @@ function getContext() {
|
|
|
122
111
|
return storage().getStore() ?? {};
|
|
123
112
|
}
|
|
124
113
|
|
|
125
|
-
// src/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
// src/exporters/http.ts
|
|
129
|
-
init_log();
|
|
114
|
+
// src/runtime/applier.ts
|
|
115
|
+
import { createHash } from "crypto";
|
|
130
116
|
|
|
131
117
|
// src/client.ts
|
|
132
|
-
init_log();
|
|
133
|
-
init_globals();
|
|
134
118
|
function requireTracer() {
|
|
135
119
|
const tracer = getTracer();
|
|
136
120
|
if (!tracer) {
|
|
@@ -188,8 +172,20 @@ function calculateCost(model, promptTokens, completionTokens) {
|
|
|
188
172
|
return inputCost + outputCost;
|
|
189
173
|
}
|
|
190
174
|
|
|
191
|
-
// src/
|
|
192
|
-
|
|
175
|
+
// src/utils/assert-client.ts
|
|
176
|
+
function assertClient(patcherName, client) {
|
|
177
|
+
if (client === null || client === void 0) {
|
|
178
|
+
throw new TypeError(
|
|
179
|
+
`${patcherName} requires a client object, got ${client === null ? "null" : "undefined"}`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
const t = typeof client;
|
|
183
|
+
if (t !== "object" && t !== "function") {
|
|
184
|
+
throw new TypeError(
|
|
185
|
+
`${patcherName} requires a client object, got ${t}`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
193
189
|
|
|
194
190
|
// src/context/dedup.ts
|
|
195
191
|
function isProviderInstrumentationSuppressed() {
|
|
@@ -202,17 +198,26 @@ var INSTRUMENTED_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
202
198
|
"ConverseStreamCommand",
|
|
203
199
|
"InvokeModelCommand"
|
|
204
200
|
]);
|
|
205
|
-
function
|
|
206
|
-
const
|
|
201
|
+
function deriveModelFamily(modelId) {
|
|
202
|
+
const KNOWN_REGION_PREFIXES = ["us.", "eu.", "apac."];
|
|
203
|
+
let id = modelId;
|
|
204
|
+
for (const p of KNOWN_REGION_PREFIXES) {
|
|
205
|
+
if (id.startsWith(p)) {
|
|
206
|
+
id = id.slice(p.length);
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const dotIndex = id.indexOf(".");
|
|
207
211
|
if (dotIndex > 0) {
|
|
208
|
-
return
|
|
212
|
+
return id.substring(0, dotIndex);
|
|
209
213
|
}
|
|
210
|
-
return "
|
|
214
|
+
return "unknown";
|
|
211
215
|
}
|
|
212
|
-
function enrichSpanFromRequest(span, input,
|
|
216
|
+
function enrichSpanFromRequest(span, input, modelFamily) {
|
|
213
217
|
const modelId = input.modelId;
|
|
214
218
|
if (modelId) {
|
|
215
|
-
span.setAttribute("gen_ai.system",
|
|
219
|
+
span.setAttribute("gen_ai.system", "bedrock");
|
|
220
|
+
span.setAttribute("bedrock.model_family", modelFamily);
|
|
216
221
|
span.setAttribute("gen_ai.request.model", modelId);
|
|
217
222
|
}
|
|
218
223
|
const inferenceConfig = input.inferenceConfig;
|
|
@@ -315,7 +320,7 @@ function createSendProxy(originalSend) {
|
|
|
315
320
|
}
|
|
316
321
|
const input = getCommandInput(command);
|
|
317
322
|
const modelId = input.modelId ?? "unknown";
|
|
318
|
-
const
|
|
323
|
+
const modelFamily = deriveModelFamily(modelId);
|
|
319
324
|
const isStream = commandName === "ConverseStreamCommand";
|
|
320
325
|
const spanName = `bedrock.${commandName.replace("Command", "").toLowerCase()}`;
|
|
321
326
|
return tracer.startSpan(
|
|
@@ -324,14 +329,16 @@ function createSendProxy(originalSend) {
|
|
|
324
329
|
kind: "llm_call" /* LLM_CALL */,
|
|
325
330
|
attributes: {
|
|
326
331
|
"llm.request.model": modelId,
|
|
327
|
-
|
|
332
|
+
// F-630: provider is the SERVICE for AWS-spend filtering.
|
|
333
|
+
"gen_ai.system": "bedrock",
|
|
334
|
+
"bedrock.model_family": modelFamily,
|
|
328
335
|
"bedrock.command": commandName,
|
|
329
336
|
...isStream ? { "llm.stream": true } : {}
|
|
330
337
|
}
|
|
331
338
|
},
|
|
332
339
|
(span) => {
|
|
333
|
-
span.setLlmFields({ provider, model: modelId });
|
|
334
|
-
enrichSpanFromRequest(span, input,
|
|
340
|
+
span.setLlmFields({ provider: "bedrock", model: modelId });
|
|
341
|
+
enrichSpanFromRequest(span, input, modelFamily);
|
|
335
342
|
const result = originalSend.apply(this, args);
|
|
336
343
|
if (result && typeof result.then === "function") {
|
|
337
344
|
return result.then((response) => {
|
|
@@ -350,6 +357,7 @@ function createSendProxy(originalSend) {
|
|
|
350
357
|
};
|
|
351
358
|
}
|
|
352
359
|
function patchBedrock(client) {
|
|
360
|
+
assertClient("patchBedrock", client);
|
|
353
361
|
return new Proxy(client, {
|
|
354
362
|
get(target, prop, receiver) {
|
|
355
363
|
const value = Reflect.get(target, prop, receiver);
|
|
@@ -361,6 +369,7 @@ function patchBedrock(client) {
|
|
|
361
369
|
});
|
|
362
370
|
}
|
|
363
371
|
export {
|
|
372
|
+
deriveModelFamily,
|
|
364
373
|
patchBedrock
|
|
365
374
|
};
|
|
366
375
|
//# sourceMappingURL=index.js.map
|