@babav/knowledge-core-client 0.13.0 → 0.15.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
@@ -51,9 +51,14 @@ export interface RetrievalContent {
51
51
  }
52
52
  export interface QueryOverrides {
53
53
  generation_model?: string;
54
+ max_response_tokens?: number;
54
55
  top_k?: number;
56
+ candidate_multiplier?: number;
57
+ sibling_window?: number;
55
58
  rerank_instruction?: string;
56
59
  max_hops?: number;
60
+ decomposition_model?: string;
61
+ groundedness_verifier_model?: string;
57
62
  groundedness_threshold?: number;
58
63
  grounding_enabled?: boolean;
59
64
  citations_enabled?: boolean;
@@ -87,23 +92,31 @@ export interface Citation {
87
92
  custom_metadata: Record<string, unknown>;
88
93
  source_url: string | null;
89
94
  }
90
- export interface GroundednessSentence {
95
+ export interface GroundednessClaim {
91
96
  /** Char span into the RAW answer (concatenated tokens / `final.answer`). */
92
97
  text_span: [number, number];
93
- /** The exact sentence text highlight by matching this in the rendered output
94
- * (robust to markdown rendering + inserted citation markers) rather than offsets. */
98
+ /** The exact claim text (a verbatim substring of the answer) highlight by matching
99
+ * this in the rendered output rather than by offsets (robust to markdown + citation
100
+ * markers). Claims with `passed === false` are the unsupported spans to flag. */
95
101
  text: string;
102
+ /** Verdict from the LLM verifier: 1.0 = supported, 0.5 = partially supported,
103
+ * 0.0 = unsupported/contradicted (by the retrieved sources). */
96
104
  score: number;
97
105
  passed: boolean | null;
106
+ /** The verifier's brief justification for the verdict (why supported/partial/unsupported). */
107
+ reason?: string | null;
98
108
  }
109
+ /** @deprecated Alias — groundedness entries are now per-claim. Use GroundednessClaim. */
110
+ export type GroundednessSentence = GroundednessClaim;
99
111
  export interface Groundedness {
100
- /** Headline faithfulness of the whole answer vs. the full context. */
112
+ /** Headline faithfulness of the whole answer = mean of the per-claim scores. */
101
113
  overall: {
102
114
  score: number | null;
103
115
  passed: boolean | null;
104
116
  };
105
- /** Per-sentence faithfulness flag low-`score` sentences as weakly grounded. */
106
- sentences: GroundednessSentence[];
117
+ /** Per-CLAIM faithfulness from an independent Claude (Haiku) verifier that checks each
118
+ * extracted claim against the retrieved sources. `model` reports the verifier. */
119
+ sentences: GroundednessClaim[];
107
120
  model: string;
108
121
  threshold: number | null;
109
122
  }
@@ -191,9 +204,14 @@ export interface Agent {
191
204
  identity_prompt: string | null;
192
205
  response_prompt: string | null;
193
206
  generation_model: string | null;
207
+ max_response_tokens: number | null;
194
208
  top_k: number | null;
209
+ candidate_multiplier: number | null;
210
+ sibling_window: number | null;
195
211
  rerank_instruction: string | null;
196
212
  max_hops: number | null;
213
+ decomposition_model: string | null;
214
+ groundedness_verifier_model: string | null;
197
215
  groundedness_threshold: number | null;
198
216
  grounding_enabled: boolean | null;
199
217
  citations_enabled: boolean | null;
@@ -488,9 +506,14 @@ export declare class AdminClient extends HttpBase {
488
506
  identity_prompt?: string;
489
507
  response_prompt?: string;
490
508
  generation_model?: string;
509
+ max_response_tokens?: number;
491
510
  top_k?: number;
511
+ candidate_multiplier?: number;
512
+ sibling_window?: number;
492
513
  rerank_instruction?: string;
493
514
  max_hops?: number;
515
+ decomposition_model?: string;
516
+ groundedness_verifier_model?: string;
494
517
  groundedness_threshold?: number;
495
518
  grounding_enabled?: boolean;
496
519
  citations_enabled?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babav/knowledge-core-client",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "TypeScript client for the Babav Knowledge Core API (Deno + Node 18+, zero deps).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -61,9 +61,14 @@ export interface RetrievalContent {
61
61
 
62
62
  export interface QueryOverrides {
63
63
  generation_model?: string;
64
+ max_response_tokens?: number; // max answer tokens
64
65
  top_k?: number;
66
+ candidate_multiplier?: number; // candidate pool = top_k * this (before rerank)
67
+ sibling_window?: number; // adjacent sections fetched each side of a hit
65
68
  rerank_instruction?: string;
66
69
  max_hops?: number;
70
+ decomposition_model?: string; // model for query decomposition
71
+ groundedness_verifier_model?: string; // model for the groundedness LLM judge
67
72
  groundedness_threshold?: number;
68
73
  grounding_enabled?: boolean; // groundedness score (default off)
69
74
  citations_enabled?: boolean; // source attribution (default on)
@@ -102,20 +107,28 @@ export interface Citation {
102
107
  source_url: string | null;
103
108
  }
104
109
 
105
- export interface GroundednessSentence {
110
+ export interface GroundednessClaim {
106
111
  /** Char span into the RAW answer (concatenated tokens / `final.answer`). */
107
112
  text_span: [number, number];
108
- /** The exact sentence text highlight by matching this in the rendered output
109
- * (robust to markdown rendering + inserted citation markers) rather than offsets. */
113
+ /** The exact claim text (a verbatim substring of the answer) highlight by matching
114
+ * this in the rendered output rather than by offsets (robust to markdown + citation
115
+ * markers). Claims with `passed === false` are the unsupported spans to flag. */
110
116
  text: string;
117
+ /** Verdict from the LLM verifier: 1.0 = supported, 0.5 = partially supported,
118
+ * 0.0 = unsupported/contradicted (by the retrieved sources). */
111
119
  score: number;
112
120
  passed: boolean | null;
121
+ /** The verifier's brief justification for the verdict (why supported/partial/unsupported). */
122
+ reason?: string | null;
113
123
  }
124
+ /** @deprecated Alias — groundedness entries are now per-claim. Use GroundednessClaim. */
125
+ export type GroundednessSentence = GroundednessClaim;
114
126
  export interface Groundedness {
115
- /** Headline faithfulness of the whole answer vs. the full context. */
127
+ /** Headline faithfulness of the whole answer = mean of the per-claim scores. */
116
128
  overall: { score: number | null; passed: boolean | null };
117
- /** Per-sentence faithfulness flag low-`score` sentences as weakly grounded. */
118
- sentences: GroundednessSentence[];
129
+ /** Per-CLAIM faithfulness from an independent Claude (Haiku) verifier that checks each
130
+ * extracted claim against the retrieved sources. `model` reports the verifier. */
131
+ sentences: GroundednessClaim[];
119
132
  model: string;
120
133
  threshold: number | null;
121
134
  }
@@ -204,9 +217,14 @@ export interface Agent {
204
217
  identity_prompt: string | null; // answer-system: who/purpose (null => server default)
205
218
  response_prompt: string | null; // answer-system: output guidelines (null => server default)
206
219
  generation_model: string | null;
220
+ max_response_tokens: number | null;
207
221
  top_k: number | null;
222
+ candidate_multiplier: number | null;
223
+ sibling_window: number | null;
208
224
  rerank_instruction: string | null;
209
225
  max_hops: number | null;
226
+ decomposition_model: string | null;
227
+ groundedness_verifier_model: string | null;
210
228
  groundedness_threshold: number | null;
211
229
  grounding_enabled: boolean | null;
212
230
  citations_enabled: boolean | null;
@@ -624,7 +642,7 @@ export class AdminClient extends HttpBase {
624
642
 
625
643
  // Agents are query agents, global for now.
626
644
  agents = {
627
- create: (b: { name: string; identity_prompt?: string; response_prompt?: string; generation_model?: string; top_k?: number; rerank_instruction?: string; max_hops?: number; groundedness_threshold?: number; grounding_enabled?: boolean; citations_enabled?: boolean }) =>
645
+ create: (b: { name: string; identity_prompt?: string; response_prompt?: string; generation_model?: string; max_response_tokens?: number; top_k?: number; candidate_multiplier?: number; sibling_window?: number; rerank_instruction?: string; max_hops?: number; decomposition_model?: string; groundedness_verifier_model?: string; groundedness_threshold?: number; grounding_enabled?: boolean; citations_enabled?: boolean }) =>
628
646
  this.request<Agent>("POST", "/v1/agents", { json: b }),
629
647
  update: (id: UUID, b: Partial<Omit<Agent, "id">>) =>
630
648
  this.request<Agent>("PATCH", `/v1/agents/${id}`, { json: b }),