@llmops/sdk 1.0.0-beta.1 → 1.0.0-beta.11
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/dist/agents.cjs +1 -1
- package/dist/agents.d.cts +1 -1
- package/dist/agents.d.mts +1 -1
- package/dist/agents.mjs +1 -1
- package/dist/constants--ywcWP7q.cjs +18 -0
- package/dist/constants-B8e4mnT7.mjs +12 -0
- package/dist/express.cjs +29 -2
- package/dist/express.d.cts +7 -3
- package/dist/express.d.mts +7 -3
- package/dist/express.mjs +28 -1
- package/dist/hono.d.cts +2 -2
- package/dist/hono.d.mts +2 -2
- package/dist/{index-C7J-9Jvp.d.cts → index-B5aeZ4Jb.d.mts} +1 -1
- package/dist/{index-D0LVaLA4.d.mts → index-sjRozlIk.d.cts} +1 -1
- package/dist/index.cjs +4 -10
- package/dist/index.d.cts +4 -5
- package/dist/index.d.mts +4 -5
- package/dist/index.mjs +4 -4
- package/dist/interface-B0KYptxO.d.cts +223 -0
- package/dist/interface-DFchZZQP.d.mts +223 -0
- package/dist/nextjs.d.cts +2 -2
- package/dist/nextjs.d.mts +2 -2
- package/dist/store/d1.cjs +491 -0
- package/dist/store/d1.d.cts +60 -0
- package/dist/store/d1.d.mts +60 -0
- package/dist/store/d1.mjs +490 -0
- package/dist/store/pg.cjs +13636 -0
- package/dist/store/pg.d.cts +38 -0
- package/dist/store/pg.d.mts +38 -0
- package/dist/store/pg.mjs +13637 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +44 -3
- package/dist/express-B-wbCza5.cjs +0 -35
- package/dist/express-ClEIbLM9.mjs +0 -30
- package/dist/index-1uemrw2P.d.cts +0 -7
- package/dist/index-BeDbCYjz.d.mts +0 -7
- /package/dist/{agents-exporter-B-ADoC7t.d.cts → agents-exporter-B3dyZc2j.d.mts} +0 -0
- /package/dist/{agents-exporter-CxbWY6xN.mjs → agents-exporter-Cte-NArh.mjs} +0 -0
- /package/dist/{agents-exporter-BuTq2n2y.cjs → agents-exporter-DizRE7CQ.cjs} +0 -0
- /package/dist/{agents-exporter-BZjfVkaH.d.mts → agents-exporter-vuQine9v.d.cts} +0 -0
package/dist/agents.cjs
CHANGED
package/dist/agents.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AgentsTracingExporter, i as AgentsTrace, n as AgentsSpanData, o as LLMOpsAgentsExporterConfig, r as AgentsSpanError, s as createLLMOpsAgentsExporter, t as AgentsSpan } from "./agents-exporter-
|
|
1
|
+
import { a as AgentsTracingExporter, i as AgentsTrace, n as AgentsSpanData, o as LLMOpsAgentsExporterConfig, r as AgentsSpanError, s as createLLMOpsAgentsExporter, t as AgentsSpan } from "./agents-exporter-vuQine9v.cjs";
|
|
2
2
|
export { AgentsSpan, AgentsSpanData, AgentsSpanError, AgentsTrace, AgentsTracingExporter, LLMOpsAgentsExporterConfig, createLLMOpsAgentsExporter };
|
package/dist/agents.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AgentsTracingExporter, i as AgentsTrace, n as AgentsSpanData, o as LLMOpsAgentsExporterConfig, r as AgentsSpanError, s as createLLMOpsAgentsExporter, t as AgentsSpan } from "./agents-exporter-
|
|
1
|
+
import { a as AgentsTracingExporter, i as AgentsTrace, n as AgentsSpanData, o as LLMOpsAgentsExporterConfig, r as AgentsSpanError, s as createLLMOpsAgentsExporter, t as AgentsSpan } from "./agents-exporter-B3dyZc2j.mjs";
|
|
2
2
|
export { AgentsSpan, AgentsSpanData, AgentsSpanError, AgentsTrace, AgentsTracingExporter, LLMOpsAgentsExporterConfig, createLLMOpsAgentsExporter };
|
package/dist/agents.mjs
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/telemetry/constants.ts
|
|
3
|
+
const COST_SUMMARY_GROUP_BY = [
|
|
4
|
+
"day",
|
|
5
|
+
"hour",
|
|
6
|
+
"model",
|
|
7
|
+
"provider",
|
|
8
|
+
"endpoint",
|
|
9
|
+
"tags"
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
Object.defineProperty(exports, 'COST_SUMMARY_GROUP_BY', {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return COST_SUMMARY_GROUP_BY;
|
|
17
|
+
}
|
|
18
|
+
});
|
package/dist/express.cjs
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
let node_stream = require("node:stream");
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/lib/express/index.ts
|
|
4
|
+
function createLLMOpsMiddleware(client) {
|
|
5
|
+
const basePath = client.config.basePath;
|
|
6
|
+
return async (req, res, next) => {
|
|
7
|
+
let urlPath = req.originalUrl;
|
|
8
|
+
if (basePath && urlPath.startsWith(basePath)) urlPath = urlPath.slice(basePath.length) || "/";
|
|
9
|
+
const url = new URL(urlPath, `${req.protocol}://${req.get("host")}`);
|
|
10
|
+
const request = new Request(url, {
|
|
11
|
+
method: req.method,
|
|
12
|
+
headers: req.headers,
|
|
13
|
+
body: ["GET", "HEAD"].includes(req.method) ? void 0 : JSON.stringify(req.body)
|
|
14
|
+
});
|
|
15
|
+
const response = await client.handler(request);
|
|
16
|
+
if (response.status === 404) return next();
|
|
17
|
+
response.headers?.forEach((value, key) => {
|
|
18
|
+
res.setHeader(key, value);
|
|
19
|
+
});
|
|
20
|
+
res.status(response.status);
|
|
21
|
+
if ((response.headers?.get("content-type"))?.includes("text/event-stream") && response.body) node_stream.Readable.fromWeb(response.body).pipe(res);
|
|
22
|
+
else {
|
|
23
|
+
const body = await response.text();
|
|
24
|
+
res.send(body);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.createLLMOpsMiddleware = createLLMOpsMiddleware;
|
package/dist/express.d.cts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import "./agents-exporter-
|
|
2
|
-
import "./index-
|
|
3
|
-
import {
|
|
1
|
+
import "./agents-exporter-vuQine9v.cjs";
|
|
2
|
+
import { t as LLMOpsClient } from "./index-sjRozlIk.cjs";
|
|
3
|
+
import { NextFunction, Request, Response } from "express";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/express/index.d.ts
|
|
6
|
+
declare function createLLMOpsMiddleware(client: LLMOpsClient): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
7
|
+
//#endregion
|
|
4
8
|
export { createLLMOpsMiddleware };
|
package/dist/express.d.mts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import "./agents-exporter-
|
|
2
|
-
import "./index-
|
|
3
|
-
import {
|
|
1
|
+
import "./agents-exporter-B3dyZc2j.mjs";
|
|
2
|
+
import { t as LLMOpsClient } from "./index-B5aeZ4Jb.mjs";
|
|
3
|
+
import { NextFunction, Request, Response } from "express";
|
|
4
|
+
|
|
5
|
+
//#region src/lib/express/index.d.ts
|
|
6
|
+
declare function createLLMOpsMiddleware(client: LLMOpsClient): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
7
|
+
//#endregion
|
|
4
8
|
export { createLLMOpsMiddleware };
|
package/dist/express.mjs
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
2
|
|
|
3
|
+
//#region src/lib/express/index.ts
|
|
4
|
+
function createLLMOpsMiddleware(client) {
|
|
5
|
+
const basePath = client.config.basePath;
|
|
6
|
+
return async (req, res, next) => {
|
|
7
|
+
let urlPath = req.originalUrl;
|
|
8
|
+
if (basePath && urlPath.startsWith(basePath)) urlPath = urlPath.slice(basePath.length) || "/";
|
|
9
|
+
const url = new URL(urlPath, `${req.protocol}://${req.get("host")}`);
|
|
10
|
+
const request = new Request(url, {
|
|
11
|
+
method: req.method,
|
|
12
|
+
headers: req.headers,
|
|
13
|
+
body: ["GET", "HEAD"].includes(req.method) ? void 0 : JSON.stringify(req.body)
|
|
14
|
+
});
|
|
15
|
+
const response = await client.handler(request);
|
|
16
|
+
if (response.status === 404) return next();
|
|
17
|
+
response.headers?.forEach((value, key) => {
|
|
18
|
+
res.setHeader(key, value);
|
|
19
|
+
});
|
|
20
|
+
res.status(response.status);
|
|
21
|
+
if ((response.headers?.get("content-type"))?.includes("text/event-stream") && response.body) Readable.fromWeb(response.body).pipe(res);
|
|
22
|
+
else {
|
|
23
|
+
const body = await response.text();
|
|
24
|
+
res.send(body);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
3
30
|
export { createLLMOpsMiddleware };
|
package/dist/hono.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./agents-exporter-
|
|
2
|
-
import { t as LLMOpsClient } from "./index-
|
|
1
|
+
import "./agents-exporter-vuQine9v.cjs";
|
|
2
|
+
import { t as LLMOpsClient } from "./index-sjRozlIk.cjs";
|
|
3
3
|
import { MiddlewareHandler } from "hono";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/hono/index.d.ts
|
package/dist/hono.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./agents-exporter-
|
|
2
|
-
import { t as LLMOpsClient } from "./index-
|
|
1
|
+
import "./agents-exporter-B3dyZc2j.mjs";
|
|
2
|
+
import { t as LLMOpsClient } from "./index-B5aeZ4Jb.mjs";
|
|
3
3
|
import { MiddlewareHandler } from "hono";
|
|
4
4
|
|
|
5
5
|
//#region src/lib/hono/index.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AgentsTracingExporter } from "./agents-exporter-
|
|
1
|
+
import { a as AgentsTracingExporter } from "./agents-exporter-B3dyZc2j.mjs";
|
|
2
2
|
import { LLMOpsConfig, ValidatedLLMOpsConfig } from "@llmops/core";
|
|
3
3
|
|
|
4
4
|
//#region src/telemetry/langchain-client.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AgentsTracingExporter } from "./agents-exporter-
|
|
1
|
+
import { a as AgentsTracingExporter } from "./agents-exporter-vuQine9v.cjs";
|
|
2
2
|
import { LLMOpsConfig, ValidatedLLMOpsConfig } from "@llmops/core";
|
|
3
3
|
|
|
4
4
|
//#region src/telemetry/langchain-client.d.ts
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const require_agents_exporter = require('./agents-exporter-DizRE7CQ.cjs');
|
|
2
|
+
const require_constants = require('./constants--ywcWP7q.cjs');
|
|
3
3
|
let __llmops_core = require("@llmops/core");
|
|
4
4
|
let __llmops_app = require("@llmops/app");
|
|
5
5
|
|
|
@@ -229,14 +229,8 @@ function createLLMOpsSpanExporter(config) {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
//#endregion
|
|
232
|
+
exports.COST_SUMMARY_GROUP_BY = require_constants.COST_SUMMARY_GROUP_BY;
|
|
232
233
|
exports.createLLMOpsAgentsExporter = require_agents_exporter.createLLMOpsAgentsExporter;
|
|
233
234
|
exports.createLLMOpsLangChainClient = createLLMOpsLangChainClient;
|
|
234
|
-
exports.createLLMOpsMiddleware = require_express.createLLMOpsMiddleware;
|
|
235
235
|
exports.createLLMOpsSpanExporter = createLLMOpsSpanExporter;
|
|
236
|
-
exports.llmops = createLLMOps;
|
|
237
|
-
Object.defineProperty(exports, 'pgStore', {
|
|
238
|
-
enumerable: true,
|
|
239
|
-
get: function () {
|
|
240
|
-
return __llmops_core.createPgStore;
|
|
241
|
-
}
|
|
242
|
-
});
|
|
236
|
+
exports.llmops = createLLMOps;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as AgentsTracingExporter, o as LLMOpsAgentsExporterConfig, s as createLLMOpsAgentsExporter } from "./agents-exporter-
|
|
2
|
-
import { a as LLMOpsLangChainClientConfig, i as createLLMOps, n as ProviderOptions, o as LangChainTracingClient, r as TraceContext, s as createLLMOpsLangChainClient, t as LLMOpsClient } from "./index-
|
|
3
|
-
import { t as
|
|
4
|
-
import { TelemetryStore, createPgStore as pgStore } from "@llmops/core";
|
|
1
|
+
import { a as AgentsTracingExporter, o as LLMOpsAgentsExporterConfig, s as createLLMOpsAgentsExporter } from "./agents-exporter-vuQine9v.cjs";
|
|
2
|
+
import { a as LLMOpsLangChainClientConfig, i as createLLMOps, n as ProviderOptions, o as LangChainTracingClient, r as TraceContext, s as createLLMOpsLangChainClient, t as LLMOpsClient } from "./index-sjRozlIk.cjs";
|
|
3
|
+
import { a as TraceUpsert, i as SpanInsert, n as LLMRequestInsert, o as COST_SUMMARY_GROUP_BY, r as SpanEventInsert, s as CostSummaryGroupBy, t as TelemetryStore } from "./interface-B0KYptxO.cjs";
|
|
5
4
|
|
|
6
5
|
//#region src/telemetry/exporter.d.ts
|
|
7
6
|
|
|
@@ -93,4 +92,4 @@ interface LLMOpsExporterConfig {
|
|
|
93
92
|
*/
|
|
94
93
|
declare function createLLMOpsSpanExporter(config: LLMOpsExporterConfig): SpanExporter;
|
|
95
94
|
//#endregion
|
|
96
|
-
export { type AgentsTracingExporter, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, type LLMOpsLangChainClientConfig, type LangChainTracingClient, type ProviderOptions, type SpanExporter, type TelemetryStore, type TraceContext, createLLMOpsAgentsExporter, createLLMOpsLangChainClient,
|
|
95
|
+
export { type AgentsTracingExporter, COST_SUMMARY_GROUP_BY, type CostSummaryGroupBy, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, type LLMOpsLangChainClientConfig, type LLMRequestInsert, type LangChainTracingClient, type ProviderOptions, type SpanEventInsert, type SpanExporter, type SpanInsert, type TelemetryStore, type TraceContext, type TraceUpsert, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsSpanExporter, createLLMOps as llmops };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as AgentsTracingExporter, o as LLMOpsAgentsExporterConfig, s as createLLMOpsAgentsExporter } from "./agents-exporter-
|
|
2
|
-
import { a as LLMOpsLangChainClientConfig, i as createLLMOps, n as ProviderOptions, o as LangChainTracingClient, r as TraceContext, s as createLLMOpsLangChainClient, t as LLMOpsClient } from "./index-
|
|
3
|
-
import { t as
|
|
4
|
-
import { TelemetryStore, createPgStore as pgStore } from "@llmops/core";
|
|
1
|
+
import { a as AgentsTracingExporter, o as LLMOpsAgentsExporterConfig, s as createLLMOpsAgentsExporter } from "./agents-exporter-B3dyZc2j.mjs";
|
|
2
|
+
import { a as LLMOpsLangChainClientConfig, i as createLLMOps, n as ProviderOptions, o as LangChainTracingClient, r as TraceContext, s as createLLMOpsLangChainClient, t as LLMOpsClient } from "./index-B5aeZ4Jb.mjs";
|
|
3
|
+
import { a as TraceUpsert, i as SpanInsert, n as LLMRequestInsert, o as COST_SUMMARY_GROUP_BY, r as SpanEventInsert, s as CostSummaryGroupBy, t as TelemetryStore } from "./interface-DFchZZQP.mjs";
|
|
5
4
|
|
|
6
5
|
//#region src/telemetry/exporter.d.ts
|
|
7
6
|
|
|
@@ -93,4 +92,4 @@ interface LLMOpsExporterConfig {
|
|
|
93
92
|
*/
|
|
94
93
|
declare function createLLMOpsSpanExporter(config: LLMOpsExporterConfig): SpanExporter;
|
|
95
94
|
//#endregion
|
|
96
|
-
export { type AgentsTracingExporter, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, type LLMOpsLangChainClientConfig, type LangChainTracingClient, type ProviderOptions, type SpanExporter, type TelemetryStore, type TraceContext, createLLMOpsAgentsExporter, createLLMOpsLangChainClient,
|
|
95
|
+
export { type AgentsTracingExporter, COST_SUMMARY_GROUP_BY, type CostSummaryGroupBy, type LLMOpsAgentsExporterConfig, type LLMOpsClient, type LLMOpsExporterConfig, type LLMOpsLangChainClientConfig, type LLMRequestInsert, type LangChainTracingClient, type ProviderOptions, type SpanEventInsert, type SpanExporter, type SpanInsert, type TelemetryStore, type TraceContext, type TraceUpsert, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsSpanExporter, createLLMOps as llmops };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import { LLMOPS_INTERNAL_HEADER, LLMOPS_SPAN_NAME_HEADER, LLMOPS_TRACE_ID_HEADER, LLMOPS_TRACE_NAME_HEADER
|
|
1
|
+
import { t as createLLMOpsAgentsExporter } from "./agents-exporter-Cte-NArh.mjs";
|
|
2
|
+
import { t as COST_SUMMARY_GROUP_BY } from "./constants-B8e4mnT7.mjs";
|
|
3
|
+
import { LLMOPS_INTERNAL_HEADER, LLMOPS_SPAN_NAME_HEADER, LLMOPS_TRACE_ID_HEADER, LLMOPS_TRACE_NAME_HEADER } from "@llmops/core";
|
|
4
4
|
import { createApp } from "@llmops/app";
|
|
5
5
|
|
|
6
6
|
//#region src/telemetry/langchain-client.ts
|
|
@@ -229,4 +229,4 @@ function createLLMOpsSpanExporter(config) {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
//#endregion
|
|
232
|
-
export { createLLMOpsAgentsExporter, createLLMOpsLangChainClient,
|
|
232
|
+
export { COST_SUMMARY_GROUP_BY, createLLMOpsAgentsExporter, createLLMOpsLangChainClient, createLLMOpsSpanExporter, createLLMOps as llmops };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/telemetry/constants.d.ts
|
|
4
|
+
declare const COST_SUMMARY_GROUP_BY: readonly ["day", "hour", "model", "provider", "endpoint", "tags"];
|
|
5
|
+
type CostSummaryGroupBy = (typeof COST_SUMMARY_GROUP_BY)[number];
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/telemetry/types.d.ts
|
|
8
|
+
|
|
9
|
+
declare const insertLLMRequestSchema: z.ZodObject<{
|
|
10
|
+
requestId: z.ZodString;
|
|
11
|
+
configId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
variantId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
environmentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
providerConfigId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
15
|
+
provider: z.ZodString;
|
|
16
|
+
model: z.ZodString;
|
|
17
|
+
promptTokens: z.ZodDefault<z.ZodNumber>;
|
|
18
|
+
completionTokens: z.ZodDefault<z.ZodNumber>;
|
|
19
|
+
totalTokens: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
cachedTokens: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
cacheCreationTokens: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
cost: z.ZodDefault<z.ZodNumber>;
|
|
23
|
+
cacheSavings: z.ZodDefault<z.ZodNumber>;
|
|
24
|
+
inputCost: z.ZodDefault<z.ZodNumber>;
|
|
25
|
+
outputCost: z.ZodDefault<z.ZodNumber>;
|
|
26
|
+
endpoint: z.ZodString;
|
|
27
|
+
statusCode: z.ZodNumber;
|
|
28
|
+
latencyMs: z.ZodDefault<z.ZodNumber>;
|
|
29
|
+
isStreaming: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
+
userId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
+
tags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
32
|
+
guardrailResults: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
33
|
+
results: z.ZodArray<z.ZodObject<{
|
|
34
|
+
checkId: z.ZodString;
|
|
35
|
+
functionId: z.ZodString;
|
|
36
|
+
hookType: z.ZodEnum<{
|
|
37
|
+
beforeRequestHook: "beforeRequestHook";
|
|
38
|
+
afterRequestHook: "afterRequestHook";
|
|
39
|
+
}>;
|
|
40
|
+
verdict: z.ZodBoolean;
|
|
41
|
+
latencyMs: z.ZodNumber;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
action: z.ZodEnum<{
|
|
44
|
+
allowed: "allowed";
|
|
45
|
+
blocked: "blocked";
|
|
46
|
+
logged: "logged";
|
|
47
|
+
}>;
|
|
48
|
+
totalLatencyMs: z.ZodNumber;
|
|
49
|
+
}, z.core.$strip>>>;
|
|
50
|
+
traceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
spanId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
52
|
+
parentSpanId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
sessionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
type LLMRequestInsert = z.infer<typeof insertLLMRequestSchema>;
|
|
56
|
+
declare const upsertTraceSchema: z.ZodObject<{
|
|
57
|
+
traceId: z.ZodString;
|
|
58
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
sessionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
|
+
userId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
61
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
62
|
+
error: "error";
|
|
63
|
+
unset: "unset";
|
|
64
|
+
ok: "ok";
|
|
65
|
+
}>>;
|
|
66
|
+
startTime: z.ZodDate;
|
|
67
|
+
endTime: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
68
|
+
durationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
69
|
+
spanCount: z.ZodDefault<z.ZodNumber>;
|
|
70
|
+
totalInputTokens: z.ZodDefault<z.ZodNumber>;
|
|
71
|
+
totalOutputTokens: z.ZodDefault<z.ZodNumber>;
|
|
72
|
+
totalTokens: z.ZodDefault<z.ZodNumber>;
|
|
73
|
+
totalCost: z.ZodDefault<z.ZodNumber>;
|
|
74
|
+
tags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
75
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
type TraceUpsert = z.infer<typeof upsertTraceSchema>;
|
|
78
|
+
declare const insertSpanSchema: z.ZodObject<{
|
|
79
|
+
traceId: z.ZodString;
|
|
80
|
+
spanId: z.ZodString;
|
|
81
|
+
parentSpanId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
82
|
+
name: z.ZodString;
|
|
83
|
+
kind: z.ZodDefault<z.ZodNumber>;
|
|
84
|
+
status: z.ZodDefault<z.ZodNumber>;
|
|
85
|
+
statusMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
86
|
+
startTime: z.ZodDate;
|
|
87
|
+
endTime: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
88
|
+
durationMs: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
89
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
90
|
+
model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
91
|
+
promptTokens: z.ZodDefault<z.ZodNumber>;
|
|
92
|
+
completionTokens: z.ZodDefault<z.ZodNumber>;
|
|
93
|
+
totalTokens: z.ZodDefault<z.ZodNumber>;
|
|
94
|
+
cost: z.ZodDefault<z.ZodNumber>;
|
|
95
|
+
configId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
96
|
+
variantId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
97
|
+
environmentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
98
|
+
providerConfigId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
99
|
+
requestId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
100
|
+
source: z.ZodDefault<z.ZodEnum<{
|
|
101
|
+
gateway: "gateway";
|
|
102
|
+
otlp: "otlp";
|
|
103
|
+
langsmith: "langsmith";
|
|
104
|
+
}>>;
|
|
105
|
+
input: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
106
|
+
output: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
107
|
+
attributes: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
type SpanInsert = z.infer<typeof insertSpanSchema>;
|
|
110
|
+
declare const insertSpanEventSchema: z.ZodObject<{
|
|
111
|
+
traceId: z.ZodString;
|
|
112
|
+
spanId: z.ZodString;
|
|
113
|
+
name: z.ZodString;
|
|
114
|
+
timestamp: z.ZodDate;
|
|
115
|
+
attributes: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
type SpanEventInsert = z.infer<typeof insertSpanEventSchema>;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/telemetry/interface.d.ts
|
|
120
|
+
/**
|
|
121
|
+
* TelemetryStore provides read + write access to telemetry data.
|
|
122
|
+
* Implemented by pgStore, d1Store, and future store backends.
|
|
123
|
+
*/
|
|
124
|
+
interface TelemetryStore {
|
|
125
|
+
batchInsertRequests(requests: LLMRequestInsert[]): Promise<{
|
|
126
|
+
count: number;
|
|
127
|
+
}>;
|
|
128
|
+
insertRequest(request: LLMRequestInsert): Promise<unknown>;
|
|
129
|
+
listRequests(params?: {
|
|
130
|
+
limit?: number;
|
|
131
|
+
offset?: number;
|
|
132
|
+
configId?: string;
|
|
133
|
+
variantId?: string;
|
|
134
|
+
environmentId?: string;
|
|
135
|
+
providerConfigId?: string;
|
|
136
|
+
provider?: string;
|
|
137
|
+
model?: string;
|
|
138
|
+
startDate?: Date;
|
|
139
|
+
endDate?: Date;
|
|
140
|
+
tags?: Record<string, string[]>;
|
|
141
|
+
}): Promise<{
|
|
142
|
+
data: unknown[];
|
|
143
|
+
total: number;
|
|
144
|
+
limit: number;
|
|
145
|
+
offset: number;
|
|
146
|
+
}>;
|
|
147
|
+
getRequestByRequestId(requestId: string): Promise<unknown | undefined>;
|
|
148
|
+
getTotalCost(params: {
|
|
149
|
+
startDate: Date;
|
|
150
|
+
endDate: Date;
|
|
151
|
+
configId?: string;
|
|
152
|
+
variantId?: string;
|
|
153
|
+
environmentId?: string;
|
|
154
|
+
tags?: Record<string, string[]>;
|
|
155
|
+
}): Promise<unknown>;
|
|
156
|
+
getCostByModel(params: {
|
|
157
|
+
startDate: Date;
|
|
158
|
+
endDate: Date;
|
|
159
|
+
}): Promise<unknown[]>;
|
|
160
|
+
getCostByProvider(params: {
|
|
161
|
+
startDate: Date;
|
|
162
|
+
endDate: Date;
|
|
163
|
+
}): Promise<unknown[]>;
|
|
164
|
+
getDailyCosts(params: {
|
|
165
|
+
startDate: Date;
|
|
166
|
+
endDate: Date;
|
|
167
|
+
}): Promise<unknown[]>;
|
|
168
|
+
getCostSummary(params: {
|
|
169
|
+
startDate: Date;
|
|
170
|
+
endDate: Date;
|
|
171
|
+
configId?: string;
|
|
172
|
+
variantId?: string;
|
|
173
|
+
environmentId?: string;
|
|
174
|
+
groupBy?: CostSummaryGroupBy;
|
|
175
|
+
tags?: Record<string, string[]>;
|
|
176
|
+
tagKeys?: string[];
|
|
177
|
+
}): Promise<unknown[]>;
|
|
178
|
+
getRequestStats(params: {
|
|
179
|
+
startDate: Date;
|
|
180
|
+
endDate: Date;
|
|
181
|
+
configId?: string;
|
|
182
|
+
variantId?: string;
|
|
183
|
+
environmentId?: string;
|
|
184
|
+
tags?: Record<string, string[]>;
|
|
185
|
+
}): Promise<unknown>;
|
|
186
|
+
getDistinctTags(): Promise<unknown[]>;
|
|
187
|
+
upsertTrace(data: TraceUpsert): Promise<void>;
|
|
188
|
+
batchInsertSpans(spans: SpanInsert[]): Promise<{
|
|
189
|
+
count: number;
|
|
190
|
+
}>;
|
|
191
|
+
batchInsertSpanEvents(events: SpanEventInsert[]): Promise<{
|
|
192
|
+
count: number;
|
|
193
|
+
}>;
|
|
194
|
+
listTraces(params?: {
|
|
195
|
+
limit?: number;
|
|
196
|
+
offset?: number;
|
|
197
|
+
sessionId?: string;
|
|
198
|
+
userId?: string;
|
|
199
|
+
status?: string;
|
|
200
|
+
name?: string;
|
|
201
|
+
startDate?: Date;
|
|
202
|
+
endDate?: Date;
|
|
203
|
+
tags?: Record<string, string[]>;
|
|
204
|
+
}): Promise<{
|
|
205
|
+
data: unknown[];
|
|
206
|
+
total: number;
|
|
207
|
+
limit: number;
|
|
208
|
+
offset: number;
|
|
209
|
+
}>;
|
|
210
|
+
getTraceWithSpans(traceId: string): Promise<{
|
|
211
|
+
trace: unknown;
|
|
212
|
+
spans: unknown[];
|
|
213
|
+
events: unknown[];
|
|
214
|
+
} | undefined>;
|
|
215
|
+
getTraceStats(params: {
|
|
216
|
+
startDate: Date;
|
|
217
|
+
endDate: Date;
|
|
218
|
+
sessionId?: string;
|
|
219
|
+
userId?: string;
|
|
220
|
+
}): Promise<unknown>;
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
export { TraceUpsert as a, SpanInsert as i, LLMRequestInsert as n, COST_SUMMARY_GROUP_BY as o, SpanEventInsert as r, CostSummaryGroupBy as s, TelemetryStore as t };
|