@llmops/core 0.6.7-beta.3 → 0.6.8

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.mjs CHANGED
@@ -1,8 +1,7 @@
1
- import { A as schemas, B as any, C as llmRequestsSchema, D as playgroundsSchema, E as playgroundRunsSchema, F as variantVersionsSchema, G as object, H as boolean, I as variantsSchema, J as union, K as record, L as workspaceSettingsSchema, M as spansSchema, N as targetingRulesSchema, O as providerConfigsSchema, P as tracesSchema, R as zod_default, S as guardrailConfigsSchema, T as playgroundResultsSchema, U as literal, V as array, W as number, Y as unknown, _ as datasetVersionRecordsSchema, a as matchType, b as environmentSecretsSchema, c as logger, d as validatePartialTableData, f as validateTableData, g as datasetRecordsSchema, h as configsSchema, i as getMigrations, j as spanEventsSchema, k as providerGuardrailOverridesSchema, l as parsePartialTableData, m as configVariantsSchema, n as createDatabaseFromConnection, o as runAutoMigrations, p as SCHEMA_METADATA, q as string, r as detectDatabaseType, s as getAuthClientOptions, t as createDatabase, u as parseTableData, v as datasetVersionsSchema, w as playgroundColumnSchema, x as environmentsSchema, y as datasetsSchema, z as _enum } from "./db-Cd1KR24Y.mjs";
1
+ import { A as schemas, B as any, C as llmRequestsSchema, D as playgroundsSchema, E as playgroundRunsSchema, F as variantVersionsSchema, G as object, H as boolean, I as variantsSchema, J as union, K as record, L as workspaceSettingsSchema, M as spansSchema, N as targetingRulesSchema, O as providerConfigsSchema, P as tracesSchema, R as zod_default, S as guardrailConfigsSchema, T as playgroundResultsSchema, U as literal, V as array, W as number, Y as unknown, _ as datasetVersionRecordsSchema, a as matchType, b as environmentSecretsSchema, c as logger, d as validatePartialTableData, f as validateTableData, g as datasetRecordsSchema, h as configsSchema, i as getMigrations, j as spanEventsSchema, k as providerGuardrailOverridesSchema, l as parsePartialTableData, m as configVariantsSchema, n as createDatabaseFromConnection, o as runAutoMigrations, p as SCHEMA_METADATA, q as string, r as detectDatabaseType, s as getAuthClientOptions, t as createDatabase, u as parseTableData, v as datasetVersionsSchema, w as playgroundColumnSchema, x as environmentsSchema, y as datasetsSchema, z as _enum } from "./db-H8SfNI38.mjs";
2
2
  import { n as executeWithSchema, t as createNeonDialect } from "./neon-dialect-DySGBYUi.mjs";
3
3
  import gateway from "@llmops/gateway";
4
4
  import { sql } from "kysely";
5
- import * as fs from "node:fs/promises";
6
5
  import * as path from "node:path";
7
6
  import { createRandomStringGenerator } from "@better-auth/utils/random";
8
7
  import { createHash, randomBytes, randomUUID } from "node:crypto";
