@babav/knowledge-core-client 0.44.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export interface RetrievalContent {
44
44
  parent_id: string;
45
45
  document_id: string;
46
46
  corpus_id: string;
47
+ chunk_id?: string | null;
47
48
  source_type: "corpus" | "conversation_attachment";
48
49
  visibility: Visibility | string;
49
50
  metadata: Record<string, unknown>;
@@ -551,7 +552,7 @@ export type QueryProfileWrite = Partial<Omit<QueryProfile, "id" | "tenant_id">>;
551
552
  export interface ModelOptions {
552
553
  models: Record<string, {
553
554
  label: string;
554
- provider: "anthropic" | "vertex";
555
+ provider: "anthropic" | "vertex" | "moonshot";
555
556
  kind: "text" | "vision";
556
557
  supports_reasoning: boolean;
557
558
  }>;
@@ -567,6 +568,43 @@ export interface ModelOptions {
567
568
  values: string[];
568
569
  }>;
569
570
  }
571
+ export type BenchmarkTier = "client_quick" | "screening" | "full";
572
+ export type BenchmarkCategory = "quality" | "quality_cost" | "quality_latency";
573
+ /** A query profile's benchmark score. `cache_hit=false` + `scoring_status="queued"` means scoring was
574
+ * enqueued (poll again / check the leaderboard). */
575
+ export interface BenchmarkScore {
576
+ cache_hit: boolean;
577
+ config_hash: string;
578
+ eval_version: string | null;
579
+ scoring_status: "unscored" | "queued" | "running" | "scored" | "failed" | "stale";
580
+ composite_q: number | null;
581
+ sub_scores: Record<string, unknown>;
582
+ per_language: Record<string, number>;
583
+ gates: Record<string, unknown>;
584
+ prod_cost_per_query_usd: number | null;
585
+ p50_ms: number | null;
586
+ p95_ms: number | null;
587
+ percentile: number | null;
588
+ job_id: string | null;
589
+ }
590
+ export interface LeaderboardEntry {
591
+ rank: number;
592
+ config_hash: string;
593
+ generation_model: string | null;
594
+ composite_q: number | null;
595
+ prod_cost_per_query_usd: number | null;
596
+ p50_ms: number | null;
597
+ p95_ms: number | null;
598
+ sub_scores: Record<string, unknown>;
599
+ per_language: Record<string, number>;
600
+ config: Record<string, unknown> | null;
601
+ }
602
+ export interface Leaderboard {
603
+ eval_version: string;
604
+ tier: BenchmarkTier;
605
+ category: BenchmarkCategory;
606
+ entries: LeaderboardEntry[];
607
+ }
570
608
  export interface Tenant {
571
609
  id: UUID;
572
610
  name: string;
@@ -1006,6 +1044,21 @@ export declare class KnowledgeCoreClient extends HttpBase {
1006
1044
  /** The model catalog for an query-profile-config UI: supported models + default per field, per-model
1007
1045
  * capabilities (`supports_reasoning`), and mode↔model dependencies. */
1008
1046
  modelOptions: () => Promise<ModelOptions>;
1047
+ /** Benchmark this query profile against the eval-set (cache-first on config hash; a miss queues
1048
+ * scoring). Returns the score (quality composite + sub-scores + gates + cost + latency) or a
1049
+ * queued status. See also `benchmark.leaderboard`. */
1050
+ benchmark: (id: UUID) => Promise<BenchmarkScore>;
1051
+ };
1052
+ /** Query-profile benchmark leaderboards — top-N system-swept profiles per eval version, per tier
1053
+ * (client_quick | screening | full) and per category (quality | quality_cost | quality_latency).
1054
+ * Tenant-anonymous (keyed by config hash); never a customer config. */
1055
+ benchmark: {
1056
+ leaderboard: (q?: {
1057
+ eval_version?: string;
1058
+ tier?: BenchmarkTier;
1059
+ category?: BenchmarkCategory;
1060
+ limit?: number;
1061
+ }) => Promise<Leaderboard>;
1009
1062
  };
1010
1063
  /** Ingestion profiles — the build-side config object (counterpart to query profiles): a tenant-owned,
1011
1064
  * named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike a query profile
package/dist/index.js CHANGED
@@ -468,6 +468,16 @@ export class KnowledgeCoreClient extends HttpBase {
468
468
  /** The model catalog for an query-profile-config UI: supported models + default per field, per-model
469
469
  * capabilities (`supports_reasoning`), and mode↔model dependencies. */
470
470
  modelOptions: () => this.request("GET", "/v1/query-profiles/model-options"),
471
+ /** Benchmark this query profile against the eval-set (cache-first on config hash; a miss queues
472
+ * scoring). Returns the score (quality composite + sub-scores + gates + cost + latency) or a
473
+ * queued status. See also `benchmark.leaderboard`. */
474
+ benchmark: (id) => this.request("POST", `/v1/query-profiles/${id}/benchmark`),
475
+ };
476
+ /** Query-profile benchmark leaderboards — top-N system-swept profiles per eval version, per tier
477
+ * (client_quick | screening | full) and per category (quality | quality_cost | quality_latency).
478
+ * Tenant-anonymous (keyed by config hash); never a customer config. */
479
+ benchmark = {
480
+ leaderboard: (q) => this.request("GET", "/v1/benchmark/leaderboard", { query: q }),
471
481
  };
472
482
  /** Ingestion profiles — the build-side config object (counterpart to query profiles): a tenant-owned,
473
483
  * named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike a query profile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babav/knowledge-core-client",
3
- "version": "0.44.0",
3
+ "version": "0.46.0",
4
4
  "description": "TypeScript client for the Babav Knowledge Core API (Deno + Node 18+, zero deps). Includes the babav.visual grammar TYPES at the ./visual subpath (types only; all visual rendering is server-side).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -64,6 +64,7 @@ export interface RetrievalContent {
64
64
  parent_id: string;
65
65
  document_id: string;
66
66
  corpus_id: string;
67
+ chunk_id?: string | null; // Qdrant point id of the best-matching child chunk ("{document_id}::{seq}")
67
68
  source_type: "corpus" | "conversation_attachment";
68
69
  visibility: Visibility | string;
69
70
  metadata: Record<string, unknown>;
@@ -518,10 +519,50 @@ export type QueryProfileWrite = Partial<Omit<QueryProfile, "id" | "tenant_id">>;
518
519
  * `modes` says which model field governs each mode (reasoning is valid only if that model's
519
520
  * supports_reasoning is true). KC provides the data; the UI decides presentation. */
520
521
  export interface ModelOptions {
521
- models: Record<string, { label: string; provider: "anthropic" | "vertex"; kind: "text" | "vision"; supports_reasoning: boolean }>;
522
+ models: Record<string, { label: string; provider: "anthropic" | "vertex" | "moonshot"; kind: "text" | "vision"; supports_reasoning: boolean }>;
522
523
  fields: Record<string, { supported: string[]; default: string; applies_when?: string; applies_to?: string[]; note?: string }>;
523
524
  modes: Record<string, { depends_on: string; values: string[] }>;
524
525
  }
526
+
527
+ // ---- benchmark (score-my-profile + leaderboards) --------------------------
528
+ export type BenchmarkTier = "client_quick" | "screening" | "full";
529
+ export type BenchmarkCategory = "quality" | "quality_cost" | "quality_latency";
530
+
531
+ /** A query profile's benchmark score. `cache_hit=false` + `scoring_status="queued"` means scoring was
532
+ * enqueued (poll again / check the leaderboard). */
533
+ export interface BenchmarkScore {
534
+ cache_hit: boolean;
535
+ config_hash: string;
536
+ eval_version: string | null;
537
+ scoring_status: "unscored" | "queued" | "running" | "scored" | "failed" | "stale";
538
+ composite_q: number | null;
539
+ sub_scores: Record<string, unknown>;
540
+ per_language: Record<string, number>;
541
+ gates: Record<string, unknown>;
542
+ prod_cost_per_query_usd: number | null;
543
+ p50_ms: number | null;
544
+ p95_ms: number | null;
545
+ percentile: number | null;
546
+ job_id: string | null;
547
+ }
548
+ export interface LeaderboardEntry {
549
+ rank: number;
550
+ config_hash: string;
551
+ generation_model: string | null;
552
+ composite_q: number | null;
553
+ prod_cost_per_query_usd: number | null;
554
+ p50_ms: number | null;
555
+ p95_ms: number | null;
556
+ sub_scores: Record<string, unknown>;
557
+ per_language: Record<string, number>;
558
+ config: Record<string, unknown> | null;
559
+ }
560
+ export interface Leaderboard {
561
+ eval_version: string;
562
+ tier: BenchmarkTier;
563
+ category: BenchmarkCategory;
564
+ entries: LeaderboardEntry[];
565
+ }
525
566
  export interface Tenant {
526
567
  id: UUID;
527
568
  name: string;
@@ -1141,6 +1182,18 @@ export class KnowledgeCoreClient extends HttpBase {
1141
1182
  /** The model catalog for an query-profile-config UI: supported models + default per field, per-model
1142
1183
  * capabilities (`supports_reasoning`), and mode↔model dependencies. */
1143
1184
  modelOptions: () => this.request<ModelOptions>("GET", "/v1/query-profiles/model-options"),
1185
+ /** Benchmark this query profile against the eval-set (cache-first on config hash; a miss queues
1186
+ * scoring). Returns the score (quality composite + sub-scores + gates + cost + latency) or a
1187
+ * queued status. See also `benchmark.leaderboard`. */
1188
+ benchmark: (id: UUID) => this.request<BenchmarkScore>("POST", `/v1/query-profiles/${id}/benchmark`),
1189
+ };
1190
+
1191
+ /** Query-profile benchmark leaderboards — top-N system-swept profiles per eval version, per tier
1192
+ * (client_quick | screening | full) and per category (quality | quality_cost | quality_latency).
1193
+ * Tenant-anonymous (keyed by config hash); never a customer config. */
1194
+ benchmark = {
1195
+ leaderboard: (q?: { eval_version?: string; tier?: BenchmarkTier; category?: BenchmarkCategory; limit?: number }) =>
1196
+ this.request<Leaderboard>("GET", "/v1/benchmark/leaderboard", { query: q }),
1144
1197
  };
1145
1198
 
1146
1199
  /** Ingestion profiles — the build-side config object (counterpart to query profiles): a tenant-owned,