@llmops/core 0.6.7-beta.1 → 0.6.7-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +24 -21
- package/dist/index.d.cts +2 -30
- package/dist/index.d.mts +2 -30
- package/dist/index.mjs +24 -21
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -632,24 +632,13 @@ const inlineProviderConfigSchema = require_db.object({
|
|
|
632
632
|
*/
|
|
633
633
|
const providersConfigSchema = require_db.array(inlineProviderConfigSchema).optional();
|
|
634
634
|
/**
|
|
635
|
-
* Schema for OTLP endpoint configuration.
|
|
636
|
-
* When configured, trace/span data is forwarded to this endpoint
|
|
637
|
-
* instead of being stored in PostgreSQL.
|
|
638
|
-
*/
|
|
639
|
-
const otlpConfigSchema = require_db.object({
|
|
640
|
-
endpoint: require_db.string().url("OTLP endpoint must be a valid URL").refine((url) => url.startsWith("http://") || url.startsWith("https://"), "OTLP endpoint must use http:// or https://"),
|
|
641
|
-
headers: require_db.record(require_db.string(), require_db.string()).optional(),
|
|
642
|
-
protocol: require_db._enum(["http/protobuf", "http/json"]).optional().default("http/protobuf")
|
|
643
|
-
}).optional();
|
|
644
|
-
/**
|
|
645
635
|
* Base schema without refinements (used for transform)
|
|
646
636
|
*/
|
|
647
637
|
const llmopsConfigBaseSchema = require_db.object({
|
|
648
638
|
database: require_db.any().optional(),
|
|
649
639
|
basePath: require_db.string().min(1, "Base path cannot be empty").refine((path) => path.startsWith("/"), "Base path must start with a forward slash").default("/llmops"),
|
|
650
640
|
schema: require_db.string().optional().default("llmops"),
|
|
651
|
-
providers: providersConfigSchema
|
|
652
|
-
otlp: otlpConfigSchema
|
|
641
|
+
providers: providersConfigSchema
|
|
653
642
|
});
|
|
654
643
|
const llmopsConfigSchema = llmopsConfigBaseSchema.transform((config) => ({
|
|
655
644
|
...config,
|
|
@@ -3189,7 +3178,11 @@ const insertSpanSchema = require_db.zod_default.object({
|
|
|
3189
3178
|
environmentId: require_db.zod_default.string().uuid().nullable().optional(),
|
|
3190
3179
|
providerConfigId: require_db.zod_default.string().uuid().nullable().optional(),
|
|
3191
3180
|
requestId: require_db.zod_default.string().uuid().nullable().optional(),
|
|
3192
|
-
source: require_db.zod_default.enum([
|
|
3181
|
+
source: require_db.zod_default.enum([
|
|
3182
|
+
"gateway",
|
|
3183
|
+
"otlp",
|
|
3184
|
+
"langsmith"
|
|
3185
|
+
]).default("gateway"),
|
|
3193
3186
|
input: require_db.zod_default.unknown().nullable().optional(),
|
|
3194
3187
|
output: require_db.zod_default.unknown().nullable().optional(),
|
|
3195
3188
|
attributes: require_db.zod_default.record(require_db.zod_default.string(), require_db.zod_default.unknown()).default({})
|
|
@@ -3287,11 +3280,16 @@ const createTracesDataLayer = (db) => {
|
|
|
3287
3280
|
},
|
|
3288
3281
|
batchInsertSpans: async (spans) => {
|
|
3289
3282
|
if (spans.length === 0) return { count: 0 };
|
|
3290
|
-
const validatedSpans =
|
|
3283
|
+
const validatedSpans = [];
|
|
3284
|
+
for (const span of spans) {
|
|
3291
3285
|
const result = await insertSpanSchema.safeParseAsync(span);
|
|
3292
|
-
if (!result.success)
|
|
3293
|
-
|
|
3294
|
-
|
|
3286
|
+
if (!result.success) {
|
|
3287
|
+
require_db.logger.warn(`[batchInsertSpans] Skipping invalid span ${span.spanId}: ${result.error.message}`);
|
|
3288
|
+
continue;
|
|
3289
|
+
}
|
|
3290
|
+
validatedSpans.push(result.data);
|
|
3291
|
+
}
|
|
3292
|
+
if (validatedSpans.length === 0) return { count: 0 };
|
|
3295
3293
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3296
3294
|
const values = validatedSpans.map((span) => ({
|
|
3297
3295
|
id: (0, node_crypto.randomUUID)(),
|
|
@@ -3328,11 +3326,16 @@ const createTracesDataLayer = (db) => {
|
|
|
3328
3326
|
},
|
|
3329
3327
|
batchInsertSpanEvents: async (events) => {
|
|
3330
3328
|
if (events.length === 0) return { count: 0 };
|
|
3331
|
-
const validatedEvents =
|
|
3329
|
+
const validatedEvents = [];
|
|
3330
|
+
for (const event of events) {
|
|
3332
3331
|
const result = await insertSpanEventSchema.safeParseAsync(event);
|
|
3333
|
-
if (!result.success)
|
|
3334
|
-
|
|
3335
|
-
|
|
3332
|
+
if (!result.success) {
|
|
3333
|
+
require_db.logger.warn(`[batchInsertSpanEvents] Skipping invalid event: ${result.error.message}`);
|
|
3334
|
+
continue;
|
|
3335
|
+
}
|
|
3336
|
+
validatedEvents.push(result.data);
|
|
3337
|
+
}
|
|
3338
|
+
if (validatedEvents.length === 0) return { count: 0 };
|
|
3336
3339
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3337
3340
|
const values = validatedEvents.map((event) => ({
|
|
3338
3341
|
id: (0, node_crypto.randomUUID)(),
|
package/dist/index.d.cts
CHANGED
|
@@ -495,24 +495,11 @@ declare const llmopsConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
495
495
|
requestTimeout: z.ZodOptional<z.ZodNumber>;
|
|
496
496
|
forwardHeaders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
497
497
|
}, z.core.$loose>>>;
|
|
498
|
-
otlp: z.ZodOptional<z.ZodObject<{
|
|
499
|
-
endpoint: z.ZodString;
|
|
500
|
-
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
501
|
-
protocol: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
502
|
-
"http/protobuf": "http/protobuf";
|
|
503
|
-
"http/json": "http/json";
|
|
504
|
-
}>>>;
|
|
505
|
-
}, z.core.$strip>>;
|
|
506
498
|
}, z.core.$strip>, z.ZodTransform<{
|
|
507
499
|
providers: InlineProviderConfig[];
|
|
508
500
|
basePath: string;
|
|
509
501
|
schema: string;
|
|
510
502
|
database?: any;
|
|
511
|
-
otlp?: {
|
|
512
|
-
endpoint: string;
|
|
513
|
-
protocol: "http/protobuf" | "http/json";
|
|
514
|
-
headers?: Record<string, string> | undefined;
|
|
515
|
-
} | undefined;
|
|
516
503
|
}, {
|
|
517
504
|
basePath: string;
|
|
518
505
|
schema: string;
|
|
@@ -526,11 +513,6 @@ declare const llmopsConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
526
513
|
requestTimeout?: number | undefined;
|
|
527
514
|
forwardHeaders?: string[] | undefined;
|
|
528
515
|
}[] | undefined;
|
|
529
|
-
otlp?: {
|
|
530
|
-
endpoint: string;
|
|
531
|
-
protocol: "http/protobuf" | "http/json";
|
|
532
|
-
headers?: Record<string, string> | undefined;
|
|
533
|
-
} | undefined;
|
|
534
516
|
}>>;
|
|
535
517
|
/**
|
|
536
518
|
* Validated LLMOps configuration
|
|
@@ -538,17 +520,11 @@ declare const llmopsConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
538
520
|
* Note: schema is optional in input but always present after validation
|
|
539
521
|
* Either database or providers must be present (enforced by schema)
|
|
540
522
|
*/
|
|
541
|
-
type OtlpConfig = {
|
|
542
|
-
endpoint: string;
|
|
543
|
-
headers?: Record<string, string>;
|
|
544
|
-
protocol: 'http/protobuf' | 'http/json';
|
|
545
|
-
};
|
|
546
523
|
type ValidatedLLMOpsConfig = {
|
|
547
524
|
database?: unknown;
|
|
548
525
|
basePath: string;
|
|
549
526
|
schema: string;
|
|
550
527
|
providers?: InlineProvidersConfig;
|
|
551
|
-
otlp?: OtlpConfig;
|
|
552
528
|
};
|
|
553
529
|
/**
|
|
554
530
|
* Input type for LLMOps configuration (before validation)
|
|
@@ -560,11 +536,6 @@ type LLMOpsConfigInput = {
|
|
|
560
536
|
basePath?: string;
|
|
561
537
|
schema?: string;
|
|
562
538
|
providers?: InlineProvidersConfig;
|
|
563
|
-
otlp?: {
|
|
564
|
-
endpoint: string;
|
|
565
|
-
headers?: Record<string, string>;
|
|
566
|
-
protocol?: 'http/protobuf' | 'http/json';
|
|
567
|
-
};
|
|
568
539
|
};
|
|
569
540
|
declare function validateLLMOpsConfig(config?: unknown): ValidatedLLMOpsConfig;
|
|
570
541
|
//#endregion
|
|
@@ -3297,6 +3268,7 @@ declare const insertSpanSchema: z$1.ZodObject<{
|
|
|
3297
3268
|
source: z$1.ZodDefault<z$1.ZodEnum<{
|
|
3298
3269
|
gateway: "gateway";
|
|
3299
3270
|
otlp: "otlp";
|
|
3271
|
+
langsmith: "langsmith";
|
|
3300
3272
|
}>>;
|
|
3301
3273
|
input: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUnknown>>;
|
|
3302
3274
|
output: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUnknown>>;
|
|
@@ -4221,4 +4193,4 @@ declare class ManifestRouter {
|
|
|
4221
4193
|
routeWithWeights(configIdOrSlug: string, environmentId: string, context?: RoutingContext): RoutingResult | null;
|
|
4222
4194
|
}
|
|
4223
4195
|
//#endregion
|
|
4224
|
-
export { type AnthropicProviderConfig, type AnyProviderConfig, AuthClientDatabaseConfig, AuthClientOptions, type AzureAIProviderConfig, type AzureOpenAIProviderConfig, BaseCacheConfig, type BaseProviderConfig, type BedrockProviderConfig, COST_SUMMARY_GROUP_BY, CacheBackend, CacheBackendType, CacheConfig, CacheEntry, CacheOptions, CacheService, CacheStats, ChatCompletionCreateParamsBase, Config, ConfigVariant, ConfigVariantsDataLayer, ConfigVariantsTable, ConfigsDataLayer, ConfigsTable, type CortexProviderConfig, CostResult, CostSummaryGroupBy, DEFAULT_PROVIDER_ENV_VARS, DataLayer, Database, DatabaseConnection, DatabaseOptions, DatabaseType, Dataset, DatasetRecord, DatasetRecordsTable, DatasetVersion, DatasetVersionRecord, DatasetVersionRecordsTable, DatasetVersionsTable, DatasetsDataLayer, DatasetsTable, Environment, EnvironmentSecret, EnvironmentSecretsDataLayer, EnvironmentSecretsTable, EnvironmentsDataLayer, EnvironmentsTable, FileCacheBackend, FileCacheConfig, type FireworksAIProviderConfig, GatewayManifest, type GoogleProviderConfig, GuardrailConfig, GuardrailConfigsDataLayer, GuardrailConfigsTable, GuardrailResult, 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, LLMRequest, LLMRequestInsert, LLMRequestsDataLayer, LLMRequestsTable, MS, ManifestBuilder, ManifestConfig, ManifestEnvironment, ManifestGuardrail, ManifestProviderGuardrailOverride, ManifestRouter, ManifestService, ManifestTargetingRule, ManifestVariantVersion, MemoryCacheBackend, MemoryCacheConfig, MigrationOptions, MigrationResult, type MistralAIProviderConfig, ModelPricing, type OpenAIProviderConfig, type OracleProviderConfig,
|
|
4196
|
+
export { type AnthropicProviderConfig, type AnyProviderConfig, AuthClientDatabaseConfig, AuthClientOptions, type AzureAIProviderConfig, type AzureOpenAIProviderConfig, BaseCacheConfig, type BaseProviderConfig, type BedrockProviderConfig, COST_SUMMARY_GROUP_BY, CacheBackend, CacheBackendType, CacheConfig, CacheEntry, CacheOptions, CacheService, CacheStats, ChatCompletionCreateParamsBase, Config, ConfigVariant, ConfigVariantsDataLayer, ConfigVariantsTable, ConfigsDataLayer, ConfigsTable, type CortexProviderConfig, CostResult, CostSummaryGroupBy, DEFAULT_PROVIDER_ENV_VARS, DataLayer, Database, DatabaseConnection, DatabaseOptions, DatabaseType, Dataset, DatasetRecord, DatasetRecordsTable, DatasetVersion, DatasetVersionRecord, DatasetVersionRecordsTable, DatasetVersionsTable, DatasetsDataLayer, DatasetsTable, Environment, EnvironmentSecret, EnvironmentSecretsDataLayer, EnvironmentSecretsTable, EnvironmentsDataLayer, EnvironmentsTable, FileCacheBackend, FileCacheConfig, type FireworksAIProviderConfig, GatewayManifest, type GoogleProviderConfig, GuardrailConfig, GuardrailConfigsDataLayer, GuardrailConfigsTable, GuardrailResult, 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, LLMRequest, LLMRequestInsert, LLMRequestsDataLayer, LLMRequestsTable, MS, ManifestBuilder, ManifestConfig, ManifestEnvironment, ManifestGuardrail, ManifestProviderGuardrailOverride, ManifestRouter, ManifestService, ManifestTargetingRule, ManifestVariantVersion, MemoryCacheBackend, MemoryCacheConfig, MigrationOptions, MigrationResult, type MistralAIProviderConfig, ModelPricing, type OpenAIProviderConfig, type OracleProviderConfig, Playground, PlaygroundColumn, PlaygroundResult, PlaygroundResultsDataLayer, PlaygroundResultsTable, PlaygroundRun, PlaygroundRunsDataLayer, PlaygroundRunsTable, PlaygroundsDataLayer, PlaygroundsTable, Prettify, PricingProvider, ProviderConfig, type ProviderConfigMap, ProviderConfigsDataLayer, ProviderConfigsTable, ProviderGuardrailOverride, ProviderGuardrailOverridesDataLayer, ProviderGuardrailOverridesTable, type ProvidersConfig, RoutingContext, RoutingResult, SCHEMA_METADATA, type SagemakerProviderConfig, Selectable, Span, SpanEvent, SpanEventInsert, SpanEventsTable, SpanInsert, SpansTable, type StabilityAIProviderConfig, SupportedProviders, TableName, TargetingRule, TargetingRulesDataLayer, TargetingRulesTable, Trace, TraceUpsert, TracesDataLayer, TracesTable, Updateable, UsageData, type ValidatedLLMOpsConfig, Variant, VariantJsonData, VariantVersion, VariantVersionsDataLayer, VariantVersionsTable, VariantsDataLayer, VariantsTable, type VertexAIProviderConfig, type WorkersAIProviderConfig, WorkspaceSettings, WorkspaceSettingsDataLayer, WorkspaceSettingsTable, calculateCacheAwareCost, calculateCost, chatCompletionCreateParamsBaseSchema, configVariantsSchema, configsSchema, createConfigDataLayer, createConfigVariantDataLayer, createDataLayer, createDatabase, createDatabaseFromConnection, createDatasetsDataLayer, createEnvironmentDataLayer, createEnvironmentSecretDataLayer, createGuardrailConfigsDataLayer, createLLMRequestsDataLayer, createNeonDialect, createPlaygroundDataLayer, createPlaygroundResultsDataLayer, createPlaygroundRunsDataLayer, createProviderConfigsDataLayer, createProviderGuardrailOverridesDataLayer, createTargetingRulesDataLayer, createTracesDataLayer, createVariantDataLayer, createVariantVersionsDataLayer, createWorkspaceSettingsDataLayer, datasetRecordsSchema, datasetVersionRecordsSchema, datasetVersionsSchema, datasetsSchema, detectDatabaseType, dollarsToMicroDollars, environmentSecretsSchema, environmentsSchema, executeWithSchema, formatCost, gateway, generateId, getAuthClientOptions, 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 };
|
package/dist/index.d.mts
CHANGED
|
@@ -495,24 +495,11 @@ declare const llmopsConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
495
495
|
requestTimeout: z.ZodOptional<z.ZodNumber>;
|
|
496
496
|
forwardHeaders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
497
497
|
}, z.core.$loose>>>;
|
|
498
|
-
otlp: z.ZodOptional<z.ZodObject<{
|
|
499
|
-
endpoint: z.ZodString;
|
|
500
|
-
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
501
|
-
protocol: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
502
|
-
"http/protobuf": "http/protobuf";
|
|
503
|
-
"http/json": "http/json";
|
|
504
|
-
}>>>;
|
|
505
|
-
}, z.core.$strip>>;
|
|
506
498
|
}, z.core.$strip>, z.ZodTransform<{
|
|
507
499
|
providers: InlineProviderConfig[];
|
|
508
500
|
basePath: string;
|
|
509
501
|
schema: string;
|
|
510
502
|
database?: any;
|
|
511
|
-
otlp?: {
|
|
512
|
-
endpoint: string;
|
|
513
|
-
protocol: "http/protobuf" | "http/json";
|
|
514
|
-
headers?: Record<string, string> | undefined;
|
|
515
|
-
} | undefined;
|
|
516
503
|
}, {
|
|
517
504
|
basePath: string;
|
|
518
505
|
schema: string;
|
|
@@ -526,11 +513,6 @@ declare const llmopsConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
526
513
|
requestTimeout?: number | undefined;
|
|
527
514
|
forwardHeaders?: string[] | undefined;
|
|
528
515
|
}[] | undefined;
|
|
529
|
-
otlp?: {
|
|
530
|
-
endpoint: string;
|
|
531
|
-
protocol: "http/protobuf" | "http/json";
|
|
532
|
-
headers?: Record<string, string> | undefined;
|
|
533
|
-
} | undefined;
|
|
534
516
|
}>>;
|
|
535
517
|
/**
|
|
536
518
|
* Validated LLMOps configuration
|
|
@@ -538,17 +520,11 @@ declare const llmopsConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
538
520
|
* Note: schema is optional in input but always present after validation
|
|
539
521
|
* Either database or providers must be present (enforced by schema)
|
|
540
522
|
*/
|
|
541
|
-
type OtlpConfig = {
|
|
542
|
-
endpoint: string;
|
|
543
|
-
headers?: Record<string, string>;
|
|
544
|
-
protocol: 'http/protobuf' | 'http/json';
|
|
545
|
-
};
|
|
546
523
|
type ValidatedLLMOpsConfig = {
|
|
547
524
|
database?: unknown;
|
|
548
525
|
basePath: string;
|
|
549
526
|
schema: string;
|
|
550
527
|
providers?: InlineProvidersConfig;
|
|
551
|
-
otlp?: OtlpConfig;
|
|
552
528
|
};
|
|
553
529
|
/**
|
|
554
530
|
* Input type for LLMOps configuration (before validation)
|
|
@@ -560,11 +536,6 @@ type LLMOpsConfigInput = {
|
|
|
560
536
|
basePath?: string;
|
|
561
537
|
schema?: string;
|
|
562
538
|
providers?: InlineProvidersConfig;
|
|
563
|
-
otlp?: {
|
|
564
|
-
endpoint: string;
|
|
565
|
-
headers?: Record<string, string>;
|
|
566
|
-
protocol?: 'http/protobuf' | 'http/json';
|
|
567
|
-
};
|
|
568
539
|
};
|
|
569
540
|
declare function validateLLMOpsConfig(config?: unknown): ValidatedLLMOpsConfig;
|
|
570
541
|
//#endregion
|
|
@@ -3297,6 +3268,7 @@ declare const insertSpanSchema: z$1.ZodObject<{
|
|
|
3297
3268
|
source: z$1.ZodDefault<z$1.ZodEnum<{
|
|
3298
3269
|
gateway: "gateway";
|
|
3299
3270
|
otlp: "otlp";
|
|
3271
|
+
langsmith: "langsmith";
|
|
3300
3272
|
}>>;
|
|
3301
3273
|
input: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUnknown>>;
|
|
3302
3274
|
output: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodUnknown>>;
|
|
@@ -4221,4 +4193,4 @@ declare class ManifestRouter {
|
|
|
4221
4193
|
routeWithWeights(configIdOrSlug: string, environmentId: string, context?: RoutingContext): RoutingResult | null;
|
|
4222
4194
|
}
|
|
4223
4195
|
//#endregion
|
|
4224
|
-
export { type AnthropicProviderConfig, type AnyProviderConfig, AuthClientDatabaseConfig, AuthClientOptions, 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 ConfigVariantsDataLayer, type ConfigVariantsTable, type ConfigsDataLayer, 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 EnvironmentSecretsDataLayer, type EnvironmentSecretsTable, type EnvironmentsDataLayer, type EnvironmentsTable, FileCacheBackend, FileCacheConfig, type FireworksAIProviderConfig, type GatewayManifest, type GoogleProviderConfig, type GuardrailConfig, type GuardrailConfigsDataLayer, 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, type LLMRequestsDataLayer, LLMRequestsTable, MS, ManifestBuilder, type ManifestConfig, type ManifestEnvironment, type ManifestGuardrail, type ManifestProviderGuardrailOverride, ManifestRouter, ManifestService, type ManifestTargetingRule, type ManifestVariantVersion, MemoryCacheBackend, MemoryCacheConfig, MigrationOptions, MigrationResult, type MistralAIProviderConfig, ModelPricing, type OpenAIProviderConfig, type OracleProviderConfig, type
|
|
4196
|
+
export { type AnthropicProviderConfig, type AnyProviderConfig, AuthClientDatabaseConfig, AuthClientOptions, 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 ConfigVariantsDataLayer, type ConfigVariantsTable, type ConfigsDataLayer, 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 EnvironmentSecretsDataLayer, type EnvironmentSecretsTable, type EnvironmentsDataLayer, type EnvironmentsTable, FileCacheBackend, FileCacheConfig, type FireworksAIProviderConfig, type GatewayManifest, type GoogleProviderConfig, type GuardrailConfig, type GuardrailConfigsDataLayer, 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, type LLMRequestsDataLayer, LLMRequestsTable, MS, ManifestBuilder, type ManifestConfig, type ManifestEnvironment, type ManifestGuardrail, type ManifestProviderGuardrailOverride, ManifestRouter, ManifestService, type ManifestTargetingRule, type ManifestVariantVersion, MemoryCacheBackend, MemoryCacheConfig, MigrationOptions, MigrationResult, type MistralAIProviderConfig, ModelPricing, type OpenAIProviderConfig, type OracleProviderConfig, type Playground, type PlaygroundColumn, type PlaygroundResult, type PlaygroundResultsDataLayer, PlaygroundResultsTable, type PlaygroundRun, type PlaygroundRunsDataLayer, PlaygroundRunsTable, type PlaygroundsDataLayer, PlaygroundsTable, Prettify, PricingProvider, type ProviderConfig, type ProviderConfigMap, type ProviderConfigsDataLayer, ProviderConfigsTable, type ProviderGuardrailOverride, type ProviderGuardrailOverridesDataLayer, ProviderGuardrailOverridesTable, type ProvidersConfig, type RoutingContext, type RoutingResult, SCHEMA_METADATA, type SagemakerProviderConfig, Selectable, Span, SpanEvent, type SpanEventInsert, SpanEventsTable, type SpanInsert, SpansTable, type StabilityAIProviderConfig, SupportedProviders, type TableName, type TargetingRule, type TargetingRulesDataLayer, type TargetingRulesTable, Trace, type TraceUpsert, type TracesDataLayer, TracesTable, Updateable, UsageData, type ValidatedLLMOpsConfig, type Variant, VariantJsonData, type VariantVersion, type VariantVersionsDataLayer, VariantVersionsTable, type VariantsDataLayer, type VariantsTable, type VertexAIProviderConfig, type WorkersAIProviderConfig, type WorkspaceSettings, type WorkspaceSettingsDataLayer, WorkspaceSettingsTable, calculateCacheAwareCost, calculateCost, chatCompletionCreateParamsBaseSchema, configVariantsSchema, configsSchema, createConfigDataLayer, createConfigVariantDataLayer, createDataLayer, createDatabase, createDatabaseFromConnection, createDatasetsDataLayer, createEnvironmentDataLayer, createEnvironmentSecretDataLayer, createGuardrailConfigsDataLayer, createLLMRequestsDataLayer, createNeonDialect, createPlaygroundDataLayer, createPlaygroundResultsDataLayer, createPlaygroundRunsDataLayer, createProviderConfigsDataLayer, createProviderGuardrailOverridesDataLayer, createTargetingRulesDataLayer, createTracesDataLayer, createVariantDataLayer, createVariantVersionsDataLayer, createWorkspaceSettingsDataLayer, datasetRecordsSchema, datasetVersionRecordsSchema, datasetVersionsSchema, datasetsSchema, detectDatabaseType, dollarsToMicroDollars, environmentSecretsSchema, environmentsSchema, executeWithSchema, formatCost, gateway, generateId, getAuthClientOptions, 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 };
|
package/dist/index.mjs
CHANGED
|
@@ -628,24 +628,13 @@ const inlineProviderConfigSchema = object({
|
|
|
628
628
|
*/
|
|
629
629
|
const providersConfigSchema = array(inlineProviderConfigSchema).optional();
|
|
630
630
|
/**
|
|
631
|
-
* Schema for OTLP endpoint configuration.
|
|
632
|
-
* When configured, trace/span data is forwarded to this endpoint
|
|
633
|
-
* instead of being stored in PostgreSQL.
|
|
634
|
-
*/
|
|
635
|
-
const otlpConfigSchema = object({
|
|
636
|
-
endpoint: string().url("OTLP endpoint must be a valid URL").refine((url) => url.startsWith("http://") || url.startsWith("https://"), "OTLP endpoint must use http:// or https://"),
|
|
637
|
-
headers: record(string(), string()).optional(),
|
|
638
|
-
protocol: _enum(["http/protobuf", "http/json"]).optional().default("http/protobuf")
|
|
639
|
-
}).optional();
|
|
640
|
-
/**
|
|
641
631
|
* Base schema without refinements (used for transform)
|
|
642
632
|
*/
|
|
643
633
|
const llmopsConfigBaseSchema = object({
|
|
644
634
|
database: any().optional(),
|
|
645
635
|
basePath: string().min(1, "Base path cannot be empty").refine((path$1) => path$1.startsWith("/"), "Base path must start with a forward slash").default("/llmops"),
|
|
646
636
|
schema: string().optional().default("llmops"),
|
|
647
|
-
providers: providersConfigSchema
|
|
648
|
-
otlp: otlpConfigSchema
|
|
637
|
+
providers: providersConfigSchema
|
|
649
638
|
});
|
|
650
639
|
const llmopsConfigSchema = llmopsConfigBaseSchema.transform((config) => ({
|
|
651
640
|
...config,
|
|
@@ -3185,7 +3174,11 @@ const insertSpanSchema = zod_default.object({
|
|
|
3185
3174
|
environmentId: zod_default.string().uuid().nullable().optional(),
|
|
3186
3175
|
providerConfigId: zod_default.string().uuid().nullable().optional(),
|
|
3187
3176
|
requestId: zod_default.string().uuid().nullable().optional(),
|
|
3188
|
-
source: zod_default.enum([
|
|
3177
|
+
source: zod_default.enum([
|
|
3178
|
+
"gateway",
|
|
3179
|
+
"otlp",
|
|
3180
|
+
"langsmith"
|
|
3181
|
+
]).default("gateway"),
|
|
3189
3182
|
input: zod_default.unknown().nullable().optional(),
|
|
3190
3183
|
output: zod_default.unknown().nullable().optional(),
|
|
3191
3184
|
attributes: zod_default.record(zod_default.string(), zod_default.unknown()).default({})
|
|
@@ -3283,11 +3276,16 @@ const createTracesDataLayer = (db) => {
|
|
|
3283
3276
|
},
|
|
3284
3277
|
batchInsertSpans: async (spans) => {
|
|
3285
3278
|
if (spans.length === 0) return { count: 0 };
|
|
3286
|
-
const validatedSpans =
|
|
3279
|
+
const validatedSpans = [];
|
|
3280
|
+
for (const span of spans) {
|
|
3287
3281
|
const result = await insertSpanSchema.safeParseAsync(span);
|
|
3288
|
-
if (!result.success)
|
|
3289
|
-
|
|
3290
|
-
|
|
3282
|
+
if (!result.success) {
|
|
3283
|
+
logger.warn(`[batchInsertSpans] Skipping invalid span ${span.spanId}: ${result.error.message}`);
|
|
3284
|
+
continue;
|
|
3285
|
+
}
|
|
3286
|
+
validatedSpans.push(result.data);
|
|
3287
|
+
}
|
|
3288
|
+
if (validatedSpans.length === 0) return { count: 0 };
|
|
3291
3289
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3292
3290
|
const values = validatedSpans.map((span) => ({
|
|
3293
3291
|
id: randomUUID(),
|
|
@@ -3324,11 +3322,16 @@ const createTracesDataLayer = (db) => {
|
|
|
3324
3322
|
},
|
|
3325
3323
|
batchInsertSpanEvents: async (events) => {
|
|
3326
3324
|
if (events.length === 0) return { count: 0 };
|
|
3327
|
-
const validatedEvents =
|
|
3325
|
+
const validatedEvents = [];
|
|
3326
|
+
for (const event of events) {
|
|
3328
3327
|
const result = await insertSpanEventSchema.safeParseAsync(event);
|
|
3329
|
-
if (!result.success)
|
|
3330
|
-
|
|
3331
|
-
|
|
3328
|
+
if (!result.success) {
|
|
3329
|
+
logger.warn(`[batchInsertSpanEvents] Skipping invalid event: ${result.error.message}`);
|
|
3330
|
+
continue;
|
|
3331
|
+
}
|
|
3332
|
+
validatedEvents.push(result.data);
|
|
3333
|
+
}
|
|
3334
|
+
if (validatedEvents.length === 0) return { count: 0 };
|
|
3332
3335
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3333
3336
|
const values = validatedEvents.map((event) => ({
|
|
3334
3337
|
id: randomUUID(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llmops/core",
|
|
3
|
-
"version": "0.6.7-beta.
|
|
3
|
+
"version": "0.6.7-beta.2",
|
|
4
4
|
"description": "Core LLMOps functionality and utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"kysely": "^0.28.8",
|
|
56
56
|
"kysely-neon": "^2.0.2",
|
|
57
57
|
"pino": "^10.1.0",
|
|
58
|
-
"@llmops/gateway": "^0.6.7-beta.
|
|
58
|
+
"@llmops/gateway": "^0.6.7-beta.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/json-logic-js": "^2.0.8",
|