@@ -639,7 +638,7 @@ const llmopsConfigBaseSchema = object({
639
638
  const llmopsConfigSchema = llmopsConfigBaseSchema.transform((config) => ({
640
639
  ...config,
641
640
  providers: mergeWithDefaultProviders(config.providers)
642
- })).refine((config) => config.database !== void 0 || config.providers && config.providers.length > 0, "Either database or providers must be configured. Set a database connection, configure providers explicitly, or set API key environment variables (e.g., OPENAI_API_KEY).");
641
+ }));
643
642
  function validateLLMOpsConfig(config) {
644
643
  const result = llmopsConfigSchema.safeParse(config ?? {});
645
644
  if (!result.success) {
@@ -860,14 +859,16 @@ var FileCacheBackend = class {
860
859
  if (!this.loaded) await this.loadPromise;
861
860
  }
862
861
  async ensureDataDir() {
862
+ const { mkdir } = await import("node:fs/promises");
863
863
  const dir = path.dirname(this.cacheFile);
864
864
  try {
865
- await fs.mkdir(dir, { recursive: true });
865
+ await mkdir(dir, { recursive: true });
866
866
  } catch {}
867
867
  }
868
868
  async loadCache() {
869
869
  try {
870
- const content = await fs.readFile(this.cacheFile, "utf-8");
870
+ const { readFile } = await import("node:fs/promises");
871
+ const content = await readFile(this.cacheFile, "utf-8");
871
872
  this.data = JSON.parse(content);
872
873
  this.updateStats();
873
874
  this.loaded = true;
@@ -879,7 +880,8 @@ var FileCacheBackend = class {
879
880
  async saveCache() {
880
881
  try {
881
882
  await this.ensureDataDir();
882
- await fs.writeFile(this.cacheFile, JSON.stringify(this.data, null, 2));
883
+ const { writeFile } = await import("node:fs/promises");
884
+ await writeFile(this.cacheFile, JSON.stringify(this.data, null, 2));
883
885
  } catch {}
884
886
  }
885
887
  scheduleSave() {
@@ -2066,7 +2068,8 @@ const costSummarySchema = zod_default.object({
2066
2068
  variantId: zod_default.string().uuid().optional(),
2067
2069
  environmentId: zod_default.string().uuid().optional(),
2068
2070
  tags: zod_default.record(zod_default.string(), zod_default.array(zod_default.string())).optional(),
2069
- groupBy: zod_default.enum(COST_SUMMARY_GROUP_BY).optional()
2071
+ groupBy: zod_default.enum(COST_SUMMARY_GROUP_BY).optional(),
2072
+ tagKeys: zod_default.array(zod_default.string()).optional()
2070
2073
  });
2071
2074
  /**
2072
2075
  * Helper to create column reference for SQL
@@ -2282,7 +2285,7 @@ const createLLMRequestsDataLayer = (db) => {
2282
2285
  getCostSummary: async (params) => {
2283
2286
  const result = await costSummarySchema.safeParseAsync(params);
2284
2287
  if (!result.success) throw new LLMOpsError(`Invalid parameters: ${result.error.message}`);
2285
- const { startDate, endDate, groupBy, configId, variantId, environmentId, tags } = result.data;
2288
+ const { startDate, endDate, groupBy, configId, variantId, environmentId, tags, tagKeys } = result.data;
2286
2289
  let baseQuery = db.selectFrom("llm_requests").where(sql`${col$1("createdAt")} >= ${startDate.toISOString()}`).where(sql`${col$1("createdAt")} <= ${endDate.toISOString()}`);
2287
2290
  if (configId) baseQuery = baseQuery.where("configId", "=", configId);
2288
2291
  if (variantId) baseQuery = baseQuery.where("variantId", "=", variantId);
@@ -2341,6 +2344,10 @@ const createLLMRequestsDataLayer = (db) => {
2341
2344
  conditions.push(sql`${col$1("tags")}->>${key} IN (${valueList})`);
2342
2345
  }
2343
2346
  }
2347
+ if (tagKeys && tagKeys.length > 0) {
2348
+ const tagKeyList = sql.join(tagKeys.map((k) => sql`${k}`), sql`, `);
2349
+ conditions.push(sql`t.key IN (${tagKeyList})`);
2350
+ }
2344
2351
  const whereClause = sql.join(conditions, sql` AND `);
2345
2352
  return (await sql`
2346
2353
  SELECT t.key || ':' || t.value as "groupKey",
@@ -1,3 +1,3 @@
1
- const require_neon_dialect = require('./neon-dialect-oh8u9vRy.cjs');
1
+ const require_neon_dialect = require('./neon-dialect-Dn80Acj9.cjs');
2
2
 
3
3
  exports.createNeonDialect = require_neon_dialect.createNeonDialect;
@@ -1,4 +1,4 @@
1
- const require_db = require('./db-i0OOYxJm.cjs');
1
+ const require_db = require('./db-DsEVRoua.cjs');
2
2
  let kysely_neon = require("kysely-neon");
3
3
  require("@neondatabase/serverless");
4
4
 
@@ -1,4 +1,4 @@
1
- const require_db = require('./db-i0OOYxJm.cjs');
1
+ const require_db = require('./db-DsEVRoua.cjs');
2
2
  let kysely = require("kysely");
3
3
 
4
4
  //#region src/db/node-sqlite-dialect.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmops/core",
3
- "version": "0.6.7-beta.3",
3
+ "version": "0.6.8",
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.3"
58
+ "@llmops/gateway": "^0.6.8"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/json-logic-js": "^2.0.8",