@llmops/core 1.0.0-beta.1 → 1.0.0-beta.3
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/{bun-sqlite-dialect-C3HVUfYl.cjs → bun-sqlite-dialect-CVUG5QUU.cjs} +1 -1
- package/dist/db/index.cjs +2 -2
- package/dist/db/index.d.cts +1 -1
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.mjs +1 -1
- package/dist/{db-CjwRQB4N.mjs → db-CZ8KtpL-.mjs} +3 -132
- package/dist/{db-D3WDjcvd.cjs → db-DZv0NtMm.cjs} +7 -136
- package/dist/{index-BoDvuqku.d.mts → index-BlFAMkmT.d.mts} +18 -416
- package/dist/{index-BmGf4wCW.d.cts → index-DjIHdwhi.d.cts} +18 -416
- package/dist/index.cjs +1132 -1648
- package/dist/index.d.cts +981 -1535
- package/dist/index.d.mts +981 -1535
- package/dist/index.mjs +1132 -1641
- package/dist/{neon-dialect-BSJpZ9YH.cjs → neon-dialect-BOnuygPe.cjs} +1 -1
- package/dist/{neon-dialect-DMClTHvw.cjs → neon-dialect-ByrFa9iy.cjs} +1 -1
- package/dist/{node-sqlite-dialect-BZGXfDHS.cjs → node-sqlite-dialect-fwmW40Ar.cjs} +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { $ as SCHEMA_METADATA, A as DatasetsTable, At as playgroundsSchema, B as LLMRequest, Bt as workspaceSettingsSchema, C as Dataset, Ct as environmentSecretsSchema, D as DatasetVersionRecord, Dt as playgroundColumnSchema, E as DatasetVersion, Et as llmRequestsSchema, F as GuardrailConfig, Ft as spansSchema, G as PlaygroundResultsTable, H as Playground, I as GuardrailConfigsTable, It as targetingRulesSchema, J as PlaygroundsTable, K as PlaygroundRun, L as GuardrailResult, Lt as tracesSchema, M as EnvironmentSecret, Mt as providerGuardrailOverridesSchema, N as EnvironmentSecretsTable, Nt as schemas, O as DatasetVersionRecordsTable, Ot as playgroundResultsSchema, P as EnvironmentsTable, Pt as spanEventsSchema, Q as ProviderGuardrailOverridesTable, R as GuardrailResults, Rt as variantVersionsSchema, S as Database, St as datasetsSchema, T as DatasetRecordsTable, Tt as guardrailConfigsSchema, U as PlaygroundColumn, V as LLMRequestsTable, W as PlaygroundResult, X as ProviderConfigsTable, Y as ProviderConfig, Z as ProviderGuardrailOverride, _ as validateTableData, _t as configVariantsSchema, a as createDatabaseFromConnection, at as TableName, b as ConfigVariantsTable, bt as datasetVersionRecordsSchema, c as executeWithSchema, ct as Trace, d as getMigrations, dt as Variant, et as Selectable, f as matchType, ft as VariantVersion, g as validatePartialTableData, gt as WorkspaceSettingsTable, h as parseTableData, ht as WorkspaceSettings, i as createDatabase, it as SpansTable, j as Environment, jt as providerConfigsSchema, k as DatasetVersionsTable, kt as playgroundRunsSchema, l as MigrationOptions, lt as TracesTable, m as parsePartialTableData, mt as VariantsTable, n as DatabaseOptions, nt as SpanEvent, o as detectDatabaseType, ot as TargetingRule, p as runAutoMigrations, pt as VariantVersionsTable, q as PlaygroundRunsTable, r as DatabaseType, rt as SpanEventsTable, s as createNeonDialect, st as TargetingRulesTable, t as DatabaseConnection, tt as Span, u as MigrationResult, ut as Updateable, v as Config, vt as configsSchema, w as DatasetRecord, wt as environmentsSchema, x as ConfigsTable, xt as datasetVersionsSchema, y as ConfigVariant, yt as datasetRecordsSchema, z as Insertable, zt as variantsSchema } from "./index-
|
|
1
|
+
import { $ as SCHEMA_METADATA, A as DatasetsTable, At as playgroundsSchema, B as LLMRequest, Bt as workspaceSettingsSchema, C as Dataset, Ct as environmentSecretsSchema, D as DatasetVersionRecord, Dt as playgroundColumnSchema, E as DatasetVersion, Et as llmRequestsSchema, F as GuardrailConfig, Ft as spansSchema, G as PlaygroundResultsTable, H as Playground, I as GuardrailConfigsTable, It as targetingRulesSchema, J as PlaygroundsTable, K as PlaygroundRun, L as GuardrailResult, Lt as tracesSchema, M as EnvironmentSecret, Mt as providerGuardrailOverridesSchema, N as EnvironmentSecretsTable, Nt as schemas, O as DatasetVersionRecordsTable, Ot as playgroundResultsSchema, P as EnvironmentsTable, Pt as spanEventsSchema, Q as ProviderGuardrailOverridesTable, R as GuardrailResults, Rt as variantVersionsSchema, S as Database, St as datasetsSchema, T as DatasetRecordsTable, Tt as guardrailConfigsSchema, U as PlaygroundColumn, V as LLMRequestsTable, W as PlaygroundResult, X as ProviderConfigsTable, Y as ProviderConfig, Z as ProviderGuardrailOverride, _ as validateTableData, _t as configVariantsSchema, a as createDatabaseFromConnection, at as TableName, b as ConfigVariantsTable, bt as datasetVersionRecordsSchema, c as executeWithSchema, ct as Trace, d as getMigrations, dt as Variant, et as Selectable, f as matchType, ft as VariantVersion, g as validatePartialTableData, gt as WorkspaceSettingsTable, h as parseTableData, ht as WorkspaceSettings, i as createDatabase, it as SpansTable, j as Environment, jt as providerConfigsSchema, k as DatasetVersionsTable, kt as playgroundRunsSchema, l as MigrationOptions, lt as TracesTable, m as parsePartialTableData, mt as VariantsTable, n as DatabaseOptions, nt as SpanEvent, o as detectDatabaseType, ot as TargetingRule, p as runAutoMigrations, pt as VariantVersionsTable, q as PlaygroundRunsTable, r as DatabaseType, rt as SpanEventsTable, s as createNeonDialect, st as TargetingRulesTable, t as DatabaseConnection, tt as Span, u as MigrationResult, ut as Updateable, v as Config, vt as configsSchema, w as DatasetRecord, wt as environmentsSchema, x as ConfigsTable, xt as datasetVersionsSchema, y as ConfigVariant, yt as datasetRecordsSchema, z as Insertable, zt as variantsSchema } from "./index-BlFAMkmT.mjs";
|
|
2
2
|
import gateway from "@llmops/gateway";
|
|
3
|
-
import * as kysely0 from "kysely";
|
|
4
3
|
import { Kysely } from "kysely";
|
|
5
4
|
import pino from "pino";
|
|
6
5
|
import z$1, { z } from "zod";
|
|
@@ -1383,1289 +1382,1106 @@ declare const createDatasetsDataLayer: (db: Kysely<Database>) => {
|
|
|
1383
1382
|
}[]>;
|
|
1384
1383
|
};
|
|
1385
1384
|
//#endregion
|
|
1386
|
-
//#region src/datalayer/
|
|
1387
|
-
declare const
|
|
1385
|
+
//#region src/datalayer/playgrounds.d.ts
|
|
1386
|
+
declare const createNewPlayground: z$1.ZodObject<{
|
|
1388
1387
|
name: z$1.ZodString;
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1388
|
+
datasetId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1389
|
+
columns: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodArray<z$1.ZodObject<{
|
|
1390
|
+
id: z$1.ZodString;
|
|
1391
|
+
name: z$1.ZodString;
|
|
1392
|
+
position: z$1.ZodNumber;
|
|
1393
|
+
providerConfigId: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNull]>>;
|
|
1394
|
+
providerSlug: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1395
|
+
modelName: z$1.ZodString;
|
|
1396
|
+
messages: z$1.ZodArray<z$1.ZodObject<{
|
|
1397
|
+
role: z$1.ZodEnum<{
|
|
1398
|
+
system: "system";
|
|
1399
|
+
user: "user";
|
|
1400
|
+
assistant: "assistant";
|
|
1401
|
+
}>;
|
|
1402
|
+
content: z$1.ZodString;
|
|
1403
|
+
}, z$1.core.$strip>>;
|
|
1404
|
+
temperature: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1405
|
+
maxTokens: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1406
|
+
topP: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1407
|
+
frequencyPenalty: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1408
|
+
presencePenalty: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1409
|
+
}, z$1.core.$strip>>>>;
|
|
1402
1410
|
}, z$1.core.$strip>;
|
|
1403
|
-
declare const
|
|
1404
|
-
|
|
1411
|
+
declare const updatePlayground: z$1.ZodObject<{
|
|
1412
|
+
playgroundId: z$1.ZodUUID;
|
|
1405
1413
|
name: z$1.ZodOptional<z$1.ZodString>;
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1414
|
+
datasetId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1415
|
+
columns: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodArray<z$1.ZodObject<{
|
|
1416
|
+
id: z$1.ZodString;
|
|
1417
|
+
name: z$1.ZodString;
|
|
1418
|
+
position: z$1.ZodNumber;
|
|
1419
|
+
providerConfigId: z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNull]>>;
|
|
1420
|
+
providerSlug: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1421
|
+
modelName: z$1.ZodString;
|
|
1422
|
+
messages: z$1.ZodArray<z$1.ZodObject<{
|
|
1423
|
+
role: z$1.ZodEnum<{
|
|
1424
|
+
system: "system";
|
|
1425
|
+
user: "user";
|
|
1426
|
+
assistant: "assistant";
|
|
1427
|
+
}>;
|
|
1428
|
+
content: z$1.ZodString;
|
|
1429
|
+
}, z$1.core.$strip>>;
|
|
1430
|
+
temperature: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1431
|
+
maxTokens: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1432
|
+
topP: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1433
|
+
frequencyPenalty: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1434
|
+
presencePenalty: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1435
|
+
}, z$1.core.$strip>>>>;
|
|
1417
1436
|
}, z$1.core.$strip>;
|
|
1418
|
-
declare const
|
|
1419
|
-
|
|
1437
|
+
declare const getPlaygroundById: z$1.ZodObject<{
|
|
1438
|
+
playgroundId: z$1.ZodUUID;
|
|
1420
1439
|
}, z$1.core.$strip>;
|
|
1421
|
-
declare const
|
|
1422
|
-
|
|
1440
|
+
declare const deletePlayground: z$1.ZodObject<{
|
|
1441
|
+
playgroundId: z$1.ZodUUID;
|
|
1423
1442
|
}, z$1.core.$strip>;
|
|
1424
|
-
declare const
|
|
1443
|
+
declare const listPlaygrounds: z$1.ZodObject<{
|
|
1425
1444
|
limit: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1426
1445
|
offset: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1427
|
-
hookType: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1428
|
-
beforeRequestHook: "beforeRequestHook";
|
|
1429
|
-
afterRequestHook: "afterRequestHook";
|
|
1430
|
-
}>>;
|
|
1431
|
-
enabled: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1432
1446
|
}, z$1.core.$strip>;
|
|
1433
|
-
declare const
|
|
1434
|
-
|
|
1447
|
+
declare const createPlaygroundDataLayer: (db: Kysely<Database>) => {
|
|
1448
|
+
createNewPlayground: (params: z$1.infer<typeof createNewPlayground>) => Promise<{
|
|
1435
1449
|
name: string;
|
|
1436
1450
|
id: string;
|
|
1437
1451
|
createdAt: Date;
|
|
1438
1452
|
updatedAt: Date;
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1453
|
+
datasetId: string | null;
|
|
1454
|
+
columns: {
|
|
1455
|
+
id: string;
|
|
1456
|
+
name: string;
|
|
1457
|
+
position: number;
|
|
1458
|
+
modelName: string;
|
|
1459
|
+
messages: {
|
|
1460
|
+
role: "system" | "user" | "assistant";
|
|
1461
|
+
content: string;
|
|
1462
|
+
}[];
|
|
1463
|
+
providerConfigId?: string | null | undefined;
|
|
1464
|
+
providerSlug?: string | null | undefined;
|
|
1465
|
+
temperature?: number | null | undefined;
|
|
1466
|
+
maxTokens?: number | null | undefined;
|
|
1467
|
+
topP?: number | null | undefined;
|
|
1468
|
+
frequencyPenalty?: number | null | undefined;
|
|
1469
|
+
presencePenalty?: number | null | undefined;
|
|
1470
|
+
}[] | null;
|
|
1446
1471
|
} | undefined>;
|
|
1447
|
-
|
|
1472
|
+
updatePlayground: (params: z$1.infer<typeof updatePlayground>) => Promise<{
|
|
1448
1473
|
name: string;
|
|
1449
1474
|
id: string;
|
|
1450
1475
|
createdAt: Date;
|
|
1451
1476
|
updatedAt: Date;
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1477
|
+
datasetId: string | null;
|
|
1478
|
+
columns: {
|
|
1479
|
+
id: string;
|
|
1480
|
+
name: string;
|
|
1481
|
+
position: number;
|
|
1482
|
+
modelName: string;
|
|
1483
|
+
messages: {
|
|
1484
|
+
role: "system" | "user" | "assistant";
|
|
1485
|
+
content: string;
|
|
1486
|
+
}[];
|
|
1487
|
+
providerConfigId?: string | null | undefined;
|
|
1488
|
+
providerSlug?: string | null | undefined;
|
|
1489
|
+
temperature?: number | null | undefined;
|
|
1490
|
+
maxTokens?: number | null | undefined;
|
|
1491
|
+
topP?: number | null | undefined;
|
|
1492
|
+
frequencyPenalty?: number | null | undefined;
|
|
1493
|
+
presencePenalty?: number | null | undefined;
|
|
1494
|
+
}[] | null;
|
|
1459
1495
|
} | undefined>;
|
|
1460
|
-
|
|
1496
|
+
getPlaygroundById: (params: z$1.infer<typeof getPlaygroundById>) => Promise<{
|
|
1461
1497
|
name: string;
|
|
1462
1498
|
id: string;
|
|
1463
1499
|
createdAt: Date;
|
|
1464
1500
|
updatedAt: Date;
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1501
|
+
datasetId: string | null;
|
|
1502
|
+
columns: {
|
|
1503
|
+
id: string;
|
|
1504
|
+
name: string;
|
|
1505
|
+
position: number;
|
|
1506
|
+
modelName: string;
|
|
1507
|
+
messages: {
|
|
1508
|
+
role: "system" | "user" | "assistant";
|
|
1509
|
+
content: string;
|
|
1510
|
+
}[];
|
|
1511
|
+
providerConfigId?: string | null | undefined;
|
|
1512
|
+
providerSlug?: string | null | undefined;
|
|
1513
|
+
temperature?: number | null | undefined;
|
|
1514
|
+
maxTokens?: number | null | undefined;
|
|
1515
|
+
topP?: number | null | undefined;
|
|
1516
|
+
frequencyPenalty?: number | null | undefined;
|
|
1517
|
+
presencePenalty?: number | null | undefined;
|
|
1518
|
+
}[] | null;
|
|
1472
1519
|
} | undefined>;
|
|
1473
|
-
|
|
1520
|
+
deletePlayground: (params: z$1.infer<typeof deletePlayground>) => Promise<{
|
|
1474
1521
|
name: string;
|
|
1475
1522
|
id: string;
|
|
1476
1523
|
createdAt: Date;
|
|
1477
1524
|
updatedAt: Date;
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1525
|
+
datasetId: string | null;
|
|
1526
|
+
columns: {
|
|
1527
|
+
id: string;
|
|
1528
|
+
name: string;
|
|
1529
|
+
position: number;
|
|
1530
|
+
modelName: string;
|
|
1531
|
+
messages: {
|
|
1532
|
+
role: "system" | "user" | "assistant";
|
|
1533
|
+
content: string;
|
|
1534
|
+
}[];
|
|
1535
|
+
providerConfigId?: string | null | undefined;
|
|
1536
|
+
providerSlug?: string | null | undefined;
|
|
1537
|
+
temperature?: number | null | undefined;
|
|
1538
|
+
maxTokens?: number | null | undefined;
|
|
1539
|
+
topP?: number | null | undefined;
|
|
1540
|
+
frequencyPenalty?: number | null | undefined;
|
|
1541
|
+
presencePenalty?: number | null | undefined;
|
|
1542
|
+
}[] | null;
|
|
1485
1543
|
} | undefined>;
|
|
1486
|
-
|
|
1487
|
-
name: string;
|
|
1488
|
-
id: string;
|
|
1489
|
-
createdAt: Date;
|
|
1490
|
-
updatedAt: Date;
|
|
1491
|
-
priority: number;
|
|
1492
|
-
enabled: boolean;
|
|
1493
|
-
pluginId: string;
|
|
1494
|
-
functionId: string;
|
|
1495
|
-
hookType: string;
|
|
1496
|
-
parameters: Record<string, unknown>;
|
|
1497
|
-
onFail: string;
|
|
1498
|
-
}[]>;
|
|
1499
|
-
countGuardrailConfigs: () => Promise<number>;
|
|
1500
|
-
/**
|
|
1501
|
-
* Get all enabled guardrails for a specific hook type
|
|
1502
|
-
* Ordered by priority (highest first)
|
|
1503
|
-
*/
|
|
1504
|
-
getEnabledGuardrailsByHookType: (hookType: "beforeRequestHook" | "afterRequestHook") => Promise<{
|
|
1544
|
+
listPlaygrounds: (params?: z$1.infer<typeof listPlaygrounds>) => Promise<{
|
|
1505
1545
|
name: string;
|
|
1506
1546
|
id: string;
|
|
1507
1547
|
createdAt: Date;
|
|
1508
1548
|
updatedAt: Date;
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1549
|
+
datasetId: string | null;
|
|
1550
|
+
columns: {
|
|
1551
|
+
id: string;
|
|
1552
|
+
name: string;
|
|
1553
|
+
position: number;
|
|
1554
|
+
modelName: string;
|
|
1555
|
+
messages: {
|
|
1556
|
+
role: "system" | "user" | "assistant";
|
|
1557
|
+
content: string;
|
|
1558
|
+
}[];
|
|
1559
|
+
providerConfigId?: string | null | undefined;
|
|
1560
|
+
providerSlug?: string | null | undefined;
|
|
1561
|
+
temperature?: number | null | undefined;
|
|
1562
|
+
maxTokens?: number | null | undefined;
|
|
1563
|
+
topP?: number | null | undefined;
|
|
1564
|
+
frequencyPenalty?: number | null | undefined;
|
|
1565
|
+
presencePenalty?: number | null | undefined;
|
|
1566
|
+
}[] | null;
|
|
1516
1567
|
}[]>;
|
|
1568
|
+
countPlaygrounds: () => Promise<number>;
|
|
1517
1569
|
};
|
|
1518
1570
|
//#endregion
|
|
1519
|
-
//#region src/datalayer/
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
model: z$1.ZodString;
|
|
1531
|
-
promptTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1532
|
-
completionTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1533
|
-
totalTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1534
|
-
cachedTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1535
|
-
cacheCreationTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1536
|
-
cost: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1537
|
-
cacheSavings: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1538
|
-
inputCost: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1539
|
-
outputCost: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1540
|
-
endpoint: z$1.ZodString;
|
|
1541
|
-
statusCode: z$1.ZodNumber;
|
|
1542
|
-
latencyMs: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1543
|
-
isStreaming: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
1544
|
-
userId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1545
|
-
tags: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
1546
|
-
guardrailResults: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodObject<{
|
|
1547
|
-
results: z$1.ZodArray<z$1.ZodObject<{
|
|
1548
|
-
checkId: z$1.ZodString;
|
|
1549
|
-
functionId: z$1.ZodString;
|
|
1550
|
-
hookType: z$1.ZodEnum<{
|
|
1551
|
-
beforeRequestHook: "beforeRequestHook";
|
|
1552
|
-
afterRequestHook: "afterRequestHook";
|
|
1553
|
-
}>;
|
|
1554
|
-
verdict: z$1.ZodBoolean;
|
|
1555
|
-
latencyMs: z$1.ZodNumber;
|
|
1556
|
-
}, z$1.core.$strip>>;
|
|
1557
|
-
action: z$1.ZodEnum<{
|
|
1558
|
-
allowed: "allowed";
|
|
1559
|
-
blocked: "blocked";
|
|
1560
|
-
logged: "logged";
|
|
1561
|
-
}>;
|
|
1562
|
-
totalLatencyMs: z$1.ZodNumber;
|
|
1563
|
-
}, z$1.core.$strip>>>;
|
|
1564
|
-
traceId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1565
|
-
spanId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1566
|
-
parentSpanId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1567
|
-
sessionId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1568
|
-
}, z$1.core.$strip>;
|
|
1569
|
-
type LLMRequestInsert = z$1.infer<typeof insertLLMRequestSchema>;
|
|
1570
|
-
/**
|
|
1571
|
-
* Schema for listing LLM requests
|
|
1572
|
-
*/
|
|
1573
|
-
declare const listRequestsSchema: z$1.ZodObject<{
|
|
1574
|
-
limit: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1575
|
-
offset: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1576
|
-
configId: z$1.ZodOptional<z$1.ZodString>;
|
|
1577
|
-
variantId: z$1.ZodOptional<z$1.ZodString>;
|
|
1578
|
-
environmentId: z$1.ZodOptional<z$1.ZodString>;
|
|
1579
|
-
providerConfigId: z$1.ZodOptional<z$1.ZodString>;
|
|
1580
|
-
provider: z$1.ZodOptional<z$1.ZodString>;
|
|
1581
|
-
model: z$1.ZodOptional<z$1.ZodString>;
|
|
1582
|
-
startDate: z$1.ZodOptional<z$1.ZodDate>;
|
|
1583
|
-
endDate: z$1.ZodOptional<z$1.ZodDate>;
|
|
1584
|
-
tags: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodArray<z$1.ZodString>>>;
|
|
1585
|
-
}, z$1.core.$strip>;
|
|
1586
|
-
/**
|
|
1587
|
-
* Schema for date range queries with optional filters
|
|
1588
|
-
*/
|
|
1589
|
-
declare const dateRangeSchema: z$1.ZodObject<{
|
|
1590
|
-
startDate: z$1.ZodDate;
|
|
1591
|
-
endDate: z$1.ZodDate;
|
|
1592
|
-
configId: z$1.ZodOptional<z$1.ZodString>;
|
|
1593
|
-
variantId: z$1.ZodOptional<z$1.ZodString>;
|
|
1594
|
-
environmentId: z$1.ZodOptional<z$1.ZodString>;
|
|
1595
|
-
tags: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodArray<z$1.ZodString>>>;
|
|
1596
|
-
}, z$1.core.$strip>;
|
|
1597
|
-
/**
|
|
1598
|
-
* Valid groupBy values for cost summary queries
|
|
1599
|
-
*/
|
|
1600
|
-
declare const COST_SUMMARY_GROUP_BY: readonly ["day", "hour", "model", "provider", "endpoint", "tags"];
|
|
1601
|
-
type CostSummaryGroupBy = (typeof COST_SUMMARY_GROUP_BY)[number];
|
|
1602
|
-
/**
|
|
1603
|
-
* Schema for cost summary with grouping
|
|
1604
|
-
*/
|
|
1605
|
-
declare const costSummarySchema: z$1.ZodObject<{
|
|
1606
|
-
startDate: z$1.ZodDate;
|
|
1607
|
-
endDate: z$1.ZodDate;
|
|
1608
|
-
configId: z$1.ZodOptional<z$1.ZodString>;
|
|
1609
|
-
variantId: z$1.ZodOptional<z$1.ZodString>;
|
|
1610
|
-
environmentId: z$1.ZodOptional<z$1.ZodString>;
|
|
1611
|
-
tags: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodArray<z$1.ZodString>>>;
|
|
1612
|
-
groupBy: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1613
|
-
provider: "provider";
|
|
1614
|
-
model: "model";
|
|
1615
|
-
endpoint: "endpoint";
|
|
1616
|
-
tags: "tags";
|
|
1617
|
-
day: "day";
|
|
1618
|
-
hour: "hour";
|
|
1571
|
+
//#region src/datalayer/playgroundResults.d.ts
|
|
1572
|
+
declare const createPlaygroundResult: z$1.ZodObject<{
|
|
1573
|
+
runId: z$1.ZodString;
|
|
1574
|
+
columnId: z$1.ZodString;
|
|
1575
|
+
datasetRecordId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1576
|
+
inputVariables: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
1577
|
+
status: z$1.ZodDefault<z$1.ZodEnum<{
|
|
1578
|
+
pending: "pending";
|
|
1579
|
+
running: "running";
|
|
1580
|
+
completed: "completed";
|
|
1581
|
+
failed: "failed";
|
|
1619
1582
|
}>>;
|
|
1620
|
-
tagKeys: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
1621
1583
|
}, z$1.core.$strip>;
|
|
1622
|
-
declare const
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1584
|
+
declare const createPlaygroundResultsBatch: z$1.ZodObject<{
|
|
1585
|
+
results: z$1.ZodArray<z$1.ZodObject<{
|
|
1586
|
+
runId: z$1.ZodString;
|
|
1587
|
+
columnId: z$1.ZodString;
|
|
1588
|
+
datasetRecordId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1589
|
+
inputVariables: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
1590
|
+
status: z$1.ZodDefault<z$1.ZodEnum<{
|
|
1591
|
+
pending: "pending";
|
|
1592
|
+
running: "running";
|
|
1593
|
+
completed: "completed";
|
|
1594
|
+
failed: "failed";
|
|
1595
|
+
}>>;
|
|
1596
|
+
}, z$1.core.$strip>>;
|
|
1597
|
+
}, z$1.core.$strip>;
|
|
1598
|
+
declare const updatePlaygroundResult: z$1.ZodObject<{
|
|
1599
|
+
resultId: z$1.ZodString;
|
|
1600
|
+
outputContent: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1601
|
+
status: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1602
|
+
pending: "pending";
|
|
1603
|
+
running: "running";
|
|
1604
|
+
completed: "completed";
|
|
1605
|
+
failed: "failed";
|
|
1606
|
+
}>>;
|
|
1607
|
+
error: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1608
|
+
latencyMs: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1609
|
+
promptTokens: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1610
|
+
completionTokens: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1611
|
+
totalTokens: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1612
|
+
cost: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1613
|
+
}, z$1.core.$strip>;
|
|
1614
|
+
declare const getPlaygroundResultById: z$1.ZodObject<{
|
|
1615
|
+
resultId: z$1.ZodString;
|
|
1616
|
+
}, z$1.core.$strip>;
|
|
1617
|
+
declare const listPlaygroundResults: z$1.ZodObject<{
|
|
1618
|
+
runId: z$1.ZodString;
|
|
1619
|
+
columnId: z$1.ZodOptional<z$1.ZodString>;
|
|
1620
|
+
limit: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1621
|
+
offset: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1622
|
+
}, z$1.core.$strip>;
|
|
1623
|
+
declare const deletePlaygroundResultsByRunId: z$1.ZodObject<{
|
|
1624
|
+
runId: z$1.ZodString;
|
|
1625
|
+
}, z$1.core.$strip>;
|
|
1626
|
+
declare const createPlaygroundResultsDataLayer: (db: Kysely<Database>) => {
|
|
1627
|
+
createPlaygroundResult: (params: z$1.infer<typeof createPlaygroundResult>) => Promise<{
|
|
1628
|
+
error: string | null;
|
|
1634
1629
|
id: string;
|
|
1635
1630
|
createdAt: Date;
|
|
1636
1631
|
updatedAt: Date;
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
model: string;
|
|
1649
|
-
cachedTokens: number;
|
|
1650
|
-
cacheCreationTokens: number;
|
|
1651
|
-
cacheSavings: number;
|
|
1652
|
-
inputCost: number;
|
|
1653
|
-
outputCost: number;
|
|
1654
|
-
endpoint: string;
|
|
1655
|
-
statusCode: number;
|
|
1656
|
-
isStreaming: boolean;
|
|
1657
|
-
userId: string | null;
|
|
1658
|
-
tags: Record<string, string>;
|
|
1659
|
-
guardrailResults: {
|
|
1660
|
-
results: {
|
|
1661
|
-
checkId: string;
|
|
1662
|
-
functionId: string;
|
|
1663
|
-
hookType: "beforeRequestHook" | "afterRequestHook";
|
|
1664
|
-
verdict: boolean;
|
|
1665
|
-
latencyMs: number;
|
|
1666
|
-
}[];
|
|
1667
|
-
action: "allowed" | "blocked" | "logged";
|
|
1668
|
-
totalLatencyMs: number;
|
|
1669
|
-
} | null;
|
|
1670
|
-
traceId: string | null;
|
|
1671
|
-
spanId: string | null;
|
|
1672
|
-
parentSpanId: string | null;
|
|
1673
|
-
sessionId: string | null;
|
|
1632
|
+
status: string;
|
|
1633
|
+
runId: string;
|
|
1634
|
+
columnId: string;
|
|
1635
|
+
datasetRecordId: string | null;
|
|
1636
|
+
inputVariables: Record<string, unknown>;
|
|
1637
|
+
outputContent: string | null;
|
|
1638
|
+
latencyMs: number | null;
|
|
1639
|
+
promptTokens: number | null;
|
|
1640
|
+
completionTokens: number | null;
|
|
1641
|
+
totalTokens: number | null;
|
|
1642
|
+
cost: number | null;
|
|
1674
1643
|
} | undefined>;
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
* Returns data and total count for pagination
|
|
1678
|
-
*/
|
|
1679
|
-
listRequests: (params?: z$1.infer<typeof listRequestsSchema>) => Promise<{
|
|
1680
|
-
data: {
|
|
1681
|
-
id: string;
|
|
1682
|
-
createdAt: Date;
|
|
1683
|
-
updatedAt: Date;
|
|
1684
|
-
variantId: string | null;
|
|
1685
|
-
provider: string;
|
|
1686
|
-
environmentId: string | null;
|
|
1687
|
-
configId: string | null;
|
|
1688
|
-
providerConfigId: string | null;
|
|
1689
|
-
latencyMs: number;
|
|
1690
|
-
promptTokens: number;
|
|
1691
|
-
completionTokens: number;
|
|
1692
|
-
totalTokens: number;
|
|
1693
|
-
cost: number;
|
|
1694
|
-
requestId: string;
|
|
1695
|
-
model: string;
|
|
1696
|
-
cachedTokens: number;
|
|
1697
|
-
cacheCreationTokens: number;
|
|
1698
|
-
cacheSavings: number;
|
|
1699
|
-
inputCost: number;
|
|
1700
|
-
outputCost: number;
|
|
1701
|
-
endpoint: string;
|
|
1702
|
-
statusCode: number;
|
|
1703
|
-
isStreaming: boolean;
|
|
1704
|
-
userId: string | null;
|
|
1705
|
-
tags: Record<string, string>;
|
|
1706
|
-
guardrailResults: {
|
|
1707
|
-
results: {
|
|
1708
|
-
checkId: string;
|
|
1709
|
-
functionId: string;
|
|
1710
|
-
hookType: "beforeRequestHook" | "afterRequestHook";
|
|
1711
|
-
verdict: boolean;
|
|
1712
|
-
latencyMs: number;
|
|
1713
|
-
}[];
|
|
1714
|
-
action: "allowed" | "blocked" | "logged";
|
|
1715
|
-
totalLatencyMs: number;
|
|
1716
|
-
} | null;
|
|
1717
|
-
traceId: string | null;
|
|
1718
|
-
spanId: string | null;
|
|
1719
|
-
parentSpanId: string | null;
|
|
1720
|
-
sessionId: string | null;
|
|
1721
|
-
}[];
|
|
1722
|
-
total: number;
|
|
1723
|
-
limit: number;
|
|
1724
|
-
offset: number;
|
|
1725
|
-
}>;
|
|
1726
|
-
/**
|
|
1727
|
-
* Get a single request by requestId
|
|
1728
|
-
*/
|
|
1729
|
-
getRequestByRequestId: (requestId: string) => Promise<{
|
|
1644
|
+
createPlaygroundResultsBatch: (params: z$1.infer<typeof createPlaygroundResultsBatch>) => Promise<{
|
|
1645
|
+
error: string | null;
|
|
1730
1646
|
id: string;
|
|
1731
1647
|
createdAt: Date;
|
|
1732
1648
|
updatedAt: Date;
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
latencyMs: number;
|
|
1762
|
-
}[];
|
|
1763
|
-
action: "allowed" | "blocked" | "logged";
|
|
1764
|
-
totalLatencyMs: number;
|
|
1765
|
-
} | null;
|
|
1766
|
-
traceId: string | null;
|
|
1767
|
-
spanId: string | null;
|
|
1768
|
-
parentSpanId: string | null;
|
|
1769
|
-
sessionId: string | null;
|
|
1649
|
+
status: string;
|
|
1650
|
+
runId: string;
|
|
1651
|
+
columnId: string;
|
|
1652
|
+
datasetRecordId: string | null;
|
|
1653
|
+
inputVariables: Record<string, unknown>;
|
|
1654
|
+
outputContent: string | null;
|
|
1655
|
+
latencyMs: number | null;
|
|
1656
|
+
promptTokens: number | null;
|
|
1657
|
+
completionTokens: number | null;
|
|
1658
|
+
totalTokens: number | null;
|
|
1659
|
+
cost: number | null;
|
|
1660
|
+
}[]>;
|
|
1661
|
+
updatePlaygroundResult: (params: z$1.infer<typeof updatePlaygroundResult>) => Promise<{
|
|
1662
|
+
error: string | null;
|
|
1663
|
+
id: string;
|
|
1664
|
+
createdAt: Date;
|
|
1665
|
+
updatedAt: Date;
|
|
1666
|
+
status: string;
|
|
1667
|
+
runId: string;
|
|
1668
|
+
columnId: string;
|
|
1669
|
+
datasetRecordId: string | null;
|
|
1670
|
+
inputVariables: Record<string, unknown>;
|
|
1671
|
+
outputContent: string | null;
|
|
1672
|
+
latencyMs: number | null;
|
|
1673
|
+
promptTokens: number | null;
|
|
1674
|
+
completionTokens: number | null;
|
|
1675
|
+
totalTokens: number | null;
|
|
1676
|
+
cost: number | null;
|
|
1770
1677
|
} | undefined>;
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1678
|
+
getPlaygroundResultById: (params: z$1.infer<typeof getPlaygroundResultById>) => Promise<{
|
|
1679
|
+
error: string | null;
|
|
1680
|
+
id: string;
|
|
1681
|
+
createdAt: Date;
|
|
1682
|
+
updatedAt: Date;
|
|
1683
|
+
status: string;
|
|
1684
|
+
runId: string;
|
|
1685
|
+
columnId: string;
|
|
1686
|
+
datasetRecordId: string | null;
|
|
1687
|
+
inputVariables: Record<string, unknown>;
|
|
1688
|
+
outputContent: string | null;
|
|
1689
|
+
latencyMs: number | null;
|
|
1690
|
+
promptTokens: number | null;
|
|
1691
|
+
completionTokens: number | null;
|
|
1692
|
+
totalTokens: number | null;
|
|
1693
|
+
cost: number | null;
|
|
1784
1694
|
} | undefined>;
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
getCostByProvider: (params: z$1.infer<typeof dateRangeSchema>) => Promise<{
|
|
1802
|
-
provider: string;
|
|
1803
|
-
totalCost: number;
|
|
1804
|
-
totalInputCost: number;
|
|
1805
|
-
totalOutputCost: number;
|
|
1806
|
-
totalTokens: number;
|
|
1807
|
-
requestCount: number;
|
|
1808
|
-
avgLatencyMs: number;
|
|
1809
|
-
}[]>;
|
|
1810
|
-
/**
|
|
1811
|
-
* Get daily cost summary
|
|
1812
|
-
*/
|
|
1813
|
-
getDailyCosts: (params: z$1.infer<typeof dateRangeSchema>) => Promise<{
|
|
1814
|
-
totalCost: number;
|
|
1815
|
-
totalInputCost: number;
|
|
1816
|
-
totalOutputCost: number;
|
|
1817
|
-
totalTokens: number;
|
|
1818
|
-
requestCount: number;
|
|
1819
|
-
date: string;
|
|
1820
|
-
}[]>;
|
|
1821
|
-
/**
|
|
1822
|
-
* Get cost summary with flexible grouping and optional filters
|
|
1823
|
-
*/
|
|
1824
|
-
getCostSummary: (params: z$1.infer<typeof costSummarySchema>) => Promise<{
|
|
1825
|
-
totalCost: number;
|
|
1826
|
-
requestCount: number;
|
|
1827
|
-
groupKey: string;
|
|
1695
|
+
listPlaygroundResults: (params: z$1.infer<typeof listPlaygroundResults>) => Promise<{
|
|
1696
|
+
error: string | null;
|
|
1697
|
+
id: string;
|
|
1698
|
+
createdAt: Date;
|
|
1699
|
+
updatedAt: Date;
|
|
1700
|
+
status: string;
|
|
1701
|
+
runId: string;
|
|
1702
|
+
columnId: string;
|
|
1703
|
+
datasetRecordId: string | null;
|
|
1704
|
+
inputVariables: Record<string, unknown>;
|
|
1705
|
+
outputContent: string | null;
|
|
1706
|
+
latencyMs: number | null;
|
|
1707
|
+
promptTokens: number | null;
|
|
1708
|
+
completionTokens: number | null;
|
|
1709
|
+
totalTokens: number | null;
|
|
1710
|
+
cost: number | null;
|
|
1828
1711
|
}[]>;
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
getDistinctTags: () => Promise<{
|
|
1846
|
-
key: string;
|
|
1847
|
-
value: string;
|
|
1712
|
+
deletePlaygroundResultsByRunId: (params: z$1.infer<typeof deletePlaygroundResultsByRunId>) => Promise<{
|
|
1713
|
+
error: string | null;
|
|
1714
|
+
id: string;
|
|
1715
|
+
createdAt: Date;
|
|
1716
|
+
updatedAt: Date;
|
|
1717
|
+
status: string;
|
|
1718
|
+
runId: string;
|
|
1719
|
+
columnId: string;
|
|
1720
|
+
datasetRecordId: string | null;
|
|
1721
|
+
inputVariables: Record<string, unknown>;
|
|
1722
|
+
outputContent: string | null;
|
|
1723
|
+
latencyMs: number | null;
|
|
1724
|
+
promptTokens: number | null;
|
|
1725
|
+
completionTokens: number | null;
|
|
1726
|
+
totalTokens: number | null;
|
|
1727
|
+
cost: number | null;
|
|
1848
1728
|
}[]>;
|
|
1729
|
+
countPlaygroundResults: (runId: string) => Promise<number>;
|
|
1730
|
+
countCompletedPlaygroundResults: (runId: string) => Promise<number>;
|
|
1849
1731
|
};
|
|
1850
1732
|
//#endregion
|
|
1851
|
-
//#region src/datalayer/
|
|
1852
|
-
declare const
|
|
1853
|
-
|
|
1854
|
-
datasetId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1855
|
-
columns: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodArray<z$1.ZodObject<{
|
|
1856
|
-
id: z$1.ZodString;
|
|
1857
|
-
name: z$1.ZodString;
|
|
1858
|
-
position: z$1.ZodNumber;
|
|
1859
|
-
providerConfigId: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNull]>;
|
|
1860
|
-
modelName: z$1.ZodString;
|
|
1861
|
-
messages: z$1.ZodArray<z$1.ZodObject<{
|
|
1862
|
-
role: z$1.ZodEnum<{
|
|
1863
|
-
system: "system";
|
|
1864
|
-
user: "user";
|
|
1865
|
-
assistant: "assistant";
|
|
1866
|
-
}>;
|
|
1867
|
-
content: z$1.ZodString;
|
|
1868
|
-
}, z$1.core.$strip>>;
|
|
1869
|
-
temperature: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1870
|
-
maxTokens: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1871
|
-
topP: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1872
|
-
frequencyPenalty: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1873
|
-
presencePenalty: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1874
|
-
configId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1875
|
-
variantId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1876
|
-
variantVersionId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1877
|
-
}, z$1.core.$strip>>>>;
|
|
1878
|
-
}, z$1.core.$strip>;
|
|
1879
|
-
declare const updatePlayground: z$1.ZodObject<{
|
|
1880
|
-
playgroundId: z$1.ZodUUID;
|
|
1881
|
-
name: z$1.ZodOptional<z$1.ZodString>;
|
|
1733
|
+
//#region src/datalayer/playgroundRuns.d.ts
|
|
1734
|
+
declare const createPlaygroundRun: z$1.ZodObject<{
|
|
1735
|
+
playgroundId: z$1.ZodString;
|
|
1882
1736
|
datasetId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
user: "user";
|
|
1893
|
-
assistant: "assistant";
|
|
1894
|
-
}>;
|
|
1895
|
-
content: z$1.ZodString;
|
|
1896
|
-
}, z$1.core.$strip>>;
|
|
1897
|
-
temperature: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1898
|
-
maxTokens: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1899
|
-
topP: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1900
|
-
frequencyPenalty: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1901
|
-
presencePenalty: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
1902
|
-
configId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1903
|
-
variantId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1904
|
-
variantVersionId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1905
|
-
}, z$1.core.$strip>>>>;
|
|
1737
|
+
datasetVersionId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1738
|
+
status: z$1.ZodDefault<z$1.ZodEnum<{
|
|
1739
|
+
pending: "pending";
|
|
1740
|
+
running: "running";
|
|
1741
|
+
completed: "completed";
|
|
1742
|
+
failed: "failed";
|
|
1743
|
+
cancelled: "cancelled";
|
|
1744
|
+
}>>;
|
|
1745
|
+
totalRecords: z$1.ZodDefault<z$1.ZodNumber>;
|
|
1906
1746
|
}, z$1.core.$strip>;
|
|
1907
|
-
declare const
|
|
1908
|
-
|
|
1747
|
+
declare const updatePlaygroundRun: z$1.ZodObject<{
|
|
1748
|
+
runId: z$1.ZodString;
|
|
1749
|
+
status: z$1.ZodOptional<z$1.ZodEnum<{
|
|
1750
|
+
pending: "pending";
|
|
1751
|
+
running: "running";
|
|
1752
|
+
completed: "completed";
|
|
1753
|
+
failed: "failed";
|
|
1754
|
+
cancelled: "cancelled";
|
|
1755
|
+
}>>;
|
|
1756
|
+
startedAt: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
1757
|
+
completedAt: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
1758
|
+
completedRecords: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1909
1759
|
}, z$1.core.$strip>;
|
|
1910
|
-
declare const
|
|
1911
|
-
|
|
1760
|
+
declare const getPlaygroundRunById: z$1.ZodObject<{
|
|
1761
|
+
runId: z$1.ZodString;
|
|
1912
1762
|
}, z$1.core.$strip>;
|
|
1913
|
-
declare const
|
|
1763
|
+
declare const listPlaygroundRuns: z$1.ZodObject<{
|
|
1764
|
+
playgroundId: z$1.ZodString;
|
|
1914
1765
|
limit: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1915
1766
|
offset: z$1.ZodOptional<z$1.ZodNumber>;
|
|
1916
1767
|
}, z$1.core.$strip>;
|
|
1917
|
-
declare const
|
|
1918
|
-
|
|
1919
|
-
|
|
1768
|
+
declare const deletePlaygroundRun: z$1.ZodObject<{
|
|
1769
|
+
runId: z$1.ZodString;
|
|
1770
|
+
}, z$1.core.$strip>;
|
|
1771
|
+
declare const createPlaygroundRunsDataLayer: (db: Kysely<Database>) => {
|
|
1772
|
+
createPlaygroundRun: (params: z$1.infer<typeof createPlaygroundRun>) => Promise<{
|
|
1920
1773
|
id: string;
|
|
1921
1774
|
createdAt: Date;
|
|
1922
1775
|
updatedAt: Date;
|
|
1923
1776
|
datasetId: string | null;
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
role: "system" | "user" | "assistant";
|
|
1932
|
-
content: string;
|
|
1933
|
-
}[];
|
|
1934
|
-
temperature?: number | null | undefined;
|
|
1935
|
-
maxTokens?: number | null | undefined;
|
|
1936
|
-
topP?: number | null | undefined;
|
|
1937
|
-
frequencyPenalty?: number | null | undefined;
|
|
1938
|
-
presencePenalty?: number | null | undefined;
|
|
1939
|
-
configId?: string | null | undefined;
|
|
1940
|
-
variantId?: string | null | undefined;
|
|
1941
|
-
variantVersionId?: string | null | undefined;
|
|
1942
|
-
}[] | null;
|
|
1777
|
+
playgroundId: string;
|
|
1778
|
+
datasetVersionId: string | null;
|
|
1779
|
+
status: string;
|
|
1780
|
+
startedAt: Date | null;
|
|
1781
|
+
completedAt: Date | null;
|
|
1782
|
+
totalRecords: number;
|
|
1783
|
+
completedRecords: number;
|
|
1943
1784
|
} | undefined>;
|
|
1944
|
-
|
|
1945
|
-
name: string;
|
|
1785
|
+
updatePlaygroundRun: (params: z$1.infer<typeof updatePlaygroundRun>) => Promise<{
|
|
1946
1786
|
id: string;
|
|
1947
1787
|
createdAt: Date;
|
|
1948
1788
|
updatedAt: Date;
|
|
1949
1789
|
datasetId: string | null;
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
role: "system" | "user" | "assistant";
|
|
1958
|
-
content: string;
|
|
1959
|
-
}[];
|
|
1960
|
-
temperature?: number | null | undefined;
|
|
1961
|
-
maxTokens?: number | null | undefined;
|
|
1962
|
-
topP?: number | null | undefined;
|
|
1963
|
-
frequencyPenalty?: number | null | undefined;
|
|
1964
|
-
presencePenalty?: number | null | undefined;
|
|
1965
|
-
configId?: string | null | undefined;
|
|
1966
|
-
variantId?: string | null | undefined;
|
|
1967
|
-
variantVersionId?: string | null | undefined;
|
|
1968
|
-
}[] | null;
|
|
1790
|
+
playgroundId: string;
|
|
1791
|
+
datasetVersionId: string | null;
|
|
1792
|
+
status: string;
|
|
1793
|
+
startedAt: Date | null;
|
|
1794
|
+
completedAt: Date | null;
|
|
1795
|
+
totalRecords: number;
|
|
1796
|
+
completedRecords: number;
|
|
1969
1797
|
} | undefined>;
|
|
1970
|
-
|
|
1971
|
-
name: string;
|
|
1798
|
+
getPlaygroundRunById: (params: z$1.infer<typeof getPlaygroundRunById>) => Promise<{
|
|
1972
1799
|
id: string;
|
|
1973
1800
|
createdAt: Date;
|
|
1974
1801
|
updatedAt: Date;
|
|
1975
1802
|
datasetId: string | null;
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
role: "system" | "user" | "assistant";
|
|
1984
|
-
content: string;
|
|
1985
|
-
}[];
|
|
1986
|
-
temperature?: number | null | undefined;
|
|
1987
|
-
maxTokens?: number | null | undefined;
|
|
1988
|
-
topP?: number | null | undefined;
|
|
1989
|
-
frequencyPenalty?: number | null | undefined;
|
|
1990
|
-
presencePenalty?: number | null | undefined;
|
|
1991
|
-
configId?: string | null | undefined;
|
|
1992
|
-
variantId?: string | null | undefined;
|
|
1993
|
-
variantVersionId?: string | null | undefined;
|
|
1994
|
-
}[] | null;
|
|
1803
|
+
playgroundId: string;
|
|
1804
|
+
datasetVersionId: string | null;
|
|
1805
|
+
status: string;
|
|
1806
|
+
startedAt: Date | null;
|
|
1807
|
+
completedAt: Date | null;
|
|
1808
|
+
totalRecords: number;
|
|
1809
|
+
completedRecords: number;
|
|
1995
1810
|
} | undefined>;
|
|
1996
|
-
|
|
1997
|
-
name: string;
|
|
1811
|
+
listPlaygroundRuns: (params: z$1.infer<typeof listPlaygroundRuns>) => Promise<{
|
|
1998
1812
|
id: string;
|
|
1999
1813
|
createdAt: Date;
|
|
2000
1814
|
updatedAt: Date;
|
|
2001
1815
|
datasetId: string | null;
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
}[];
|
|
2012
|
-
temperature?: number | null | undefined;
|
|
2013
|
-
maxTokens?: number | null | undefined;
|
|
2014
|
-
topP?: number | null | undefined;
|
|
2015
|
-
frequencyPenalty?: number | null | undefined;
|
|
2016
|
-
presencePenalty?: number | null | undefined;
|
|
2017
|
-
configId?: string | null | undefined;
|
|
2018
|
-
variantId?: string | null | undefined;
|
|
2019
|
-
variantVersionId?: string | null | undefined;
|
|
2020
|
-
}[] | null;
|
|
2021
|
-
} | undefined>;
|
|
2022
|
-
listPlaygrounds: (params?: z$1.infer<typeof listPlaygrounds>) => Promise<{
|
|
2023
|
-
name: string;
|
|
1816
|
+
playgroundId: string;
|
|
1817
|
+
datasetVersionId: string | null;
|
|
1818
|
+
status: string;
|
|
1819
|
+
startedAt: Date | null;
|
|
1820
|
+
completedAt: Date | null;
|
|
1821
|
+
totalRecords: number;
|
|
1822
|
+
completedRecords: number;
|
|
1823
|
+
}[]>;
|
|
1824
|
+
deletePlaygroundRun: (params: z$1.infer<typeof deletePlaygroundRun>) => Promise<{
|
|
2024
1825
|
id: string;
|
|
2025
1826
|
createdAt: Date;
|
|
2026
1827
|
updatedAt: Date;
|
|
2027
1828
|
datasetId: string | null;
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
}[];
|
|
2038
|
-
temperature?: number | null | undefined;
|
|
2039
|
-
maxTokens?: number | null | undefined;
|
|
2040
|
-
topP?: number | null | undefined;
|
|
2041
|
-
frequencyPenalty?: number | null | undefined;
|
|
2042
|
-
presencePenalty?: number | null | undefined;
|
|
2043
|
-
configId?: string | null | undefined;
|
|
2044
|
-
variantId?: string | null | undefined;
|
|
2045
|
-
variantVersionId?: string | null | undefined;
|
|
2046
|
-
}[] | null;
|
|
2047
|
-
}[]>;
|
|
2048
|
-
countPlaygrounds: () => Promise<number>;
|
|
1829
|
+
playgroundId: string;
|
|
1830
|
+
datasetVersionId: string | null;
|
|
1831
|
+
status: string;
|
|
1832
|
+
startedAt: Date | null;
|
|
1833
|
+
completedAt: Date | null;
|
|
1834
|
+
totalRecords: number;
|
|
1835
|
+
completedRecords: number;
|
|
1836
|
+
} | undefined>;
|
|
1837
|
+
countPlaygroundRuns: (playgroundId: string) => Promise<number>;
|
|
2049
1838
|
};
|
|
2050
1839
|
//#endregion
|
|
2051
|
-
//#region src/datalayer/
|
|
2052
|
-
declare const
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
inputVariables: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2057
|
-
status: z$1.ZodDefault<z$1.ZodEnum<{
|
|
2058
|
-
pending: "pending";
|
|
2059
|
-
running: "running";
|
|
2060
|
-
completed: "completed";
|
|
2061
|
-
failed: "failed";
|
|
2062
|
-
}>>;
|
|
2063
|
-
}, z$1.core.$strip>;
|
|
2064
|
-
declare const createPlaygroundResultsBatch: z$1.ZodObject<{
|
|
2065
|
-
results: z$1.ZodArray<z$1.ZodObject<{
|
|
2066
|
-
runId: z$1.ZodString;
|
|
2067
|
-
columnId: z$1.ZodString;
|
|
2068
|
-
datasetRecordId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2069
|
-
inputVariables: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2070
|
-
status: z$1.ZodDefault<z$1.ZodEnum<{
|
|
2071
|
-
pending: "pending";
|
|
2072
|
-
running: "running";
|
|
2073
|
-
completed: "completed";
|
|
2074
|
-
failed: "failed";
|
|
2075
|
-
}>>;
|
|
2076
|
-
}, z$1.core.$strip>>;
|
|
2077
|
-
}, z$1.core.$strip>;
|
|
2078
|
-
declare const updatePlaygroundResult: z$1.ZodObject<{
|
|
2079
|
-
resultId: z$1.ZodString;
|
|
2080
|
-
outputContent: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2081
|
-
status: z$1.ZodOptional<z$1.ZodEnum<{
|
|
2082
|
-
pending: "pending";
|
|
2083
|
-
running: "running";
|
|
2084
|
-
completed: "completed";
|
|
2085
|
-
failed: "failed";
|
|
2086
|
-
}>>;
|
|
2087
|
-
error: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2088
|
-
latencyMs: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
2089
|
-
promptTokens: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
2090
|
-
completionTokens: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
2091
|
-
totalTokens: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
2092
|
-
cost: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
2093
|
-
}, z$1.core.$strip>;
|
|
2094
|
-
declare const getPlaygroundResultById: z$1.ZodObject<{
|
|
2095
|
-
resultId: z$1.ZodString;
|
|
2096
|
-
}, z$1.core.$strip>;
|
|
2097
|
-
declare const listPlaygroundResults: z$1.ZodObject<{
|
|
2098
|
-
runId: z$1.ZodString;
|
|
2099
|
-
columnId: z$1.ZodOptional<z$1.ZodString>;
|
|
2100
|
-
limit: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2101
|
-
offset: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2102
|
-
}, z$1.core.$strip>;
|
|
2103
|
-
declare const deletePlaygroundResultsByRunId: z$1.ZodObject<{
|
|
2104
|
-
runId: z$1.ZodString;
|
|
1840
|
+
//#region src/datalayer/workspaceSettings.d.ts
|
|
1841
|
+
declare const updateWorkspaceSettings: z$1.ZodObject<{
|
|
1842
|
+
name: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
1843
|
+
setupComplete: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
1844
|
+
superAdminId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2105
1845
|
}, z$1.core.$strip>;
|
|
2106
|
-
declare const
|
|
2107
|
-
|
|
2108
|
-
|
|
1846
|
+
declare const createWorkspaceSettingsDataLayer: (db: Kysely<Database>) => {
|
|
1847
|
+
/**
|
|
1848
|
+
* Get workspace settings (creates default if not exists)
|
|
1849
|
+
*/
|
|
1850
|
+
getWorkspaceSettings: () => Promise<{
|
|
1851
|
+
name: string | null;
|
|
2109
1852
|
id: string;
|
|
2110
1853
|
createdAt: Date;
|
|
2111
1854
|
updatedAt: Date;
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
columnId: string;
|
|
2115
|
-
datasetRecordId: string | null;
|
|
2116
|
-
inputVariables: Record<string, unknown>;
|
|
2117
|
-
outputContent: string | null;
|
|
2118
|
-
latencyMs: number | null;
|
|
2119
|
-
promptTokens: number | null;
|
|
2120
|
-
completionTokens: number | null;
|
|
2121
|
-
totalTokens: number | null;
|
|
2122
|
-
cost: number | null;
|
|
1855
|
+
setupComplete: boolean;
|
|
1856
|
+
superAdminId: string | null;
|
|
2123
1857
|
} | undefined>;
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
status: string;
|
|
2130
|
-
runId: string;
|
|
2131
|
-
columnId: string;
|
|
2132
|
-
datasetRecordId: string | null;
|
|
2133
|
-
inputVariables: Record<string, unknown>;
|
|
2134
|
-
outputContent: string | null;
|
|
2135
|
-
latencyMs: number | null;
|
|
2136
|
-
promptTokens: number | null;
|
|
2137
|
-
completionTokens: number | null;
|
|
2138
|
-
totalTokens: number | null;
|
|
2139
|
-
cost: number | null;
|
|
2140
|
-
}[]>;
|
|
2141
|
-
updatePlaygroundResult: (params: z$1.infer<typeof updatePlaygroundResult>) => Promise<{
|
|
2142
|
-
error: string | null;
|
|
1858
|
+
/**
|
|
1859
|
+
* Update workspace settings
|
|
1860
|
+
*/
|
|
1861
|
+
updateWorkspaceSettings: (params: z$1.infer<typeof updateWorkspaceSettings>) => Promise<{
|
|
1862
|
+
name: string | null;
|
|
2143
1863
|
id: string;
|
|
2144
1864
|
createdAt: Date;
|
|
2145
1865
|
updatedAt: Date;
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
columnId: string;
|
|
2149
|
-
datasetRecordId: string | null;
|
|
2150
|
-
inputVariables: Record<string, unknown>;
|
|
2151
|
-
outputContent: string | null;
|
|
2152
|
-
latencyMs: number | null;
|
|
2153
|
-
promptTokens: number | null;
|
|
2154
|
-
completionTokens: number | null;
|
|
2155
|
-
totalTokens: number | null;
|
|
2156
|
-
cost: number | null;
|
|
1866
|
+
setupComplete: boolean;
|
|
1867
|
+
superAdminId: string | null;
|
|
2157
1868
|
} | undefined>;
|
|
2158
|
-
|
|
2159
|
-
|
|
1869
|
+
/**
|
|
1870
|
+
* Get the super admin user ID
|
|
1871
|
+
*/
|
|
1872
|
+
getSuperAdminId: () => Promise<string | null>;
|
|
1873
|
+
/**
|
|
1874
|
+
* Set the super admin user ID (only if not already set)
|
|
1875
|
+
*/
|
|
1876
|
+
setSuperAdminId: (userId: string) => Promise<boolean>;
|
|
1877
|
+
/**
|
|
1878
|
+
* Check if initial setup has been completed
|
|
1879
|
+
*/
|
|
1880
|
+
isSetupComplete: () => Promise<boolean>;
|
|
1881
|
+
/**
|
|
1882
|
+
* Mark initial setup as complete
|
|
1883
|
+
*/
|
|
1884
|
+
markSetupComplete: () => Promise<{
|
|
1885
|
+
name: string | null;
|
|
2160
1886
|
id: string;
|
|
2161
1887
|
createdAt: Date;
|
|
2162
1888
|
updatedAt: Date;
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
columnId: string;
|
|
2166
|
-
datasetRecordId: string | null;
|
|
2167
|
-
inputVariables: Record<string, unknown>;
|
|
2168
|
-
outputContent: string | null;
|
|
2169
|
-
latencyMs: number | null;
|
|
2170
|
-
promptTokens: number | null;
|
|
2171
|
-
completionTokens: number | null;
|
|
2172
|
-
totalTokens: number | null;
|
|
2173
|
-
cost: number | null;
|
|
1889
|
+
setupComplete: boolean;
|
|
1890
|
+
superAdminId: string | null;
|
|
2174
1891
|
} | undefined>;
|
|
2175
|
-
listPlaygroundResults: (params: z$1.infer<typeof listPlaygroundResults>) => Promise<{
|
|
2176
|
-
error: string | null;
|
|
2177
|
-
id: string;
|
|
2178
|
-
createdAt: Date;
|
|
2179
|
-
updatedAt: Date;
|
|
2180
|
-
status: string;
|
|
2181
|
-
runId: string;
|
|
2182
|
-
columnId: string;
|
|
2183
|
-
datasetRecordId: string | null;
|
|
2184
|
-
inputVariables: Record<string, unknown>;
|
|
2185
|
-
outputContent: string | null;
|
|
2186
|
-
latencyMs: number | null;
|
|
2187
|
-
promptTokens: number | null;
|
|
2188
|
-
completionTokens: number | null;
|
|
2189
|
-
totalTokens: number | null;
|
|
2190
|
-
cost: number | null;
|
|
2191
|
-
}[]>;
|
|
2192
|
-
deletePlaygroundResultsByRunId: (params: z$1.infer<typeof deletePlaygroundResultsByRunId>) => Promise<{
|
|
2193
|
-
error: string | null;
|
|
2194
|
-
id: string;
|
|
2195
|
-
createdAt: Date;
|
|
2196
|
-
updatedAt: Date;
|
|
2197
|
-
status: string;
|
|
2198
|
-
runId: string;
|
|
2199
|
-
columnId: string;
|
|
2200
|
-
datasetRecordId: string | null;
|
|
2201
|
-
inputVariables: Record<string, unknown>;
|
|
2202
|
-
outputContent: string | null;
|
|
2203
|
-
latencyMs: number | null;
|
|
2204
|
-
promptTokens: number | null;
|
|
2205
|
-
completionTokens: number | null;
|
|
2206
|
-
totalTokens: number | null;
|
|
2207
|
-
cost: number | null;
|
|
2208
|
-
}[]>;
|
|
2209
|
-
countPlaygroundResults: (runId: string) => Promise<number>;
|
|
2210
|
-
countCompletedPlaygroundResults: (runId: string) => Promise<number>;
|
|
2211
1892
|
};
|
|
2212
1893
|
//#endregion
|
|
2213
|
-
//#region src/datalayer/
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
running: "running";
|
|
2221
|
-
completed: "completed";
|
|
2222
|
-
failed: "failed";
|
|
2223
|
-
cancelled: "cancelled";
|
|
2224
|
-
}>>;
|
|
2225
|
-
totalRecords: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2226
|
-
}, z$1.core.$strip>;
|
|
2227
|
-
declare const updatePlaygroundRun: z$1.ZodObject<{
|
|
2228
|
-
runId: z$1.ZodString;
|
|
2229
|
-
status: z$1.ZodOptional<z$1.ZodEnum<{
|
|
2230
|
-
pending: "pending";
|
|
2231
|
-
running: "running";
|
|
2232
|
-
completed: "completed";
|
|
2233
|
-
failed: "failed";
|
|
2234
|
-
cancelled: "cancelled";
|
|
2235
|
-
}>>;
|
|
2236
|
-
startedAt: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
2237
|
-
completedAt: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
2238
|
-
completedRecords: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2239
|
-
}, z$1.core.$strip>;
|
|
2240
|
-
declare const getPlaygroundRunById: z$1.ZodObject<{
|
|
2241
|
-
runId: z$1.ZodString;
|
|
2242
|
-
}, z$1.core.$strip>;
|
|
2243
|
-
declare const listPlaygroundRuns: z$1.ZodObject<{
|
|
2244
|
-
playgroundId: z$1.ZodString;
|
|
2245
|
-
limit: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2246
|
-
offset: z$1.ZodOptional<z$1.ZodNumber>;
|
|
2247
|
-
}, z$1.core.$strip>;
|
|
2248
|
-
declare const deletePlaygroundRun: z$1.ZodObject<{
|
|
2249
|
-
runId: z$1.ZodString;
|
|
2250
|
-
}, z$1.core.$strip>;
|
|
2251
|
-
declare const createPlaygroundRunsDataLayer: (db: Kysely<Database>) => {
|
|
2252
|
-
createPlaygroundRun: (params: z$1.infer<typeof createPlaygroundRun>) => Promise<{
|
|
2253
|
-
id: string;
|
|
2254
|
-
createdAt: Date;
|
|
2255
|
-
updatedAt: Date;
|
|
2256
|
-
datasetId: string | null;
|
|
2257
|
-
playgroundId: string;
|
|
2258
|
-
datasetVersionId: string | null;
|
|
2259
|
-
status: string;
|
|
2260
|
-
startedAt: Date | null;
|
|
2261
|
-
completedAt: Date | null;
|
|
2262
|
-
totalRecords: number;
|
|
2263
|
-
completedRecords: number;
|
|
2264
|
-
} | undefined>;
|
|
2265
|
-
updatePlaygroundRun: (params: z$1.infer<typeof updatePlaygroundRun>) => Promise<{
|
|
2266
|
-
id: string;
|
|
2267
|
-
createdAt: Date;
|
|
2268
|
-
updatedAt: Date;
|
|
2269
|
-
datasetId: string | null;
|
|
2270
|
-
playgroundId: string;
|
|
2271
|
-
datasetVersionId: string | null;
|
|
2272
|
-
status: string;
|
|
2273
|
-
startedAt: Date | null;
|
|
2274
|
-
completedAt: Date | null;
|
|
2275
|
-
totalRecords: number;
|
|
2276
|
-
completedRecords: number;
|
|
2277
|
-
} | undefined>;
|
|
2278
|
-
getPlaygroundRunById: (params: z$1.infer<typeof getPlaygroundRunById>) => Promise<{
|
|
2279
|
-
id: string;
|
|
2280
|
-
createdAt: Date;
|
|
2281
|
-
updatedAt: Date;
|
|
2282
|
-
datasetId: string | null;
|
|
2283
|
-
playgroundId: string;
|
|
2284
|
-
datasetVersionId: string | null;
|
|
2285
|
-
status: string;
|
|
2286
|
-
startedAt: Date | null;
|
|
2287
|
-
completedAt: Date | null;
|
|
2288
|
-
totalRecords: number;
|
|
2289
|
-
completedRecords: number;
|
|
2290
|
-
} | undefined>;
|
|
2291
|
-
listPlaygroundRuns: (params: z$1.infer<typeof listPlaygroundRuns>) => Promise<{
|
|
2292
|
-
id: string;
|
|
2293
|
-
createdAt: Date;
|
|
2294
|
-
updatedAt: Date;
|
|
2295
|
-
datasetId: string | null;
|
|
2296
|
-
playgroundId: string;
|
|
2297
|
-
datasetVersionId: string | null;
|
|
2298
|
-
status: string;
|
|
2299
|
-
startedAt: Date | null;
|
|
2300
|
-
completedAt: Date | null;
|
|
2301
|
-
totalRecords: number;
|
|
2302
|
-
completedRecords: number;
|
|
2303
|
-
}[]>;
|
|
2304
|
-
deletePlaygroundRun: (params: z$1.infer<typeof deletePlaygroundRun>) => Promise<{
|
|
2305
|
-
id: string;
|
|
2306
|
-
createdAt: Date;
|
|
2307
|
-
updatedAt: Date;
|
|
2308
|
-
datasetId: string | null;
|
|
2309
|
-
playgroundId: string;
|
|
2310
|
-
datasetVersionId: string | null;
|
|
2311
|
-
status: string;
|
|
2312
|
-
startedAt: Date | null;
|
|
2313
|
-
completedAt: Date | null;
|
|
2314
|
-
totalRecords: number;
|
|
2315
|
-
completedRecords: number;
|
|
2316
|
-
} | undefined>;
|
|
2317
|
-
countPlaygroundRuns: (playgroundId: string) => Promise<number>;
|
|
2318
|
-
};
|
|
1894
|
+
//#region src/datalayer/interface.d.ts
|
|
1895
|
+
type DatasetsDataLayer = ReturnType<typeof createDatasetsDataLayer>;
|
|
1896
|
+
type PlaygroundsDataLayer = ReturnType<typeof createPlaygroundDataLayer>;
|
|
1897
|
+
type PlaygroundResultsDataLayer = ReturnType<typeof createPlaygroundResultsDataLayer>;
|
|
1898
|
+
type PlaygroundRunsDataLayer = ReturnType<typeof createPlaygroundRunsDataLayer>;
|
|
1899
|
+
type WorkspaceSettingsDataLayer = ReturnType<typeof createWorkspaceSettingsDataLayer>;
|
|
1900
|
+
type DataLayer = DatasetsDataLayer & PlaygroundsDataLayer & PlaygroundResultsDataLayer & PlaygroundRunsDataLayer & WorkspaceSettingsDataLayer;
|
|
2319
1901
|
//#endregion
|
|
2320
|
-
//#region src/datalayer/
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
1902
|
+
//#region src/datalayer/create.d.ts
|
|
1903
|
+
/**
|
|
1904
|
+
* Create all datalayers from a Kysely database instance.
|
|
1905
|
+
* Returns a flat object with all datalayer methods spread together.
|
|
1906
|
+
*/
|
|
1907
|
+
declare function createDataLayer(db: Kysely<Database>): DataLayer;
|
|
1908
|
+
//#endregion
|
|
1909
|
+
//#region src/pricing/types.d.ts
|
|
1910
|
+
/**
|
|
1911
|
+
* Pricing types for cost tracking
|
|
1912
|
+
*/
|
|
1913
|
+
/**
|
|
1914
|
+
* Model pricing information
|
|
1915
|
+
* All costs are in dollars per 1 million tokens
|
|
1916
|
+
*/
|
|
1917
|
+
interface ModelPricing {
|
|
1918
|
+
/** Cost per 1M input/prompt tokens in dollars */
|
|
1919
|
+
inputCostPer1M: number;
|
|
1920
|
+
/** Cost per 1M output/completion tokens in dollars */
|
|
1921
|
+
outputCostPer1M: number;
|
|
1922
|
+
/** Cost per 1M cached read tokens in dollars (optional) */
|
|
1923
|
+
cacheReadCostPer1M?: number;
|
|
1924
|
+
/** Cost per 1M cached write tokens in dollars (optional) */
|
|
1925
|
+
cacheWriteCostPer1M?: number;
|
|
1926
|
+
/** Cost per 1M reasoning tokens in dollars (optional, for models like o1) */
|
|
1927
|
+
reasoningCostPer1M?: number;
|
|
1928
|
+
}
|
|
1929
|
+
/**
|
|
1930
|
+
* Token usage data from LLM response
|
|
1931
|
+
*/
|
|
1932
|
+
interface UsageData {
|
|
1933
|
+
/** Number of tokens in the prompt/input */
|
|
1934
|
+
promptTokens: number;
|
|
1935
|
+
/** Number of tokens in the completion/output */
|
|
1936
|
+
completionTokens: number;
|
|
1937
|
+
/** Total tokens (prompt + completion) */
|
|
1938
|
+
totalTokens?: number;
|
|
1939
|
+
/** Number of cache read tokens (OpenAI cached_tokens / Anthropic cache_read_input_tokens) */
|
|
1940
|
+
cachedTokens?: number;
|
|
1941
|
+
/** Number of cache creation tokens (Anthropic cache_creation_input_tokens) */
|
|
1942
|
+
cacheCreationTokens?: number;
|
|
1943
|
+
/** Number of reasoning tokens (optional, for models like o1) */
|
|
1944
|
+
reasoningTokens?: number;
|
|
1945
|
+
}
|
|
1946
|
+
/**
|
|
1947
|
+
* Cost calculation result
|
|
1948
|
+
* All costs are in micro-dollars (1 dollar = 1,000,000 micro-dollars)
|
|
1949
|
+
* This avoids floating-point precision issues
|
|
1950
|
+
*/
|
|
1951
|
+
interface CostResult {
|
|
1952
|
+
/** Total cost in micro-dollars */
|
|
1953
|
+
totalCost: number;
|
|
1954
|
+
/** Input/prompt cost in micro-dollars */
|
|
1955
|
+
inputCost: number;
|
|
1956
|
+
/** Output/completion cost in micro-dollars */
|
|
1957
|
+
outputCost: number;
|
|
1958
|
+
/** Cost saved by cache hits in micro-dollars (negative means cache write premium exceeded savings) */
|
|
1959
|
+
cacheSavings: number;
|
|
1960
|
+
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Provider for fetching model pricing data
|
|
1963
|
+
* Abstracted to allow swapping data sources (models.dev, local JSON, etc.)
|
|
1964
|
+
*/
|
|
1965
|
+
interface PricingProvider {
|
|
1966
|
+
/**
|
|
1967
|
+
* Get pricing for a specific model
|
|
1968
|
+
* @param provider - Provider name (e.g., "openai", "anthropic")
|
|
1969
|
+
* @param model - Model identifier (e.g., "gpt-4o", "claude-3-sonnet")
|
|
1970
|
+
* @returns Model pricing or null if not found
|
|
1971
|
+
*/
|
|
1972
|
+
getModelPricing(provider: string, model: string): Promise<ModelPricing | null>;
|
|
1973
|
+
/**
|
|
1974
|
+
* Force refresh the pricing cache
|
|
1975
|
+
*/
|
|
1976
|
+
refreshCache(): Promise<void>;
|
|
1977
|
+
/**
|
|
1978
|
+
* Check if the provider is ready (cache is populated)
|
|
1979
|
+
*/
|
|
1980
|
+
isReady(): boolean;
|
|
1981
|
+
}
|
|
1982
|
+
//#endregion
|
|
1983
|
+
//#region src/pricing/calculator.d.ts
|
|
1984
|
+
/**
|
|
1985
|
+
* Calculate the cost of an LLM request in micro-dollars
|
|
1986
|
+
*
|
|
1987
|
+
* Micro-dollars are used to avoid floating-point precision issues:
|
|
1988
|
+
* - 1 dollar = 1,000,000 micro-dollars
|
|
1989
|
+
* - $0.001 = 1,000 micro-dollars
|
|
1990
|
+
* - $0.000001 = 1 micro-dollar
|
|
1991
|
+
*
|
|
1992
|
+
* @param usage - Token usage data from the LLM response
|
|
1993
|
+
* @param pricing - Model pricing information
|
|
1994
|
+
* @returns Cost breakdown in micro-dollars
|
|
1995
|
+
*
|
|
1996
|
+
* @example
|
|
1997
|
+
* ```typescript
|
|
1998
|
+
* const usage = { promptTokens: 1000, completionTokens: 500 };
|
|
1999
|
+
* const pricing = { inputCostPer1M: 2.5, outputCostPer1M: 10.0 };
|
|
2000
|
+
* const cost = calculateCost(usage, pricing);
|
|
2001
|
+
* // cost = { inputCost: 2500, outputCost: 5000, totalCost: 7500 }
|
|
2002
|
+
* // In dollars: $0.0025 input + $0.005 output = $0.0075 total
|
|
2003
|
+
* ```
|
|
2004
|
+
*/
|
|
2005
|
+
declare function calculateCost(usage: UsageData, pricing: ModelPricing): CostResult;
|
|
2006
|
+
/**
|
|
2007
|
+
* Calculate cache-aware cost of an LLM request in micro-dollars.
|
|
2008
|
+
*
|
|
2009
|
+
* Splits input tokens into uncached, cache-read, and cache-creation buckets,
|
|
2010
|
+
* each priced at different rates. Falls back to provider-specific multipliers
|
|
2011
|
+
* when models.dev doesn't provide cache pricing.
|
|
2012
|
+
*
|
|
2013
|
+
* @param usage - Token usage data (with cachedTokens and cacheCreationTokens)
|
|
2014
|
+
* @param pricing - Model pricing (may include cacheReadCostPer1M / cacheWriteCostPer1M)
|
|
2015
|
+
* @param provider - Provider name for fallback rate selection
|
|
2016
|
+
* @returns Cost breakdown in micro-dollars
|
|
2017
|
+
*/
|
|
2018
|
+
declare function calculateCacheAwareCost(usage: UsageData, pricing: ModelPricing, provider?: string): CostResult;
|
|
2019
|
+
/**
|
|
2020
|
+
* Convert micro-dollars to dollars
|
|
2021
|
+
*
|
|
2022
|
+
* @param microDollars - Amount in micro-dollars
|
|
2023
|
+
* @returns Amount in dollars
|
|
2024
|
+
*
|
|
2025
|
+
* @example
|
|
2026
|
+
* ```typescript
|
|
2027
|
+
* microDollarsToDollars(7500); // 0.0075
|
|
2028
|
+
* microDollarsToDollars(1000000); // 1.0
|
|
2029
|
+
* ```
|
|
2030
|
+
*/
|
|
2031
|
+
declare function microDollarsToDollars(microDollars: number): number;
|
|
2032
|
+
/**
|
|
2033
|
+
* Convert dollars to micro-dollars
|
|
2034
|
+
*
|
|
2035
|
+
* @param dollars - Amount in dollars
|
|
2036
|
+
* @returns Amount in micro-dollars (rounded to nearest integer)
|
|
2037
|
+
*
|
|
2038
|
+
* @example
|
|
2039
|
+
* ```typescript
|
|
2040
|
+
* dollarsToMicroDollars(0.0075); // 7500
|
|
2041
|
+
* dollarsToMicroDollars(1.0); // 1000000
|
|
2042
|
+
* ```
|
|
2043
|
+
*/
|
|
2044
|
+
declare function dollarsToMicroDollars(dollars: number): number;
|
|
2045
|
+
/**
|
|
2046
|
+
* Format micro-dollars as a human-readable dollar string
|
|
2047
|
+
*
|
|
2048
|
+
* @param microDollars - Amount in micro-dollars
|
|
2049
|
+
* @param decimals - Number of decimal places (default: 6)
|
|
2050
|
+
* @returns Formatted dollar string
|
|
2051
|
+
*
|
|
2052
|
+
* @example
|
|
2053
|
+
* ```typescript
|
|
2054
|
+
* formatCost(7500); // "$0.007500"
|
|
2055
|
+
* formatCost(1234567, 2); // "$1.23"
|
|
2056
|
+
* ```
|
|
2057
|
+
*/
|
|
2058
|
+
declare function formatCost(microDollars: number, decimals?: number): string;
|
|
2059
|
+
//#endregion
|
|
2060
|
+
//#region src/pricing/provider.d.ts
|
|
2061
|
+
/**
|
|
2062
|
+
* Pricing provider that fetches per-model data from the LLMOps Models API.
|
|
2063
|
+
*
|
|
2064
|
+
* Features:
|
|
2065
|
+
* - Per-model in-memory cache with configurable TTL (default 5 minutes)
|
|
2066
|
+
* - Deduplicates concurrent fetches for the same model
|
|
2067
|
+
* - Caches null results (404s) to avoid repeated lookups
|
|
2068
|
+
* - Falls back to stale cache on fetch errors
|
|
2069
|
+
*/
|
|
2070
|
+
declare class LLMOpsPricingProvider implements PricingProvider {
|
|
2071
|
+
private cache;
|
|
2072
|
+
private pendingFetches;
|
|
2073
|
+
private cacheTTL;
|
|
2074
|
+
private baseUrl;
|
|
2075
|
+
constructor(options?: {
|
|
2076
|
+
cacheTTL?: number;
|
|
2077
|
+
baseUrl?: string;
|
|
2078
|
+
});
|
|
2079
|
+
private getCacheKey;
|
|
2080
|
+
/**
|
|
2081
|
+
* Fetch pricing for a single model from the API
|
|
2082
|
+
*/
|
|
2083
|
+
private fetchModelPricing;
|
|
2084
|
+
/**
|
|
2085
|
+
* Internal: fetch with cache and deduplication for a specific provider+model
|
|
2086
|
+
*/
|
|
2087
|
+
private getCachedPricing;
|
|
2088
|
+
/**
|
|
2089
|
+
* Get pricing for a specific model.
|
|
2090
|
+
*
|
|
2091
|
+
* When the model name contains a slash (e.g. "google/gemini-2.5-flash"),
|
|
2092
|
+
* it's likely an OpenRouter model ID. If the initial provider lookup fails,
|
|
2093
|
+
* we automatically retry with "openrouter" as the provider.
|
|
2094
|
+
*/
|
|
2095
|
+
getModelPricing(provider: string, model: string): Promise<ModelPricing | null>;
|
|
2096
|
+
/**
|
|
2097
|
+
* Force refresh the pricing cache (clears all cached entries)
|
|
2098
|
+
*/
|
|
2099
|
+
refreshCache(): Promise<void>;
|
|
2100
|
+
/**
|
|
2101
|
+
* Always ready — no bulk pre-fetch needed
|
|
2102
|
+
*/
|
|
2103
|
+
isReady(): boolean;
|
|
2104
|
+
/**
|
|
2105
|
+
* Get the number of cached models (for debugging)
|
|
2106
|
+
*/
|
|
2107
|
+
getCacheSize(): number;
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Get the default pricing provider instance
|
|
2111
|
+
*/
|
|
2112
|
+
declare function getDefaultPricingProvider(): LLMOpsPricingProvider;
|
|
2113
|
+
//#endregion
|
|
2114
|
+
//#region src/telemetry/postgres.d.ts
|
|
2115
|
+
declare const insertLLMRequestSchema: z$1.ZodObject<{
|
|
2116
|
+
requestId: z$1.ZodString;
|
|
2117
|
+
configId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2118
|
+
variantId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2119
|
+
environmentId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2120
|
+
providerConfigId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2121
|
+
provider: z$1.ZodString;
|
|
2122
|
+
model: z$1.ZodString;
|
|
2123
|
+
promptTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2124
|
+
completionTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2125
|
+
totalTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2126
|
+
cachedTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2127
|
+
cacheCreationTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2128
|
+
cost: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2129
|
+
cacheSavings: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2130
|
+
inputCost: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2131
|
+
outputCost: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2132
|
+
endpoint: z$1.ZodString;
|
|
2133
|
+
statusCode: z$1.ZodNumber;
|
|
2134
|
+
latencyMs: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2135
|
+
isStreaming: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
2136
|
+
userId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2137
|
+
tags: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
2138
|
+
guardrailResults: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodObject<{
|
|
2139
|
+
results: z$1.ZodArray<z$1.ZodObject<{
|
|
2140
|
+
checkId: z$1.ZodString;
|
|
2141
|
+
functionId: z$1.ZodString;
|
|
2142
|
+
hookType: z$1.ZodEnum<{
|
|
2143
|
+
beforeRequestHook: "beforeRequestHook";
|
|
2144
|
+
afterRequestHook: "afterRequestHook";
|
|
2145
|
+
}>;
|
|
2146
|
+
verdict: z$1.ZodBoolean;
|
|
2147
|
+
latencyMs: z$1.ZodNumber;
|
|
2148
|
+
}, z$1.core.$strip>>;
|
|
2149
|
+
action: z$1.ZodEnum<{
|
|
2150
|
+
allowed: "allowed";
|
|
2151
|
+
blocked: "blocked";
|
|
2152
|
+
logged: "logged";
|
|
2153
|
+
}>;
|
|
2154
|
+
totalLatencyMs: z$1.ZodNumber;
|
|
2155
|
+
}, z$1.core.$strip>>>;
|
|
2156
|
+
traceId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2157
|
+
spanId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2158
|
+
parentSpanId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2159
|
+
sessionId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2346
2160
|
}, z$1.core.$strip>;
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2161
|
+
type LLMRequestInsert = z$1.infer<typeof insertLLMRequestSchema>;
|
|
2162
|
+
declare const listRequestsSchema: z$1.ZodObject<{
|
|
2163
|
+
limit: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2164
|
+
offset: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2165
|
+
configId: z$1.ZodOptional<z$1.ZodString>;
|
|
2166
|
+
variantId: z$1.ZodOptional<z$1.ZodString>;
|
|
2167
|
+
environmentId: z$1.ZodOptional<z$1.ZodString>;
|
|
2168
|
+
providerConfigId: z$1.ZodOptional<z$1.ZodString>;
|
|
2169
|
+
provider: z$1.ZodOptional<z$1.ZodString>;
|
|
2170
|
+
model: z$1.ZodOptional<z$1.ZodString>;
|
|
2171
|
+
startDate: z$1.ZodOptional<z$1.ZodDate>;
|
|
2172
|
+
endDate: z$1.ZodOptional<z$1.ZodDate>;
|
|
2173
|
+
tags: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodArray<z$1.ZodString>>>;
|
|
2350
2174
|
}, z$1.core.$strip>;
|
|
2351
|
-
declare const
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
enabled: boolean;
|
|
2359
|
-
providerId: string;
|
|
2360
|
-
config: Record<string, unknown>;
|
|
2361
|
-
} | undefined>;
|
|
2362
|
-
updateProviderConfig: (params: z$1.infer<typeof updateProviderConfig>) => Promise<{
|
|
2363
|
-
slug: string | null;
|
|
2364
|
-
name: string | null;
|
|
2365
|
-
id: string;
|
|
2366
|
-
createdAt: Date;
|
|
2367
|
-
updatedAt: Date;
|
|
2368
|
-
enabled: boolean;
|
|
2369
|
-
providerId: string;
|
|
2370
|
-
config: Record<string, unknown>;
|
|
2371
|
-
} | undefined>;
|
|
2372
|
-
getProviderConfigById: (params: z$1.infer<typeof getProviderConfigById>) => Promise<{
|
|
2373
|
-
slug: string | null;
|
|
2374
|
-
name: string | null;
|
|
2375
|
-
id: string;
|
|
2376
|
-
createdAt: Date;
|
|
2377
|
-
updatedAt: Date;
|
|
2378
|
-
enabled: boolean;
|
|
2379
|
-
providerId: string;
|
|
2380
|
-
config: Record<string, unknown>;
|
|
2381
|
-
} | undefined>;
|
|
2382
|
-
getProviderConfigByProviderId: (params: z$1.infer<typeof getProviderConfigByProviderId>) => Promise<{
|
|
2383
|
-
slug: string | null;
|
|
2384
|
-
name: string | null;
|
|
2385
|
-
id: string;
|
|
2386
|
-
createdAt: Date;
|
|
2387
|
-
updatedAt: Date;
|
|
2388
|
-
enabled: boolean;
|
|
2389
|
-
providerId: string;
|
|
2390
|
-
config: Record<string, unknown>;
|
|
2391
|
-
} | undefined>;
|
|
2392
|
-
getProviderConfigBySlug: (params: z$1.infer<typeof getProviderConfigBySlug>) => Promise<{
|
|
2393
|
-
slug: string | null;
|
|
2394
|
-
name: string | null;
|
|
2395
|
-
id: string;
|
|
2396
|
-
createdAt: Date;
|
|
2397
|
-
updatedAt: Date;
|
|
2398
|
-
enabled: boolean;
|
|
2399
|
-
providerId: string;
|
|
2400
|
-
config: Record<string, unknown>;
|
|
2401
|
-
} | undefined>;
|
|
2402
|
-
deleteProviderConfig: (params: z$1.infer<typeof deleteProviderConfig>) => Promise<{
|
|
2403
|
-
slug: string | null;
|
|
2404
|
-
name: string | null;
|
|
2405
|
-
id: string;
|
|
2406
|
-
createdAt: Date;
|
|
2407
|
-
updatedAt: Date;
|
|
2408
|
-
enabled: boolean;
|
|
2409
|
-
providerId: string;
|
|
2410
|
-
config: Record<string, unknown>;
|
|
2411
|
-
} | undefined>;
|
|
2412
|
-
listProviderConfigs: (params?: z$1.infer<typeof listProviderConfigs>) => Promise<{
|
|
2413
|
-
slug: string | null;
|
|
2414
|
-
name: string | null;
|
|
2415
|
-
id: string;
|
|
2416
|
-
createdAt: Date;
|
|
2417
|
-
updatedAt: Date;
|
|
2418
|
-
enabled: boolean;
|
|
2419
|
-
providerId: string;
|
|
2420
|
-
config: Record<string, unknown>;
|
|
2421
|
-
}[]>;
|
|
2422
|
-
countProviderConfigs: () => Promise<number>;
|
|
2423
|
-
/**
|
|
2424
|
-
* Upsert provider config - creates if not exists, updates if exists
|
|
2425
|
-
* Useful for the dashboard UI where you want to set/update a provider config
|
|
2426
|
-
*/
|
|
2427
|
-
upsertProviderConfig: (params: z$1.infer<typeof createProviderConfig>) => Promise<{
|
|
2428
|
-
slug: string | null;
|
|
2429
|
-
name: string | null;
|
|
2430
|
-
id: string;
|
|
2431
|
-
createdAt: Date;
|
|
2432
|
-
updatedAt: Date;
|
|
2433
|
-
enabled: boolean;
|
|
2434
|
-
providerId: string;
|
|
2435
|
-
config: Record<string, unknown>;
|
|
2436
|
-
} | undefined>;
|
|
2437
|
-
};
|
|
2438
|
-
//#endregion
|
|
2439
|
-
//#region src/datalayer/providerGuardrailOverrides.d.ts
|
|
2440
|
-
declare const createProviderGuardrailOverride: z$1.ZodObject<{
|
|
2441
|
-
providerConfigId: z$1.ZodString;
|
|
2442
|
-
guardrailConfigId: z$1.ZodString;
|
|
2443
|
-
enabled: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodBoolean>>;
|
|
2444
|
-
parameters: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>>;
|
|
2175
|
+
declare const dateRangeSchema: z$1.ZodObject<{
|
|
2176
|
+
startDate: z$1.ZodDate;
|
|
2177
|
+
endDate: z$1.ZodDate;
|
|
2178
|
+
configId: z$1.ZodOptional<z$1.ZodString>;
|
|
2179
|
+
variantId: z$1.ZodOptional<z$1.ZodString>;
|
|
2180
|
+
environmentId: z$1.ZodOptional<z$1.ZodString>;
|
|
2181
|
+
tags: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodArray<z$1.ZodString>>>;
|
|
2445
2182
|
}, z$1.core.$strip>;
|
|
2446
|
-
declare const
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2183
|
+
declare const COST_SUMMARY_GROUP_BY: readonly ["day", "hour", "model", "provider", "endpoint", "tags"];
|
|
2184
|
+
type CostSummaryGroupBy = (typeof COST_SUMMARY_GROUP_BY)[number];
|
|
2185
|
+
declare const costSummarySchema: z$1.ZodObject<{
|
|
2186
|
+
startDate: z$1.ZodDate;
|
|
2187
|
+
endDate: z$1.ZodDate;
|
|
2188
|
+
configId: z$1.ZodOptional<z$1.ZodString>;
|
|
2189
|
+
variantId: z$1.ZodOptional<z$1.ZodString>;
|
|
2190
|
+
environmentId: z$1.ZodOptional<z$1.ZodString>;
|
|
2191
|
+
tags: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodArray<z$1.ZodString>>>;
|
|
2192
|
+
groupBy: z$1.ZodOptional<z$1.ZodEnum<{
|
|
2193
|
+
provider: "provider";
|
|
2194
|
+
model: "model";
|
|
2195
|
+
endpoint: "endpoint";
|
|
2196
|
+
tags: "tags";
|
|
2197
|
+
day: "day";
|
|
2198
|
+
hour: "hour";
|
|
2199
|
+
}>>;
|
|
2200
|
+
tagKeys: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
2450
2201
|
}, z$1.core.$strip>;
|
|
2451
|
-
declare const
|
|
2452
|
-
|
|
2202
|
+
declare const upsertTraceSchema: z$1.ZodObject<{
|
|
2203
|
+
traceId: z$1.ZodString;
|
|
2204
|
+
name: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2205
|
+
sessionId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2206
|
+
userId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2207
|
+
status: z$1.ZodDefault<z$1.ZodEnum<{
|
|
2208
|
+
error: "error";
|
|
2209
|
+
unset: "unset";
|
|
2210
|
+
ok: "ok";
|
|
2211
|
+
}>>;
|
|
2212
|
+
startTime: z$1.ZodDate;
|
|
2213
|
+
endTime: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
2214
|
+
durationMs: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
2215
|
+
spanCount: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2216
|
+
totalInputTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2217
|
+
totalOutputTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2218
|
+
totalTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2219
|
+
totalCost: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2220
|
+
tags: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
2221
|
+
metadata: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2453
2222
|
}, z$1.core.$strip>;
|
|
2454
|
-
|
|
2455
|
-
|
|
2223
|
+
type TraceUpsert = z$1.infer<typeof upsertTraceSchema>;
|
|
2224
|
+
declare const insertSpanSchema: z$1.ZodObject<{
|
|
2225
|
+
traceId: z$1.ZodString;
|
|
2226
|
+
spanId: z$1.ZodString;
|
|
2227
|
+
parentSpanId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2228
|
+
name: z$1.ZodString;
|
|
2229
|
+
kind: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2230
|
+
status: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2231
|
+
statusMessage: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2232
|
+
startTime: z$1.ZodDate;
|
|
2233
|
+
endTime: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
2234
|
+
durationMs: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
2235
|
+
provider: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2236
|
+
model: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2237
|
+
promptTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2238
|
+
completionTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2239
|
+
totalTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2240
|
+
cost: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2241
|
+
configId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2242
|
+
variantId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2243
|
+
environmentId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2244
|
+
providerConfigId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2245
|
+
requestId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2246
|
+
source: z$1.ZodDefault<z$1.ZodEnum<{
|
|
2247
|
+
gateway: "gateway";
|
|
2248
|
+
otlp: "otlp";
|
|
2249
|
+
langsmith: "langsmith";
|
|
2250
|
+
}>>;
|
|
2251
|
+
input: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUnknown>>;
|
|
2252
|
+
output: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUnknown>>;
|
|
2253
|
+
attributes: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2456
2254
|
}, z$1.core.$strip>;
|
|
2457
|
-
|
|
2458
|
-
|
|
2255
|
+
type SpanInsert = z$1.infer<typeof insertSpanSchema>;
|
|
2256
|
+
declare const insertSpanEventSchema: z$1.ZodObject<{
|
|
2257
|
+
traceId: z$1.ZodString;
|
|
2258
|
+
spanId: z$1.ZodString;
|
|
2259
|
+
name: z$1.ZodString;
|
|
2260
|
+
timestamp: z$1.ZodDate;
|
|
2261
|
+
attributes: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2459
2262
|
}, z$1.core.$strip>;
|
|
2460
|
-
|
|
2461
|
-
|
|
2263
|
+
type SpanEventInsert = z$1.infer<typeof insertSpanEventSchema>;
|
|
2264
|
+
declare const listTracesSchema: z$1.ZodObject<{
|
|
2265
|
+
limit: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2266
|
+
offset: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2267
|
+
sessionId: z$1.ZodOptional<z$1.ZodString>;
|
|
2268
|
+
userId: z$1.ZodOptional<z$1.ZodString>;
|
|
2269
|
+
status: z$1.ZodOptional<z$1.ZodEnum<{
|
|
2270
|
+
error: "error";
|
|
2271
|
+
unset: "unset";
|
|
2272
|
+
ok: "ok";
|
|
2273
|
+
}>>;
|
|
2274
|
+
name: z$1.ZodOptional<z$1.ZodString>;
|
|
2275
|
+
startDate: z$1.ZodOptional<z$1.ZodDate>;
|
|
2276
|
+
endDate: z$1.ZodOptional<z$1.ZodDate>;
|
|
2277
|
+
tags: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodArray<z$1.ZodString>>>;
|
|
2462
2278
|
}, z$1.core.$strip>;
|
|
2463
|
-
declare const
|
|
2464
|
-
|
|
2465
|
-
|
|
2279
|
+
declare const traceStatsSchema: z$1.ZodObject<{
|
|
2280
|
+
startDate: z$1.ZodDate;
|
|
2281
|
+
endDate: z$1.ZodDate;
|
|
2282
|
+
sessionId: z$1.ZodOptional<z$1.ZodString>;
|
|
2283
|
+
userId: z$1.ZodOptional<z$1.ZodString>;
|
|
2466
2284
|
}, z$1.core.$strip>;
|
|
2467
|
-
declare
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
enabled: boolean;
|
|
2473
|
-
providerConfigId: string;
|
|
2474
|
-
parameters: Record<string, unknown> | null;
|
|
2475
|
-
guardrailConfigId: string;
|
|
2476
|
-
} | undefined>;
|
|
2477
|
-
updateProviderGuardrailOverride: (params: z$1.infer<typeof updateProviderGuardrailOverride>) => Promise<{
|
|
2285
|
+
declare function createLLMRequestsStore(db: Kysely<Database>): {
|
|
2286
|
+
batchInsertRequests: (requests: LLMRequestInsert[]) => Promise<{
|
|
2287
|
+
count: number;
|
|
2288
|
+
}>;
|
|
2289
|
+
insertRequest: (request: LLMRequestInsert) => Promise<{
|
|
2478
2290
|
id: string;
|
|
2479
2291
|
createdAt: Date;
|
|
2480
2292
|
updatedAt: Date;
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2293
|
+
variantId: string | null;
|
|
2294
|
+
provider: string;
|
|
2295
|
+
environmentId: string | null;
|
|
2296
|
+
configId: string | null;
|
|
2297
|
+
providerConfigId: string | null;
|
|
2298
|
+
latencyMs: number;
|
|
2299
|
+
promptTokens: number;
|
|
2300
|
+
completionTokens: number;
|
|
2301
|
+
totalTokens: number;
|
|
2302
|
+
cost: number;
|
|
2303
|
+
requestId: string;
|
|
2304
|
+
model: string;
|
|
2305
|
+
cachedTokens: number;
|
|
2306
|
+
cacheCreationTokens: number;
|
|
2307
|
+
cacheSavings: number;
|
|
2308
|
+
inputCost: number;
|
|
2309
|
+
outputCost: number;
|
|
2310
|
+
endpoint: string;
|
|
2311
|
+
statusCode: number;
|
|
2312
|
+
isStreaming: boolean;
|
|
2313
|
+
userId: string | null;
|
|
2314
|
+
tags: Record<string, string>;
|
|
2315
|
+
guardrailResults: {
|
|
2316
|
+
results: {
|
|
2317
|
+
checkId: string;
|
|
2318
|
+
functionId: string;
|
|
2319
|
+
hookType: "beforeRequestHook" | "afterRequestHook";
|
|
2320
|
+
verdict: boolean;
|
|
2321
|
+
latencyMs: number;
|
|
2322
|
+
}[];
|
|
2323
|
+
action: "allowed" | "blocked" | "logged";
|
|
2324
|
+
totalLatencyMs: number;
|
|
2325
|
+
} | null;
|
|
2326
|
+
traceId: string | null;
|
|
2327
|
+
spanId: string | null;
|
|
2328
|
+
parentSpanId: string | null;
|
|
2329
|
+
sessionId: string | null;
|
|
2485
2330
|
} | undefined>;
|
|
2486
|
-
|
|
2331
|
+
listRequests: (params?: z$1.infer<typeof listRequestsSchema>) => Promise<{
|
|
2332
|
+
data: {
|
|
2333
|
+
id: string;
|
|
2334
|
+
createdAt: Date;
|
|
2335
|
+
updatedAt: Date;
|
|
2336
|
+
variantId: string | null;
|
|
2337
|
+
provider: string;
|
|
2338
|
+
environmentId: string | null;
|
|
2339
|
+
configId: string | null;
|
|
2340
|
+
providerConfigId: string | null;
|
|
2341
|
+
latencyMs: number;
|
|
2342
|
+
promptTokens: number;
|
|
2343
|
+
completionTokens: number;
|
|
2344
|
+
totalTokens: number;
|
|
2345
|
+
cost: number;
|
|
2346
|
+
requestId: string;
|
|
2347
|
+
model: string;
|
|
2348
|
+
cachedTokens: number;
|
|
2349
|
+
cacheCreationTokens: number;
|
|
2350
|
+
cacheSavings: number;
|
|
2351
|
+
inputCost: number;
|
|
2352
|
+
outputCost: number;
|
|
2353
|
+
endpoint: string;
|
|
2354
|
+
statusCode: number;
|
|
2355
|
+
isStreaming: boolean;
|
|
2356
|
+
userId: string | null;
|
|
2357
|
+
tags: Record<string, string>;
|
|
2358
|
+
guardrailResults: {
|
|
2359
|
+
results: {
|
|
2360
|
+
checkId: string;
|
|
2361
|
+
functionId: string;
|
|
2362
|
+
hookType: "beforeRequestHook" | "afterRequestHook";
|
|
2363
|
+
verdict: boolean;
|
|
2364
|
+
latencyMs: number;
|
|
2365
|
+
}[];
|
|
2366
|
+
action: "allowed" | "blocked" | "logged";
|
|
2367
|
+
totalLatencyMs: number;
|
|
2368
|
+
} | null;
|
|
2369
|
+
traceId: string | null;
|
|
2370
|
+
spanId: string | null;
|
|
2371
|
+
parentSpanId: string | null;
|
|
2372
|
+
sessionId: string | null;
|
|
2373
|
+
}[];
|
|
2374
|
+
total: number;
|
|
2375
|
+
limit: number;
|
|
2376
|
+
offset: number;
|
|
2377
|
+
}>;
|
|
2378
|
+
getRequestByRequestId: (requestId: string) => Promise<{
|
|
2487
2379
|
id: string;
|
|
2488
2380
|
createdAt: Date;
|
|
2489
2381
|
updatedAt: Date;
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2382
|
+
variantId: string | null;
|
|
2383
|
+
provider: string;
|
|
2384
|
+
environmentId: string | null;
|
|
2385
|
+
configId: string | null;
|
|
2386
|
+
providerConfigId: string | null;
|
|
2387
|
+
latencyMs: number;
|
|
2388
|
+
promptTokens: number;
|
|
2389
|
+
completionTokens: number;
|
|
2390
|
+
totalTokens: number;
|
|
2391
|
+
cost: number;
|
|
2392
|
+
requestId: string;
|
|
2393
|
+
model: string;
|
|
2394
|
+
cachedTokens: number;
|
|
2395
|
+
cacheCreationTokens: number;
|
|
2396
|
+
cacheSavings: number;
|
|
2397
|
+
inputCost: number;
|
|
2398
|
+
outputCost: number;
|
|
2399
|
+
endpoint: string;
|
|
2400
|
+
statusCode: number;
|
|
2401
|
+
isStreaming: boolean;
|
|
2402
|
+
userId: string | null;
|
|
2403
|
+
tags: Record<string, string>;
|
|
2404
|
+
guardrailResults: {
|
|
2405
|
+
results: {
|
|
2406
|
+
checkId: string;
|
|
2407
|
+
functionId: string;
|
|
2408
|
+
hookType: "beforeRequestHook" | "afterRequestHook";
|
|
2409
|
+
verdict: boolean;
|
|
2410
|
+
latencyMs: number;
|
|
2411
|
+
}[];
|
|
2412
|
+
action: "allowed" | "blocked" | "logged";
|
|
2413
|
+
totalLatencyMs: number;
|
|
2414
|
+
} | null;
|
|
2415
|
+
traceId: string | null;
|
|
2416
|
+
spanId: string | null;
|
|
2417
|
+
parentSpanId: string | null;
|
|
2418
|
+
sessionId: string | null;
|
|
2494
2419
|
} | undefined>;
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2420
|
+
getTotalCost: (params: z$1.infer<typeof dateRangeSchema>) => Promise<{
|
|
2421
|
+
totalCost: number;
|
|
2422
|
+
totalInputCost: number;
|
|
2423
|
+
totalOutputCost: number;
|
|
2424
|
+
totalPromptTokens: number;
|
|
2425
|
+
totalCompletionTokens: number;
|
|
2426
|
+
totalTokens: number;
|
|
2427
|
+
totalCachedTokens: number;
|
|
2428
|
+
totalCacheSavings: number;
|
|
2429
|
+
requestCount: number;
|
|
2503
2430
|
} | undefined>;
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2431
|
+
getCostByModel: (params: z$1.infer<typeof dateRangeSchema>) => Promise<{
|
|
2432
|
+
provider: string;
|
|
2433
|
+
model: string;
|
|
2434
|
+
totalCost: number;
|
|
2435
|
+
totalInputCost: number;
|
|
2436
|
+
totalOutputCost: number;
|
|
2437
|
+
totalTokens: number;
|
|
2438
|
+
requestCount: number;
|
|
2439
|
+
avgLatencyMs: number;
|
|
2512
2440
|
}[]>;
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2441
|
+
getCostByProvider: (params: z$1.infer<typeof dateRangeSchema>) => Promise<{
|
|
2442
|
+
provider: string;
|
|
2443
|
+
totalCost: number;
|
|
2444
|
+
totalInputCost: number;
|
|
2445
|
+
totalOutputCost: number;
|
|
2446
|
+
totalTokens: number;
|
|
2447
|
+
requestCount: number;
|
|
2448
|
+
avgLatencyMs: number;
|
|
2521
2449
|
}[]>;
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2450
|
+
getDailyCosts: (params: z$1.infer<typeof dateRangeSchema>) => Promise<{
|
|
2451
|
+
totalCost: number;
|
|
2452
|
+
totalInputCost: number;
|
|
2453
|
+
totalOutputCost: number;
|
|
2454
|
+
totalTokens: number;
|
|
2455
|
+
requestCount: number;
|
|
2456
|
+
date: string;
|
|
2457
|
+
}[]>;
|
|
2458
|
+
getCostSummary: (params: z$1.infer<typeof costSummarySchema>) => Promise<{
|
|
2459
|
+
totalCost: number;
|
|
2460
|
+
requestCount: number;
|
|
2461
|
+
groupKey: string;
|
|
2462
|
+
}[]>;
|
|
2463
|
+
getRequestStats: (params: z$1.infer<typeof dateRangeSchema>) => Promise<{
|
|
2464
|
+
avgLatencyMs: number;
|
|
2465
|
+
totalRequests: number;
|
|
2466
|
+
successfulRequests: number;
|
|
2467
|
+
failedRequests: number;
|
|
2468
|
+
streamingRequests: number;
|
|
2469
|
+
maxLatencyMs: number;
|
|
2470
|
+
minLatencyMs: number;
|
|
2542
2471
|
} | undefined>;
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
deleteOverridesByGuardrailConfigId: (params: z$1.infer<typeof getOverridesByGuardrailConfigId>) => Promise<kysely0.DeleteResult[]>;
|
|
2472
|
+
getDistinctTags: () => Promise<{
|
|
2473
|
+
key: string;
|
|
2474
|
+
value: string;
|
|
2475
|
+
}[]>;
|
|
2548
2476
|
};
|
|
2549
|
-
|
|
2550
|
-
//#region src/datalayer/traces.d.ts
|
|
2551
|
-
/**
|
|
2552
|
-
* Schema for upserting a trace
|
|
2553
|
-
*/
|
|
2554
|
-
declare const upsertTraceSchema: z$1.ZodObject<{
|
|
2555
|
-
traceId: z$1.ZodString;
|
|
2556
|
-
name: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2557
|
-
sessionId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2558
|
-
userId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2559
|
-
status: z$1.ZodDefault<z$1.ZodEnum<{
|
|
2560
|
-
error: "error";
|
|
2561
|
-
unset: "unset";
|
|
2562
|
-
ok: "ok";
|
|
2563
|
-
}>>;
|
|
2564
|
-
startTime: z$1.ZodDate;
|
|
2565
|
-
endTime: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
2566
|
-
durationMs: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
2567
|
-
spanCount: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2568
|
-
totalInputTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2569
|
-
totalOutputTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2570
|
-
totalTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2571
|
-
totalCost: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2572
|
-
tags: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
2573
|
-
metadata: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2574
|
-
}, z$1.core.$strip>;
|
|
2575
|
-
type TraceUpsert = z$1.infer<typeof upsertTraceSchema>;
|
|
2576
|
-
/**
|
|
2577
|
-
* Schema for inserting spans
|
|
2578
|
-
*/
|
|
2579
|
-
declare const insertSpanSchema: z$1.ZodObject<{
|
|
2580
|
-
traceId: z$1.ZodString;
|
|
2581
|
-
spanId: z$1.ZodString;
|
|
2582
|
-
parentSpanId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2583
|
-
name: z$1.ZodString;
|
|
2584
|
-
kind: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2585
|
-
status: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2586
|
-
statusMessage: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2587
|
-
startTime: z$1.ZodDate;
|
|
2588
|
-
endTime: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodDate>>;
|
|
2589
|
-
durationMs: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
2590
|
-
provider: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2591
|
-
model: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2592
|
-
promptTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2593
|
-
completionTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2594
|
-
totalTokens: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2595
|
-
cost: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2596
|
-
configId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2597
|
-
variantId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2598
|
-
environmentId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2599
|
-
providerConfigId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2600
|
-
requestId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2601
|
-
source: z$1.ZodDefault<z$1.ZodEnum<{
|
|
2602
|
-
gateway: "gateway";
|
|
2603
|
-
otlp: "otlp";
|
|
2604
|
-
langsmith: "langsmith";
|
|
2605
|
-
}>>;
|
|
2606
|
-
input: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUnknown>>;
|
|
2607
|
-
output: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUnknown>>;
|
|
2608
|
-
attributes: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2609
|
-
}, z$1.core.$strip>;
|
|
2610
|
-
type SpanInsert = z$1.infer<typeof insertSpanSchema>;
|
|
2611
|
-
/**
|
|
2612
|
-
* Schema for inserting span events
|
|
2613
|
-
*/
|
|
2614
|
-
declare const insertSpanEventSchema: z$1.ZodObject<{
|
|
2615
|
-
traceId: z$1.ZodString;
|
|
2616
|
-
spanId: z$1.ZodString;
|
|
2617
|
-
name: z$1.ZodString;
|
|
2618
|
-
timestamp: z$1.ZodDate;
|
|
2619
|
-
attributes: z$1.ZodDefault<z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
|
|
2620
|
-
}, z$1.core.$strip>;
|
|
2621
|
-
type SpanEventInsert = z$1.infer<typeof insertSpanEventSchema>;
|
|
2622
|
-
/**
|
|
2623
|
-
* Schema for listing traces
|
|
2624
|
-
*/
|
|
2625
|
-
declare const listTracesSchema: z$1.ZodObject<{
|
|
2626
|
-
limit: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2627
|
-
offset: z$1.ZodDefault<z$1.ZodNumber>;
|
|
2628
|
-
sessionId: z$1.ZodOptional<z$1.ZodString>;
|
|
2629
|
-
userId: z$1.ZodOptional<z$1.ZodString>;
|
|
2630
|
-
status: z$1.ZodOptional<z$1.ZodEnum<{
|
|
2631
|
-
error: "error";
|
|
2632
|
-
unset: "unset";
|
|
2633
|
-
ok: "ok";
|
|
2634
|
-
}>>;
|
|
2635
|
-
name: z$1.ZodOptional<z$1.ZodString>;
|
|
2636
|
-
startDate: z$1.ZodOptional<z$1.ZodDate>;
|
|
2637
|
-
endDate: z$1.ZodOptional<z$1.ZodDate>;
|
|
2638
|
-
tags: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodArray<z$1.ZodString>>>;
|
|
2639
|
-
}, z$1.core.$strip>;
|
|
2640
|
-
/**
|
|
2641
|
-
* Schema for trace stats query
|
|
2642
|
-
*/
|
|
2643
|
-
declare const traceStatsSchema: z$1.ZodObject<{
|
|
2644
|
-
startDate: z$1.ZodDate;
|
|
2645
|
-
endDate: z$1.ZodDate;
|
|
2646
|
-
sessionId: z$1.ZodOptional<z$1.ZodString>;
|
|
2647
|
-
userId: z$1.ZodOptional<z$1.ZodString>;
|
|
2648
|
-
}, z$1.core.$strip>;
|
|
2649
|
-
declare const createTracesDataLayer: (db: Kysely<Database>) => {
|
|
2650
|
-
/**
|
|
2651
|
-
* Upsert a trace — insert or update aggregates on conflict
|
|
2652
|
-
*/
|
|
2477
|
+
declare function createTracesStore(db: Kysely<Database>): {
|
|
2653
2478
|
upsertTrace: (data: TraceUpsert) => Promise<void>;
|
|
2654
|
-
/**
|
|
2655
|
-
* Batch insert spans
|
|
2656
|
-
*/
|
|
2657
2479
|
batchInsertSpans: (spans: SpanInsert[]) => Promise<{
|
|
2658
2480
|
count: number;
|
|
2659
2481
|
}>;
|
|
2660
|
-
/**
|
|
2661
|
-
* Batch insert span events
|
|
2662
|
-
*/
|
|
2663
2482
|
batchInsertSpanEvents: (events: SpanEventInsert[]) => Promise<{
|
|
2664
2483
|
count: number;
|
|
2665
2484
|
}>;
|
|
2666
|
-
/**
|
|
2667
|
-
* List traces with filtering and pagination
|
|
2668
|
-
*/
|
|
2669
2485
|
listTraces: (params?: z$1.infer<typeof listTracesSchema>) => Promise<{
|
|
2670
2486
|
data: {
|
|
2671
2487
|
name: string | null;
|
|
@@ -2691,9 +2507,6 @@ declare const createTracesDataLayer: (db: Kysely<Database>) => {
|
|
|
2691
2507
|
limit: number;
|
|
2692
2508
|
offset: number;
|
|
2693
2509
|
}>;
|
|
2694
|
-
/**
|
|
2695
|
-
* Get a single trace with all its spans and events
|
|
2696
|
-
*/
|
|
2697
2510
|
getTraceWithSpans: (traceId: string) => Promise<{
|
|
2698
2511
|
trace: {
|
|
2699
2512
|
name: string | null;
|
|
@@ -2755,9 +2568,6 @@ declare const createTracesDataLayer: (db: Kysely<Database>) => {
|
|
|
2755
2568
|
timestamp: Date;
|
|
2756
2569
|
}[];
|
|
2757
2570
|
} | undefined>;
|
|
2758
|
-
/**
|
|
2759
|
-
* Get aggregate trace statistics for a date range
|
|
2760
|
-
*/
|
|
2761
2571
|
getTraceStats: (params: z$1.infer<typeof traceStatsSchema>) => Promise<{
|
|
2762
2572
|
totalCost: number;
|
|
2763
2573
|
totalTokens: number;
|
|
@@ -2767,298 +2577,7 @@ declare const createTracesDataLayer: (db: Kysely<Database>) => {
|
|
|
2767
2577
|
totalSpans: number;
|
|
2768
2578
|
} | undefined>;
|
|
2769
2579
|
};
|
|
2770
|
-
|
|
2771
|
-
//#region src/datalayer/workspaceSettings.d.ts
|
|
2772
|
-
declare const updateWorkspaceSettings: z$1.ZodObject<{
|
|
2773
|
-
name: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2774
|
-
setupComplete: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
2775
|
-
superAdminId: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
2776
|
-
}, z$1.core.$strip>;
|
|
2777
|
-
declare const createWorkspaceSettingsDataLayer: (db: Kysely<Database>) => {
|
|
2778
|
-
/**
|
|
2779
|
-
* Get workspace settings (creates default if not exists)
|
|
2780
|
-
*/
|
|
2781
|
-
getWorkspaceSettings: () => Promise<{
|
|
2782
|
-
name: string | null;
|
|
2783
|
-
id: string;
|
|
2784
|
-
createdAt: Date;
|
|
2785
|
-
updatedAt: Date;
|
|
2786
|
-
setupComplete: boolean;
|
|
2787
|
-
superAdminId: string | null;
|
|
2788
|
-
} | undefined>;
|
|
2789
|
-
/**
|
|
2790
|
-
* Update workspace settings
|
|
2791
|
-
*/
|
|
2792
|
-
updateWorkspaceSettings: (params: z$1.infer<typeof updateWorkspaceSettings>) => Promise<{
|
|
2793
|
-
name: string | null;
|
|
2794
|
-
id: string;
|
|
2795
|
-
createdAt: Date;
|
|
2796
|
-
updatedAt: Date;
|
|
2797
|
-
setupComplete: boolean;
|
|
2798
|
-
superAdminId: string | null;
|
|
2799
|
-
} | undefined>;
|
|
2800
|
-
/**
|
|
2801
|
-
* Get the super admin user ID
|
|
2802
|
-
*/
|
|
2803
|
-
getSuperAdminId: () => Promise<string | null>;
|
|
2804
|
-
/**
|
|
2805
|
-
* Set the super admin user ID (only if not already set)
|
|
2806
|
-
*/
|
|
2807
|
-
setSuperAdminId: (userId: string) => Promise<boolean>;
|
|
2808
|
-
/**
|
|
2809
|
-
* Check if initial setup has been completed
|
|
2810
|
-
*/
|
|
2811
|
-
isSetupComplete: () => Promise<boolean>;
|
|
2812
|
-
/**
|
|
2813
|
-
* Mark initial setup as complete
|
|
2814
|
-
*/
|
|
2815
|
-
markSetupComplete: () => Promise<{
|
|
2816
|
-
name: string | null;
|
|
2817
|
-
id: string;
|
|
2818
|
-
createdAt: Date;
|
|
2819
|
-
updatedAt: Date;
|
|
2820
|
-
setupComplete: boolean;
|
|
2821
|
-
superAdminId: string | null;
|
|
2822
|
-
} | undefined>;
|
|
2823
|
-
};
|
|
2824
|
-
//#endregion
|
|
2825
|
-
//#region src/datalayer/interface.d.ts
|
|
2826
|
-
type DatasetsDataLayer = ReturnType<typeof createDatasetsDataLayer>;
|
|
2827
|
-
type GuardrailConfigsDataLayer = ReturnType<typeof createGuardrailConfigsDataLayer>;
|
|
2828
|
-
type LLMRequestsDataLayer = ReturnType<typeof createLLMRequestsDataLayer>;
|
|
2829
|
-
type PlaygroundsDataLayer = ReturnType<typeof createPlaygroundDataLayer>;
|
|
2830
|
-
type PlaygroundResultsDataLayer = ReturnType<typeof createPlaygroundResultsDataLayer>;
|
|
2831
|
-
type PlaygroundRunsDataLayer = ReturnType<typeof createPlaygroundRunsDataLayer>;
|
|
2832
|
-
type ProviderConfigsDataLayer = ReturnType<typeof createProviderConfigsDataLayer>;
|
|
2833
|
-
type ProviderGuardrailOverridesDataLayer = ReturnType<typeof createProviderGuardrailOverridesDataLayer>;
|
|
2834
|
-
type TracesDataLayer = ReturnType<typeof createTracesDataLayer>;
|
|
2835
|
-
type WorkspaceSettingsDataLayer = ReturnType<typeof createWorkspaceSettingsDataLayer>;
|
|
2836
|
-
type DataLayer = DatasetsDataLayer & GuardrailConfigsDataLayer & LLMRequestsDataLayer & PlaygroundsDataLayer & PlaygroundResultsDataLayer & PlaygroundRunsDataLayer & ProviderConfigsDataLayer & ProviderGuardrailOverridesDataLayer & TracesDataLayer & WorkspaceSettingsDataLayer;
|
|
2837
|
-
//#endregion
|
|
2838
|
-
//#region src/datalayer/create.d.ts
|
|
2839
|
-
/**
|
|
2840
|
-
* Create all datalayers from a Kysely database instance.
|
|
2841
|
-
* Returns a flat object with all datalayer methods spread together.
|
|
2842
|
-
*/
|
|
2843
|
-
declare function createDataLayer(db: Kysely<Database>): DataLayer;
|
|
2844
|
-
//#endregion
|
|
2845
|
-
//#region src/pricing/types.d.ts
|
|
2846
|
-
/**
|
|
2847
|
-
* Pricing types for cost tracking
|
|
2848
|
-
*/
|
|
2849
|
-
/**
|
|
2850
|
-
* Model pricing information
|
|
2851
|
-
* All costs are in dollars per 1 million tokens
|
|
2852
|
-
*/
|
|
2853
|
-
interface ModelPricing {
|
|
2854
|
-
/** Cost per 1M input/prompt tokens in dollars */
|
|
2855
|
-
inputCostPer1M: number;
|
|
2856
|
-
/** Cost per 1M output/completion tokens in dollars */
|
|
2857
|
-
outputCostPer1M: number;
|
|
2858
|
-
/** Cost per 1M cached read tokens in dollars (optional) */
|
|
2859
|
-
cacheReadCostPer1M?: number;
|
|
2860
|
-
/** Cost per 1M cached write tokens in dollars (optional) */
|
|
2861
|
-
cacheWriteCostPer1M?: number;
|
|
2862
|
-
/** Cost per 1M reasoning tokens in dollars (optional, for models like o1) */
|
|
2863
|
-
reasoningCostPer1M?: number;
|
|
2864
|
-
}
|
|
2865
|
-
/**
|
|
2866
|
-
* Token usage data from LLM response
|
|
2867
|
-
*/
|
|
2868
|
-
interface UsageData {
|
|
2869
|
-
/** Number of tokens in the prompt/input */
|
|
2870
|
-
promptTokens: number;
|
|
2871
|
-
/** Number of tokens in the completion/output */
|
|
2872
|
-
completionTokens: number;
|
|
2873
|
-
/** Total tokens (prompt + completion) */
|
|
2874
|
-
totalTokens?: number;
|
|
2875
|
-
/** Number of cache read tokens (OpenAI cached_tokens / Anthropic cache_read_input_tokens) */
|
|
2876
|
-
cachedTokens?: number;
|
|
2877
|
-
/** Number of cache creation tokens (Anthropic cache_creation_input_tokens) */
|
|
2878
|
-
cacheCreationTokens?: number;
|
|
2879
|
-
/** Number of reasoning tokens (optional, for models like o1) */
|
|
2880
|
-
reasoningTokens?: number;
|
|
2881
|
-
}
|
|
2882
|
-
/**
|
|
2883
|
-
* Cost calculation result
|
|
2884
|
-
* All costs are in micro-dollars (1 dollar = 1,000,000 micro-dollars)
|
|
2885
|
-
* This avoids floating-point precision issues
|
|
2886
|
-
*/
|
|
2887
|
-
interface CostResult {
|
|
2888
|
-
/** Total cost in micro-dollars */
|
|
2889
|
-
totalCost: number;
|
|
2890
|
-
/** Input/prompt cost in micro-dollars */
|
|
2891
|
-
inputCost: number;
|
|
2892
|
-
/** Output/completion cost in micro-dollars */
|
|
2893
|
-
outputCost: number;
|
|
2894
|
-
/** Cost saved by cache hits in micro-dollars (negative means cache write premium exceeded savings) */
|
|
2895
|
-
cacheSavings: number;
|
|
2896
|
-
}
|
|
2897
|
-
/**
|
|
2898
|
-
* Provider for fetching model pricing data
|
|
2899
|
-
* Abstracted to allow swapping data sources (models.dev, local JSON, etc.)
|
|
2900
|
-
*/
|
|
2901
|
-
interface PricingProvider {
|
|
2902
|
-
/**
|
|
2903
|
-
* Get pricing for a specific model
|
|
2904
|
-
* @param provider - Provider name (e.g., "openai", "anthropic")
|
|
2905
|
-
* @param model - Model identifier (e.g., "gpt-4o", "claude-3-sonnet")
|
|
2906
|
-
* @returns Model pricing or null if not found
|
|
2907
|
-
*/
|
|
2908
|
-
getModelPricing(provider: string, model: string): Promise<ModelPricing | null>;
|
|
2909
|
-
/**
|
|
2910
|
-
* Force refresh the pricing cache
|
|
2911
|
-
*/
|
|
2912
|
-
refreshCache(): Promise<void>;
|
|
2913
|
-
/**
|
|
2914
|
-
* Check if the provider is ready (cache is populated)
|
|
2915
|
-
*/
|
|
2916
|
-
isReady(): boolean;
|
|
2917
|
-
}
|
|
2918
|
-
//#endregion
|
|
2919
|
-
//#region src/pricing/calculator.d.ts
|
|
2920
|
-
/**
|
|
2921
|
-
* Calculate the cost of an LLM request in micro-dollars
|
|
2922
|
-
*
|
|
2923
|
-
* Micro-dollars are used to avoid floating-point precision issues:
|
|
2924
|
-
* - 1 dollar = 1,000,000 micro-dollars
|
|
2925
|
-
* - $0.001 = 1,000 micro-dollars
|
|
2926
|
-
* - $0.000001 = 1 micro-dollar
|
|
2927
|
-
*
|
|
2928
|
-
* @param usage - Token usage data from the LLM response
|
|
2929
|
-
* @param pricing - Model pricing information
|
|
2930
|
-
* @returns Cost breakdown in micro-dollars
|
|
2931
|
-
*
|
|
2932
|
-
* @example
|
|
2933
|
-
* ```typescript
|
|
2934
|
-
* const usage = { promptTokens: 1000, completionTokens: 500 };
|
|
2935
|
-
* const pricing = { inputCostPer1M: 2.5, outputCostPer1M: 10.0 };
|
|
2936
|
-
* const cost = calculateCost(usage, pricing);
|
|
2937
|
-
* // cost = { inputCost: 2500, outputCost: 5000, totalCost: 7500 }
|
|
2938
|
-
* // In dollars: $0.0025 input + $0.005 output = $0.0075 total
|
|
2939
|
-
* ```
|
|
2940
|
-
*/
|
|
2941
|
-
declare function calculateCost(usage: UsageData, pricing: ModelPricing): CostResult;
|
|
2942
|
-
/**
|
|
2943
|
-
* Calculate cache-aware cost of an LLM request in micro-dollars.
|
|
2944
|
-
*
|
|
2945
|
-
* Splits input tokens into uncached, cache-read, and cache-creation buckets,
|
|
2946
|
-
* each priced at different rates. Falls back to provider-specific multipliers
|
|
2947
|
-
* when models.dev doesn't provide cache pricing.
|
|
2948
|
-
*
|
|
2949
|
-
* @param usage - Token usage data (with cachedTokens and cacheCreationTokens)
|
|
2950
|
-
* @param pricing - Model pricing (may include cacheReadCostPer1M / cacheWriteCostPer1M)
|
|
2951
|
-
* @param provider - Provider name for fallback rate selection
|
|
2952
|
-
* @returns Cost breakdown in micro-dollars
|
|
2953
|
-
*/
|
|
2954
|
-
declare function calculateCacheAwareCost(usage: UsageData, pricing: ModelPricing, provider?: string): CostResult;
|
|
2955
|
-
/**
|
|
2956
|
-
* Convert micro-dollars to dollars
|
|
2957
|
-
*
|
|
2958
|
-
* @param microDollars - Amount in micro-dollars
|
|
2959
|
-
* @returns Amount in dollars
|
|
2960
|
-
*
|
|
2961
|
-
* @example
|
|
2962
|
-
* ```typescript
|
|
2963
|
-
* microDollarsToDollars(7500); // 0.0075
|
|
2964
|
-
* microDollarsToDollars(1000000); // 1.0
|
|
2965
|
-
* ```
|
|
2966
|
-
*/
|
|
2967
|
-
declare function microDollarsToDollars(microDollars: number): number;
|
|
2968
|
-
/**
|
|
2969
|
-
* Convert dollars to micro-dollars
|
|
2970
|
-
*
|
|
2971
|
-
* @param dollars - Amount in dollars
|
|
2972
|
-
* @returns Amount in micro-dollars (rounded to nearest integer)
|
|
2973
|
-
*
|
|
2974
|
-
* @example
|
|
2975
|
-
* ```typescript
|
|
2976
|
-
* dollarsToMicroDollars(0.0075); // 7500
|
|
2977
|
-
* dollarsToMicroDollars(1.0); // 1000000
|
|
2978
|
-
* ```
|
|
2979
|
-
*/
|
|
2980
|
-
declare function dollarsToMicroDollars(dollars: number): number;
|
|
2981
|
-
/**
|
|
2982
|
-
* Format micro-dollars as a human-readable dollar string
|
|
2983
|
-
*
|
|
2984
|
-
* @param microDollars - Amount in micro-dollars
|
|
2985
|
-
* @param decimals - Number of decimal places (default: 6)
|
|
2986
|
-
* @returns Formatted dollar string
|
|
2987
|
-
*
|
|
2988
|
-
* @example
|
|
2989
|
-
* ```typescript
|
|
2990
|
-
* formatCost(7500); // "$0.007500"
|
|
2991
|
-
* formatCost(1234567, 2); // "$1.23"
|
|
2992
|
-
* ```
|
|
2993
|
-
*/
|
|
2994
|
-
declare function formatCost(microDollars: number, decimals?: number): string;
|
|
2995
|
-
//#endregion
|
|
2996
|
-
//#region src/pricing/provider.d.ts
|
|
2997
|
-
/**
|
|
2998
|
-
* Pricing provider that fetches per-model data from the LLMOps Models API.
|
|
2999
|
-
*
|
|
3000
|
-
* Features:
|
|
3001
|
-
* - Per-model in-memory cache with configurable TTL (default 5 minutes)
|
|
3002
|
-
* - Deduplicates concurrent fetches for the same model
|
|
3003
|
-
* - Caches null results (404s) to avoid repeated lookups
|
|
3004
|
-
* - Falls back to stale cache on fetch errors
|
|
3005
|
-
*/
|
|
3006
|
-
declare class LLMOpsPricingProvider implements PricingProvider {
|
|
3007
|
-
private cache;
|
|
3008
|
-
private pendingFetches;
|
|
3009
|
-
private cacheTTL;
|
|
3010
|
-
private baseUrl;
|
|
3011
|
-
constructor(options?: {
|
|
3012
|
-
cacheTTL?: number;
|
|
3013
|
-
baseUrl?: string;
|
|
3014
|
-
});
|
|
3015
|
-
private getCacheKey;
|
|
3016
|
-
/**
|
|
3017
|
-
* Fetch pricing for a single model from the API
|
|
3018
|
-
*/
|
|
3019
|
-
private fetchModelPricing;
|
|
3020
|
-
/**
|
|
3021
|
-
* Internal: fetch with cache and deduplication for a specific provider+model
|
|
3022
|
-
*/
|
|
3023
|
-
private getCachedPricing;
|
|
3024
|
-
/**
|
|
3025
|
-
* Get pricing for a specific model.
|
|
3026
|
-
*
|
|
3027
|
-
* When the model name contains a slash (e.g. "google/gemini-2.5-flash"),
|
|
3028
|
-
* it's likely an OpenRouter model ID. If the initial provider lookup fails,
|
|
3029
|
-
* we automatically retry with "openrouter" as the provider.
|
|
3030
|
-
*/
|
|
3031
|
-
getModelPricing(provider: string, model: string): Promise<ModelPricing | null>;
|
|
3032
|
-
/**
|
|
3033
|
-
* Force refresh the pricing cache (clears all cached entries)
|
|
3034
|
-
*/
|
|
3035
|
-
refreshCache(): Promise<void>;
|
|
3036
|
-
/**
|
|
3037
|
-
* Always ready — no bulk pre-fetch needed
|
|
3038
|
-
*/
|
|
3039
|
-
isReady(): boolean;
|
|
3040
|
-
/**
|
|
3041
|
-
* Get the number of cached models (for debugging)
|
|
3042
|
-
*/
|
|
3043
|
-
getCacheSize(): number;
|
|
3044
|
-
}
|
|
3045
|
-
/**
|
|
3046
|
-
* Get the default pricing provider instance
|
|
3047
|
-
*/
|
|
3048
|
-
declare function getDefaultPricingProvider(): LLMOpsPricingProvider;
|
|
3049
|
-
//#endregion
|
|
3050
|
-
//#region src/telemetry/interface.d.ts
|
|
3051
|
-
type LLMRequestsStore = ReturnType<typeof createLLMRequestsDataLayer>;
|
|
3052
|
-
type TracesStore = ReturnType<typeof createTracesDataLayer>;
|
|
3053
|
-
/**
|
|
3054
|
-
* TelemetryStore provides read + write access to telemetry data.
|
|
3055
|
-
* Implemented by pgStore (and future sqliteStore, etc.)
|
|
3056
|
-
*/
|
|
3057
|
-
type TelemetryStore = LLMRequestsStore & TracesStore;
|
|
3058
|
-
//#endregion
|
|
3059
|
-
//#region src/telemetry/postgres.d.ts
|
|
3060
|
-
type PgStore = TelemetryStore & {
|
|
3061
|
-
/** Internal Kysely instance — used by the app to power remaining datalayer queries */
|
|
2580
|
+
type PgStore = ReturnType<typeof createLLMRequestsStore> & ReturnType<typeof createTracesStore> & {
|
|
3062
2581
|
_db: Kysely<Database>;
|
|
3063
2582
|
};
|
|
3064
2583
|
/**
|
|
@@ -3066,7 +2585,8 @@ type PgStore = TelemetryStore & {
|
|
|
3066
2585
|
*
|
|
3067
2586
|
* Usage:
|
|
3068
2587
|
* ```ts
|
|
3069
|
-
* import { llmops
|
|
2588
|
+
* import { llmops } from '@llmops/sdk'
|
|
2589
|
+
* import { pgStore } from '@llmops/sdk/store/pg'
|
|
3070
2590
|
*
|
|
3071
2591
|
* const ops = llmops({
|
|
3072
2592
|
* telemetry: pgStore(process.env.DATABASE_URL),
|
|
@@ -3077,85 +2597,11 @@ declare function createPgStore(connectionString: string, options?: {
|
|
|
3077
2597
|
schema?: string;
|
|
3078
2598
|
}): PgStore;
|
|
3079
2599
|
//#endregion
|
|
3080
|
-
//#region src/
|
|
3081
|
-
/**
|
|
3082
|
-
* Guardrail configuration in the manifest
|
|
3083
|
-
* Pre-loaded for gateway use without additional DB queries
|
|
3084
|
-
*/
|
|
3085
|
-
interface ManifestGuardrail {
|
|
3086
|
-
id: string;
|
|
3087
|
-
name: string;
|
|
3088
|
-
pluginId: string;
|
|
3089
|
-
functionId: string;
|
|
3090
|
-
hookType: 'beforeRequestHook' | 'afterRequestHook';
|
|
3091
|
-
parameters: Record<string, unknown>;
|
|
3092
|
-
priority: number;
|
|
3093
|
-
onFail: 'block' | 'log';
|
|
3094
|
-
}
|
|
3095
|
-
/**
|
|
3096
|
-
* Provider-specific guardrail override in the manifest
|
|
3097
|
-
*/
|
|
3098
|
-
interface ManifestProviderGuardrailOverride {
|
|
3099
|
-
id: string;
|
|
3100
|
-
providerConfigId: string;
|
|
3101
|
-
guardrailConfigId: string;
|
|
3102
|
-
enabled: boolean;
|
|
3103
|
-
parameters: Record<string, unknown> | null;
|
|
3104
|
-
}
|
|
3105
|
-
/**
|
|
3106
|
-
* The gateway manifest
|
|
3107
|
-
* Stored in cache under key: "gateway:manifest"
|
|
3108
|
-
*/
|
|
3109
|
-
interface GatewayManifest {
|
|
3110
|
-
version: number;
|
|
3111
|
-
builtAt: string;
|
|
3112
|
-
guardrails: {
|
|
3113
|
-
beforeRequestHook: ManifestGuardrail[];
|
|
3114
|
-
afterRequestHook: ManifestGuardrail[];
|
|
3115
|
-
};
|
|
3116
|
-
providerGuardrailOverrides: Record<string, ManifestProviderGuardrailOverride[]>;
|
|
3117
|
-
}
|
|
3118
|
-
//#endregion
|
|
3119
|
-
//#region src/manifest/builder.d.ts
|
|
2600
|
+
//#region src/telemetry/interface.d.ts
|
|
3120
2601
|
/**
|
|
3121
|
-
*
|
|
2602
|
+
* TelemetryStore provides read + write access to telemetry data.
|
|
2603
|
+
* Implemented by pgStore (and future sqliteStore, etc.)
|
|
3122
2604
|
*/
|
|
3123
|
-
|
|
3124
|
-
private db;
|
|
3125
|
-
constructor(db: Kysely<Database>);
|
|
3126
|
-
/**
|
|
3127
|
-
* Build the manifest from database
|
|
3128
|
-
*/
|
|
3129
|
-
build(): Promise<GatewayManifest>;
|
|
3130
|
-
}
|
|
3131
|
-
//#endregion
|
|
3132
|
-
//#region src/manifest/service.d.ts
|
|
3133
|
-
declare class ManifestService {
|
|
3134
|
-
private cache;
|
|
3135
|
-
private ttlMs;
|
|
3136
|
-
private builder;
|
|
3137
|
-
constructor(cache: CacheService, db: Kysely<Database>, ttlMs?: number);
|
|
3138
|
-
/**
|
|
3139
|
-
* Get the current manifest, building if necessary
|
|
3140
|
-
*/
|
|
3141
|
-
getManifest(): Promise<GatewayManifest>;
|
|
3142
|
-
/**
|
|
3143
|
-
* Force invalidate the manifest (called on mutations)
|
|
3144
|
-
*/
|
|
3145
|
-
invalidate(): Promise<void>;
|
|
3146
|
-
/**
|
|
3147
|
-
* Invalidate and immediately rebuild (atomic refresh)
|
|
3148
|
-
*/
|
|
3149
|
-
refresh(): Promise<GatewayManifest>;
|
|
3150
|
-
/**
|
|
3151
|
-
* Get manifest version without fetching full manifest
|
|
3152
|
-
* Useful for checking if manifest is stale
|
|
3153
|
-
*/
|
|
3154
|
-
getVersion(): Promise<number | null>;
|
|
3155
|
-
/**
|
|
3156
|
-
* Check if manifest exists in cache
|
|
3157
|
-
*/
|
|
3158
|
-
hasManifest(): Promise<boolean>;
|
|
3159
|
-
}
|
|
2605
|
+
type TelemetryStore = Omit<PgStore, '_db'>;
|
|
3160
2606
|
//#endregion
|
|
3161
|
-
export { type AnthropicProviderConfig, type AnyProviderConfig, type AzureAIProviderConfig, type AzureOpenAIProviderConfig, BaseCacheConfig, type BaseProviderConfig, type BedrockProviderConfig, COST_SUMMARY_GROUP_BY, CacheBackend, CacheBackendType, CacheConfig, CacheEntry, CacheOptions, CacheService, CacheStats, ChatCompletionCreateParamsBase, type Config, type ConfigVariant, type ConfigVariantsTable, type ConfigsTable, type CortexProviderConfig, CostResult, type CostSummaryGroupBy, DEFAULT_PROVIDER_ENV_VARS, type DataLayer, type Database, DatabaseConnection, DatabaseOptions, DatabaseType, type Dataset, type DatasetRecord, DatasetRecordsTable, type DatasetVersion, type DatasetVersionRecord, DatasetVersionRecordsTable, DatasetVersionsTable, type DatasetsDataLayer, DatasetsTable, type Environment, type EnvironmentSecret, type EnvironmentSecretsTable, type EnvironmentsTable, FileCacheBackend, FileCacheConfig, type FireworksAIProviderConfig, type
|
|
2607
|
+
export { type AnthropicProviderConfig, type AnyProviderConfig, type AzureAIProviderConfig, type AzureOpenAIProviderConfig, BaseCacheConfig, type BaseProviderConfig, type BedrockProviderConfig, COST_SUMMARY_GROUP_BY, CacheBackend, CacheBackendType, CacheConfig, CacheEntry, CacheOptions, CacheService, CacheStats, ChatCompletionCreateParamsBase, type Config, type ConfigVariant, type ConfigVariantsTable, type ConfigsTable, type CortexProviderConfig, CostResult, type CostSummaryGroupBy, DEFAULT_PROVIDER_ENV_VARS, type DataLayer, type Database, DatabaseConnection, DatabaseOptions, DatabaseType, type Dataset, type DatasetRecord, DatasetRecordsTable, type DatasetVersion, type DatasetVersionRecord, DatasetVersionRecordsTable, DatasetVersionsTable, type DatasetsDataLayer, DatasetsTable, type Environment, type EnvironmentSecret, type EnvironmentSecretsTable, type EnvironmentsTable, FileCacheBackend, FileCacheConfig, type FireworksAIProviderConfig, type GoogleProviderConfig, type GuardrailConfig, GuardrailConfigsTable, type GuardrailResult, type GuardrailResults, type HuggingFaceProviderConfig, type InlineProviderConfig, type InlineProvidersConfig, Insertable, LLMOPS_INTERNAL_HEADER, LLMOPS_REQUEST_ID_HEADER, LLMOPS_SESSION_ID_HEADER, LLMOPS_SPAN_ID_HEADER, LLMOPS_SPAN_NAME_HEADER, LLMOPS_TRACE_ID_HEADER, LLMOPS_TRACE_NAME_HEADER, LLMOPS_USER_ID_HEADER, LLMOpsClient, LLMOpsConfig, type LLMOpsConfigInput, LLMOpsPricingProvider, type LLMRequest, type LLMRequestInsert, LLMRequestsTable, MS, MemoryCacheBackend, MemoryCacheConfig, MigrationOptions, MigrationResult, type MistralAIProviderConfig, ModelPricing, type OpenAIProviderConfig, type OracleProviderConfig, type PgStore, type Playground, type PlaygroundColumn, type PlaygroundResult, type PlaygroundResultsDataLayer, PlaygroundResultsTable, type PlaygroundRun, type PlaygroundRunsDataLayer, PlaygroundRunsTable, type PlaygroundsDataLayer, PlaygroundsTable, Prettify, PricingProvider, type ProviderConfig, type ProviderConfigMap, ProviderConfigsTable, type ProviderGuardrailOverride, ProviderGuardrailOverridesTable, type ProvidersConfig, SCHEMA_METADATA, type SagemakerProviderConfig, Selectable, Span, SpanEvent, type SpanEventInsert, SpanEventsTable, type SpanInsert, SpansTable, type StabilityAIProviderConfig, SupportedProviders, type TableName, type TargetingRule, type TargetingRulesTable, type TelemetryStore, Trace, type TraceUpsert, TracesTable, Updateable, UsageData, type ValidatedLLMOpsConfig, type Variant, VariantJsonData, type VariantVersion, VariantVersionsTable, type VariantsTable, type VertexAIProviderConfig, type WorkersAIProviderConfig, type WorkspaceSettings, type WorkspaceSettingsDataLayer, WorkspaceSettingsTable, calculateCacheAwareCost, calculateCost, chatCompletionCreateParamsBaseSchema, configVariantsSchema, configsSchema, createDataLayer, createDatabase, createDatabaseFromConnection, createDatasetsDataLayer, createNeonDialect, createPgStore, createPlaygroundDataLayer, createPlaygroundResultsDataLayer, createPlaygroundRunsDataLayer, createWorkspaceSettingsDataLayer, datasetRecordsSchema, datasetVersionRecordsSchema, datasetVersionsSchema, datasetsSchema, detectDatabaseType, dollarsToMicroDollars, environmentSecretsSchema, environmentsSchema, executeWithSchema, formatCost, gateway, generateId, getDefaultPricingProvider, getDefaultProviders, getMigrations, guardrailConfigsSchema, llmRequestsSchema, llmopsConfigSchema, logger, matchType, mergeWithDefaultProviders, microDollarsToDollars, parsePartialTableData, parseTableData, playgroundColumnSchema, playgroundResultsSchema, playgroundRunsSchema, playgroundsSchema, providerConfigsSchema, providerGuardrailOverridesSchema, runAutoMigrations, schemas, spanEventsSchema, spansSchema, targetingRulesSchema, tracesSchema, validateLLMOpsConfig, validatePartialTableData, validateTableData, variantJsonDataSchema, variantVersionsSchema, variantsSchema, workspaceSettingsSchema };
|