@babav/knowledge-core-client 0.42.0 → 0.43.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 +23 -23
- package/dist/index.js +29 -29
- package/package.json +1 -1
- package/src/index.ts +36 -36
package/dist/index.d.ts
CHANGED
|
@@ -215,7 +215,7 @@ export interface Corpus {
|
|
|
215
215
|
/** Build-time knob bundle that DEFINES an index. Defaults are today's blessed config, so a
|
|
216
216
|
* profile created with no params is the blessed profile. Change any knob => different vectors
|
|
217
217
|
* => a different physical collection. Embedding/indexing/chunking is SYSTEM-level, never a
|
|
218
|
-
* query knob — this is the build-side counterpart to
|
|
218
|
+
* query knob — this is the build-side counterpart to a query profile. */
|
|
219
219
|
export interface IngestionProfileParams {
|
|
220
220
|
chunker: string;
|
|
221
221
|
chunk_child_max_tokens: number;
|
|
@@ -477,7 +477,7 @@ export interface Conversation {
|
|
|
477
477
|
export interface Message {
|
|
478
478
|
id: UUID;
|
|
479
479
|
conversation_id: UUID;
|
|
480
|
-
|
|
480
|
+
query_profile_id: UUID | null;
|
|
481
481
|
corpus_ids: UUID[] | null;
|
|
482
482
|
query: string;
|
|
483
483
|
answer: string | null;
|
|
@@ -506,7 +506,7 @@ export interface Feedback {
|
|
|
506
506
|
rating: number | null;
|
|
507
507
|
comment: string | null;
|
|
508
508
|
}
|
|
509
|
-
export interface
|
|
509
|
+
export interface QueryProfile {
|
|
510
510
|
id: UUID;
|
|
511
511
|
tenant_id: UUID;
|
|
512
512
|
name: string;
|
|
@@ -543,8 +543,8 @@ export interface Agent {
|
|
|
543
543
|
* (null/omit => server default); model fields must be one of
|
|
544
544
|
* `agents.modelOptions().fields[field].supported`. The owning tenant is the caller's key —
|
|
545
545
|
* it is never part of the body. */
|
|
546
|
-
export type
|
|
547
|
-
/** Model catalog for the
|
|
546
|
+
export type QueryProfileWrite = Partial<Omit<QueryProfile, "id" | "tenant_id">>;
|
|
547
|
+
/** Model catalog for the query-profile-config UI (GET /v1/query-profiles/model-options). `models` maps id → its
|
|
548
548
|
* capabilities; `fields` gives each agent model-field its supported ids + default (+ usage metadata);
|
|
549
549
|
* `modes` says which model field governs each mode (reasoning is valid only if that model's
|
|
550
550
|
* supports_reasoning is true). KC provides the data; the UI decides presentation. */
|
|
@@ -686,11 +686,11 @@ export interface DocumentEventHandlers {
|
|
|
686
686
|
export declare class KnowledgeCoreClient extends HttpBase {
|
|
687
687
|
/** @param opts.apiKey a TENANT key, supplied by the caller. */
|
|
688
688
|
constructor(opts: ClientOptions);
|
|
689
|
-
query(
|
|
689
|
+
query(profileId: UUID, body: QueryRequest): Promise<QueryResponse>;
|
|
690
690
|
/** Streaming query (SSE). Resolves when the stream ends (the Promise resolving is normal, not an
|
|
691
691
|
* error). Pass `signal` and abort() on unmount / when the user cancels or navigates away so the
|
|
692
692
|
* connection doesn't linger. Transient (ends on `done`) — no reopen logic needed. */
|
|
693
|
-
queryStream(
|
|
693
|
+
queryStream(profileId: UUID, body: QueryRequest, handlers: StreamHandlers, signal?: AbortSignal): Promise<void>;
|
|
694
694
|
/** Fetch a visual's PNG bytes BY ID. This is the ONLY way to get a visual image — the API never
|
|
695
695
|
* returns a URL. Authenticated + tenant-scoped like every call. Use `visual.id` from a query
|
|
696
696
|
* response / streamed `visual` event / persisted message. Returns a Blob (browser: `URL.
|
|
@@ -708,11 +708,11 @@ export declare class KnowledgeCoreClient extends HttpBase {
|
|
|
708
708
|
/** DUMMY-PROOF CHAT. Every message goes through a conversation — it is structurally impossible
|
|
709
709
|
* to send a chat turn as a non-persisted one-shot. Use this for ANY chat UI. Use the low-level
|
|
710
710
|
* `query`/`queryStream` ONLY for programmatic one-shots (tools).
|
|
711
|
-
* New chat: const chat = kc.chat(
|
|
712
|
-
* Resume: const chat = kc.chat(
|
|
711
|
+
* New chat: const chat = kc.chat(profileId, corpusIds);
|
|
712
|
+
* Resume: const chat = kc.chat(profileId, corpusIds, { conversationId });
|
|
713
713
|
* The conversation is created LAZILY on the first `send()` (opening a "new chat" and never
|
|
714
714
|
* sending leaves nothing behind). See ChatSession.send. */
|
|
715
|
-
chat(
|
|
715
|
+
chat(profileId: UUID, corpusIds: UUID[], opts?: {
|
|
716
716
|
conversationId?: UUID;
|
|
717
717
|
}): ChatSession;
|
|
718
718
|
/** Shared SSE reader for the document-status streams (documents.events / folders.events).
|
|
@@ -984,25 +984,25 @@ export declare class KnowledgeCoreClient extends HttpBase {
|
|
|
984
984
|
get: (id: UUID) => Promise<Feedback>;
|
|
985
985
|
delete: (id: UUID) => Promise<void>;
|
|
986
986
|
};
|
|
987
|
-
|
|
988
|
-
/** List this tenant's
|
|
987
|
+
queryProfiles: {
|
|
988
|
+
/** List this tenant's query profiles. */
|
|
989
989
|
list: (q?: {
|
|
990
990
|
limit?: number;
|
|
991
991
|
cursor?: string;
|
|
992
|
-
}) => Promise<Page<
|
|
993
|
-
listAll: () => Promise<
|
|
994
|
-
get: (id: UUID) => Promise<
|
|
995
|
-
/** Create
|
|
996
|
-
create: (b:
|
|
992
|
+
}) => Promise<Page<QueryProfile>>;
|
|
993
|
+
listAll: () => Promise<QueryProfile[]>;
|
|
994
|
+
get: (id: UUID) => Promise<QueryProfile>;
|
|
995
|
+
/** Create a query profile owned by this tenant (the owning tenant is the key's — no tenant_id in the body). */
|
|
996
|
+
create: (b: QueryProfileWrite & {
|
|
997
997
|
name: string;
|
|
998
|
-
}) => Promise<
|
|
999
|
-
update: (id: UUID, b:
|
|
998
|
+
}) => Promise<QueryProfile>;
|
|
999
|
+
update: (id: UUID, b: QueryProfileWrite) => Promise<QueryProfile>;
|
|
1000
1000
|
delete: (id: UUID) => Promise<void>;
|
|
1001
|
-
/** The model catalog for an
|
|
1001
|
+
/** The model catalog for an query-profile-config UI: supported models + default per field, per-model
|
|
1002
1002
|
* capabilities (`supports_reasoning`), and mode↔model dependencies. */
|
|
1003
1003
|
modelOptions: () => Promise<ModelOptions>;
|
|
1004
1004
|
};
|
|
1005
|
-
/** Ingestion profiles — the build-side config object (counterpart to
|
|
1005
|
+
/** Ingestion profiles — the build-side config object (counterpart to query profiles): a tenant-owned,
|
|
1006
1006
|
* named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike an agent
|
|
1007
1007
|
* (chosen per query), a profile binds at the TENANT/COLLECTION level — the tenant's one
|
|
1008
1008
|
* `is_default` profile governs how ALL its documents are ingested; swapping it re-indexes.
|
|
@@ -1024,7 +1024,7 @@ export declare class KnowledgeCoreClient extends HttpBase {
|
|
|
1024
1024
|
delete: (id: UUID) => Promise<void>;
|
|
1025
1025
|
/** The config catalog for a profile UI: supported embedding models (+ provider/dims),
|
|
1026
1026
|
* chunkers, distances, quantizations, per-field defaults/bounds, and the standard params.
|
|
1027
|
-
* Build-side mirror of `
|
|
1027
|
+
* Build-side mirror of `queryProfiles.modelOptions()`. */
|
|
1028
1028
|
modelOptions: () => Promise<IngestionProfileOptions>;
|
|
1029
1029
|
};
|
|
1030
1030
|
analytics: {
|
|
@@ -1123,7 +1123,7 @@ export declare class ChatSession {
|
|
|
1123
1123
|
#private;
|
|
1124
1124
|
/** The conversation id — null until the first `send()` (unless resumed). */
|
|
1125
1125
|
conversationId: UUID | null;
|
|
1126
|
-
constructor(kc: KnowledgeCoreClient,
|
|
1126
|
+
constructor(kc: KnowledgeCoreClient, profileId: UUID, corpusIds: UUID[], conversationId: UUID | null);
|
|
1127
1127
|
/** Send a chat message (streaming). Lazily creates the conversation on the first message and
|
|
1128
1128
|
* ALWAYS passes conversation_id, so the turn is persisted. `onConversationId` fires before the
|
|
1129
1129
|
* stream so you can show the conversation immediately. Pass `signal` to cancel on unmount. */
|
package/dist/index.js
CHANGED
|
@@ -156,18 +156,18 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
156
156
|
constructor(opts) {
|
|
157
157
|
super(opts);
|
|
158
158
|
}
|
|
159
|
-
// --- query (
|
|
160
|
-
query(
|
|
161
|
-
return this.request("POST", `/v1/
|
|
159
|
+
// --- query (query-profile-anchored) ---
|
|
160
|
+
query(profileId, body) {
|
|
161
|
+
return this.request("POST", `/v1/query-profiles/${profileId}/query`, { json: body });
|
|
162
162
|
}
|
|
163
163
|
/** Streaming query (SSE). Resolves when the stream ends (the Promise resolving is normal, not an
|
|
164
164
|
* error). Pass `signal` and abort() on unmount / when the user cancels or navigates away so the
|
|
165
165
|
* connection doesn't linger. Transient (ends on `done`) — no reopen logic needed. */
|
|
166
|
-
async queryStream(
|
|
167
|
-
const res = await this.raw("POST", `/v1/
|
|
166
|
+
async queryStream(profileId, body, handlers, signal) {
|
|
167
|
+
const res = await this.raw("POST", `/v1/query-profiles/${profileId}/query/stream`, { json: body, signal });
|
|
168
168
|
if (!res.ok || !res.body) {
|
|
169
169
|
const t = await res.text();
|
|
170
|
-
throw new KnowledgeCoreError(res.status, safeJson(t), `/v1/
|
|
170
|
+
throw new KnowledgeCoreError(res.status, safeJson(t), `/v1/query-profiles/${profileId}/query/stream`);
|
|
171
171
|
}
|
|
172
172
|
const reader = res.body.getReader();
|
|
173
173
|
const decoder = new TextDecoder();
|
|
@@ -217,12 +217,12 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
217
217
|
/** DUMMY-PROOF CHAT. Every message goes through a conversation — it is structurally impossible
|
|
218
218
|
* to send a chat turn as a non-persisted one-shot. Use this for ANY chat UI. Use the low-level
|
|
219
219
|
* `query`/`queryStream` ONLY for programmatic one-shots (tools).
|
|
220
|
-
* New chat: const chat = kc.chat(
|
|
221
|
-
* Resume: const chat = kc.chat(
|
|
220
|
+
* New chat: const chat = kc.chat(profileId, corpusIds);
|
|
221
|
+
* Resume: const chat = kc.chat(profileId, corpusIds, { conversationId });
|
|
222
222
|
* The conversation is created LAZILY on the first `send()` (opening a "new chat" and never
|
|
223
223
|
* sending leaves nothing behind). See ChatSession.send. */
|
|
224
|
-
chat(
|
|
225
|
-
return new ChatSession(this,
|
|
224
|
+
chat(profileId, corpusIds, opts) {
|
|
225
|
+
return new ChatSession(this, profileId, corpusIds, opts?.conversationId ?? null);
|
|
226
226
|
}
|
|
227
227
|
/** Shared SSE reader for the document-status streams (documents.events / folders.events).
|
|
228
228
|
* Resolves when the stream ends (server sends `complete` once nothing is in-flight, or the
|
|
@@ -453,21 +453,21 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
453
453
|
get: (id) => this.request("GET", `/v1/feedback/${id}`),
|
|
454
454
|
delete: (id) => this.request("DELETE", `/v1/feedback/${id}`),
|
|
455
455
|
};
|
|
456
|
-
// ---
|
|
457
|
-
|
|
458
|
-
/** List this tenant's
|
|
459
|
-
list: (q) => this.request("GET", "/v1/
|
|
460
|
-
listAll: () => this.pageAll("/v1/
|
|
461
|
-
get: (id) => this.request("GET", `/v1/
|
|
462
|
-
/** Create
|
|
463
|
-
create: (b) => this.request("POST", "/v1/
|
|
464
|
-
update: (id, b) => this.request("PATCH", `/v1/
|
|
465
|
-
delete: (id) => this.request("DELETE", `/v1/
|
|
466
|
-
/** The model catalog for an
|
|
456
|
+
// --- query profiles (tenant-owned query config; full CRUD with the tenant key) ---
|
|
457
|
+
queryProfiles = {
|
|
458
|
+
/** List this tenant's query profiles. */
|
|
459
|
+
list: (q) => this.request("GET", "/v1/query-profiles", { query: q }),
|
|
460
|
+
listAll: () => this.pageAll("/v1/query-profiles"),
|
|
461
|
+
get: (id) => this.request("GET", `/v1/query-profiles/${id}`),
|
|
462
|
+
/** Create a query profile owned by this tenant (the owning tenant is the key's — no tenant_id in the body). */
|
|
463
|
+
create: (b) => this.request("POST", "/v1/query-profiles", { json: b }),
|
|
464
|
+
update: (id, b) => this.request("PATCH", `/v1/query-profiles/${id}`, { json: b }),
|
|
465
|
+
delete: (id) => this.request("DELETE", `/v1/query-profiles/${id}`),
|
|
466
|
+
/** The model catalog for an query-profile-config UI: supported models + default per field, per-model
|
|
467
467
|
* capabilities (`supports_reasoning`), and mode↔model dependencies. */
|
|
468
|
-
modelOptions: () => this.request("GET", "/v1/
|
|
468
|
+
modelOptions: () => this.request("GET", "/v1/query-profiles/model-options"),
|
|
469
469
|
};
|
|
470
|
-
/** Ingestion profiles — the build-side config object (counterpart to
|
|
470
|
+
/** Ingestion profiles — the build-side config object (counterpart to query profiles): a tenant-owned,
|
|
471
471
|
* named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike an agent
|
|
472
472
|
* (chosen per query), a profile binds at the TENANT/COLLECTION level — the tenant's one
|
|
473
473
|
* `is_default` profile governs how ALL its documents are ingested; swapping it re-indexes.
|
|
@@ -484,7 +484,7 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
484
484
|
delete: (id) => this.request("DELETE", `/v1/profiles/${id}`),
|
|
485
485
|
/** The config catalog for a profile UI: supported embedding models (+ provider/dims),
|
|
486
486
|
* chunkers, distances, quantizations, per-field defaults/bounds, and the standard params.
|
|
487
|
-
* Build-side mirror of `
|
|
487
|
+
* Build-side mirror of `queryProfiles.modelOptions()`. */
|
|
488
488
|
modelOptions: () => this.request("GET", "/v1/profiles/model-options"),
|
|
489
489
|
};
|
|
490
490
|
// --- retrieval analytics (read-only, tenant-scoped, aggregate-on-read) ---
|
|
@@ -519,7 +519,7 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
519
519
|
}
|
|
520
520
|
// ---------------------------------------------------------------------------
|
|
521
521
|
// Admin client (tenant + API-key provisioning) — use the ADMIN key.
|
|
522
|
-
//
|
|
522
|
+
// Query profiles are tenant data; manage them with the tenant client (KnowledgeCoreClient.queryProfiles).
|
|
523
523
|
// ---------------------------------------------------------------------------
|
|
524
524
|
export class AdminClient extends HttpBase {
|
|
525
525
|
/** @param opts.apiKey the ADMIN key, supplied by the caller. */
|
|
@@ -544,14 +544,14 @@ export class AdminClient extends HttpBase {
|
|
|
544
544
|
* a chat turn is never lost and a chat conversation is never left blank. */
|
|
545
545
|
export class ChatSession {
|
|
546
546
|
#kc;
|
|
547
|
-
#
|
|
547
|
+
#profileId;
|
|
548
548
|
#corpusIds;
|
|
549
549
|
#creating = null;
|
|
550
550
|
/** The conversation id — null until the first `send()` (unless resumed). */
|
|
551
551
|
conversationId;
|
|
552
|
-
constructor(kc,
|
|
552
|
+
constructor(kc, profileId, corpusIds, conversationId) {
|
|
553
553
|
this.#kc = kc;
|
|
554
|
-
this.#
|
|
554
|
+
this.#profileId = profileId;
|
|
555
555
|
this.#corpusIds = corpusIds;
|
|
556
556
|
this.conversationId = conversationId;
|
|
557
557
|
}
|
|
@@ -572,7 +572,7 @@ export class ChatSession {
|
|
|
572
572
|
async send(text, o = {}) {
|
|
573
573
|
const convId = await this.#ensure(o, text);
|
|
574
574
|
o.onConversationId?.(convId);
|
|
575
|
-
await this.#kc.queryStream(this.#
|
|
575
|
+
await this.#kc.queryStream(this.#profileId, { corpus_ids: this.#corpusIds, query: text, conversation_id: convId,
|
|
576
576
|
overrides: o.overrides, filter: o.filter, visual: o.visual }, o, o.signal);
|
|
577
577
|
}
|
|
578
578
|
/** The conversation history (messages), once it exists. Empty page before the first send. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babav/knowledge-core-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.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
|
@@ -250,7 +250,7 @@ export interface Corpus {
|
|
|
250
250
|
/** Build-time knob bundle that DEFINES an index. Defaults are today's blessed config, so a
|
|
251
251
|
* profile created with no params is the blessed profile. Change any knob => different vectors
|
|
252
252
|
* => a different physical collection. Embedding/indexing/chunking is SYSTEM-level, never a
|
|
253
|
-
* query knob — this is the build-side counterpart to
|
|
253
|
+
* query knob — this is the build-side counterpart to a query profile. */
|
|
254
254
|
export interface IngestionProfileParams {
|
|
255
255
|
chunker: string; // "hybrid"
|
|
256
256
|
chunk_child_max_tokens: number;
|
|
@@ -446,7 +446,7 @@ export interface Conversation {
|
|
|
446
446
|
export interface Message {
|
|
447
447
|
id: UUID;
|
|
448
448
|
conversation_id: UUID;
|
|
449
|
-
|
|
449
|
+
query_profile_id: UUID | null;
|
|
450
450
|
corpus_ids: UUID[] | null;
|
|
451
451
|
query: string;
|
|
452
452
|
answer: string | null;
|
|
@@ -472,7 +472,7 @@ export interface Feedback {
|
|
|
472
472
|
rating: number | null;
|
|
473
473
|
comment: string | null;
|
|
474
474
|
}
|
|
475
|
-
export interface
|
|
475
|
+
export interface QueryProfile {
|
|
476
476
|
id: UUID;
|
|
477
477
|
tenant_id: UUID; // the owning tenant (every agent belongs to exactly one; no globals)
|
|
478
478
|
name: string;
|
|
@@ -511,9 +511,9 @@ export interface Agent {
|
|
|
511
511
|
* (null/omit => server default); model fields must be one of
|
|
512
512
|
* `agents.modelOptions().fields[field].supported`. The owning tenant is the caller's key —
|
|
513
513
|
* it is never part of the body. */
|
|
514
|
-
export type
|
|
514
|
+
export type QueryProfileWrite = Partial<Omit<QueryProfile, "id" | "tenant_id">>;
|
|
515
515
|
|
|
516
|
-
/** Model catalog for the
|
|
516
|
+
/** Model catalog for the query-profile-config UI (GET /v1/query-profiles/model-options). `models` maps id → its
|
|
517
517
|
* capabilities; `fields` gives each agent model-field its supported ids + default (+ usage metadata);
|
|
518
518
|
* `modes` says which model field governs each mode (reasoning is valid only if that model's
|
|
519
519
|
* supports_reasoning is true). KC provides the data; the UI decides presentation. */
|
|
@@ -758,19 +758,19 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
758
758
|
super(opts);
|
|
759
759
|
}
|
|
760
760
|
|
|
761
|
-
// --- query (
|
|
762
|
-
query(
|
|
763
|
-
return this.request("POST", `/v1/
|
|
761
|
+
// --- query (query-profile-anchored) ---
|
|
762
|
+
query(profileId: UUID, body: QueryRequest): Promise<QueryResponse> {
|
|
763
|
+
return this.request("POST", `/v1/query-profiles/${profileId}/query`, { json: body });
|
|
764
764
|
}
|
|
765
765
|
|
|
766
766
|
/** Streaming query (SSE). Resolves when the stream ends (the Promise resolving is normal, not an
|
|
767
767
|
* error). Pass `signal` and abort() on unmount / when the user cancels or navigates away so the
|
|
768
768
|
* connection doesn't linger. Transient (ends on `done`) — no reopen logic needed. */
|
|
769
|
-
async queryStream(
|
|
770
|
-
const res = await this.raw("POST", `/v1/
|
|
769
|
+
async queryStream(profileId: UUID, body: QueryRequest, handlers: StreamHandlers, signal?: AbortSignal): Promise<void> {
|
|
770
|
+
const res = await this.raw("POST", `/v1/query-profiles/${profileId}/query/stream`, { json: body, signal });
|
|
771
771
|
if (!res.ok || !res.body) {
|
|
772
772
|
const t = await res.text();
|
|
773
|
-
throw new KnowledgeCoreError(res.status, safeJson(t), `/v1/
|
|
773
|
+
throw new KnowledgeCoreError(res.status, safeJson(t), `/v1/query-profiles/${profileId}/query/stream`);
|
|
774
774
|
}
|
|
775
775
|
const reader = res.body.getReader();
|
|
776
776
|
const decoder = new TextDecoder();
|
|
@@ -825,12 +825,12 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
825
825
|
/** DUMMY-PROOF CHAT. Every message goes through a conversation — it is structurally impossible
|
|
826
826
|
* to send a chat turn as a non-persisted one-shot. Use this for ANY chat UI. Use the low-level
|
|
827
827
|
* `query`/`queryStream` ONLY for programmatic one-shots (tools).
|
|
828
|
-
* New chat: const chat = kc.chat(
|
|
829
|
-
* Resume: const chat = kc.chat(
|
|
828
|
+
* New chat: const chat = kc.chat(profileId, corpusIds);
|
|
829
|
+
* Resume: const chat = kc.chat(profileId, corpusIds, { conversationId });
|
|
830
830
|
* The conversation is created LAZILY on the first `send()` (opening a "new chat" and never
|
|
831
831
|
* sending leaves nothing behind). See ChatSession.send. */
|
|
832
|
-
chat(
|
|
833
|
-
return new ChatSession(this,
|
|
832
|
+
chat(profileId: UUID, corpusIds: UUID[], opts?: { conversationId?: UUID }): ChatSession {
|
|
833
|
+
return new ChatSession(this, profileId, corpusIds, opts?.conversationId ?? null);
|
|
834
834
|
}
|
|
835
835
|
|
|
836
836
|
/** Shared SSE reader for the document-status streams (documents.events / folders.events).
|
|
@@ -1126,22 +1126,22 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
1126
1126
|
delete: (id: UUID) => this.request<void>("DELETE", `/v1/feedback/${id}`),
|
|
1127
1127
|
};
|
|
1128
1128
|
|
|
1129
|
-
// ---
|
|
1130
|
-
|
|
1131
|
-
/** List this tenant's
|
|
1132
|
-
list: (q?: { limit?: number; cursor?: string }) => this.request<Page<
|
|
1133
|
-
listAll: () => this.pageAll<
|
|
1134
|
-
get: (id: UUID) => this.request<
|
|
1135
|
-
/** Create
|
|
1136
|
-
create: (b:
|
|
1137
|
-
update: (id: UUID, b:
|
|
1138
|
-
delete: (id: UUID) => this.request<void>("DELETE", `/v1/
|
|
1139
|
-
/** The model catalog for an
|
|
1129
|
+
// --- query profiles (tenant-owned query config; full CRUD with the tenant key) ---
|
|
1130
|
+
queryProfiles = {
|
|
1131
|
+
/** List this tenant's query profiles. */
|
|
1132
|
+
list: (q?: { limit?: number; cursor?: string }) => this.request<Page<QueryProfile>>("GET", "/v1/query-profiles", { query: q }),
|
|
1133
|
+
listAll: () => this.pageAll<QueryProfile>("/v1/query-profiles"),
|
|
1134
|
+
get: (id: UUID) => this.request<QueryProfile>("GET", `/v1/query-profiles/${id}`),
|
|
1135
|
+
/** Create a query profile owned by this tenant (the owning tenant is the key's — no tenant_id in the body). */
|
|
1136
|
+
create: (b: QueryProfileWrite & { name: string }) => this.request<QueryProfile>("POST", "/v1/query-profiles", { json: b }),
|
|
1137
|
+
update: (id: UUID, b: QueryProfileWrite) => this.request<QueryProfile>("PATCH", `/v1/query-profiles/${id}`, { json: b }),
|
|
1138
|
+
delete: (id: UUID) => this.request<void>("DELETE", `/v1/query-profiles/${id}`),
|
|
1139
|
+
/** The model catalog for an query-profile-config UI: supported models + default per field, per-model
|
|
1140
1140
|
* capabilities (`supports_reasoning`), and mode↔model dependencies. */
|
|
1141
|
-
modelOptions: () => this.request<ModelOptions>("GET", "/v1/
|
|
1141
|
+
modelOptions: () => this.request<ModelOptions>("GET", "/v1/query-profiles/model-options"),
|
|
1142
1142
|
};
|
|
1143
1143
|
|
|
1144
|
-
/** Ingestion profiles — the build-side config object (counterpart to
|
|
1144
|
+
/** Ingestion profiles — the build-side config object (counterpart to query profiles): a tenant-owned,
|
|
1145
1145
|
* named bundle of pipeline config (chunking + embedding + sparse + quant). Unlike an agent
|
|
1146
1146
|
* (chosen per query), a profile binds at the TENANT/COLLECTION level — the tenant's one
|
|
1147
1147
|
* `is_default` profile governs how ALL its documents are ingested; swapping it re-indexes.
|
|
@@ -1161,7 +1161,7 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
1161
1161
|
delete: (id: UUID) => this.request<void>("DELETE", `/v1/profiles/${id}`),
|
|
1162
1162
|
/** The config catalog for a profile UI: supported embedding models (+ provider/dims),
|
|
1163
1163
|
* chunkers, distances, quantizations, per-field defaults/bounds, and the standard params.
|
|
1164
|
-
* Build-side mirror of `
|
|
1164
|
+
* Build-side mirror of `queryProfiles.modelOptions()`. */
|
|
1165
1165
|
modelOptions: () => this.request<IngestionProfileOptions>("GET", "/v1/profiles/model-options"),
|
|
1166
1166
|
};
|
|
1167
1167
|
|
|
@@ -1202,7 +1202,7 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
1202
1202
|
|
|
1203
1203
|
// ---------------------------------------------------------------------------
|
|
1204
1204
|
// Admin client (tenant + API-key provisioning) — use the ADMIN key.
|
|
1205
|
-
//
|
|
1205
|
+
// Query profiles are tenant data; manage them with the tenant client (KnowledgeCoreClient.queryProfiles).
|
|
1206
1206
|
// ---------------------------------------------------------------------------
|
|
1207
1207
|
export class AdminClient extends HttpBase {
|
|
1208
1208
|
/** @param opts.apiKey the ADMIN key, supplied by the caller. */
|
|
@@ -1221,8 +1221,8 @@ export class AdminClient extends HttpBase {
|
|
|
1221
1221
|
listApiKeys: (tenantId: UUID, q?: { limit?: number; cursor?: string }) => this.request<Page<ApiKey>>("GET", `/v1/tenants/${tenantId}/api-keys`, { query: q }),
|
|
1222
1222
|
revokeApiKey: (tenantId: UUID, keyId: UUID) => this.request<void>("DELETE", `/v1/tenants/${tenantId}/api-keys/${keyId}`),
|
|
1223
1223
|
};
|
|
1224
|
-
//
|
|
1225
|
-
// KnowledgeCoreClient.
|
|
1224
|
+
// Query profiles are TENANT data, not an admin surface — manage them with the tenant key via
|
|
1225
|
+
// KnowledgeCoreClient.queryProfiles (create/update/delete/list/get/modelOptions).
|
|
1226
1226
|
}
|
|
1227
1227
|
|
|
1228
1228
|
export interface ChatSendOptions extends StreamHandlers {
|
|
@@ -1247,15 +1247,15 @@ export interface ChatSendOptions extends StreamHandlers {
|
|
|
1247
1247
|
* a chat turn is never lost and a chat conversation is never left blank. */
|
|
1248
1248
|
export class ChatSession {
|
|
1249
1249
|
#kc: KnowledgeCoreClient;
|
|
1250
|
-
#
|
|
1250
|
+
#profileId: UUID;
|
|
1251
1251
|
#corpusIds: UUID[];
|
|
1252
1252
|
#creating: Promise<UUID> | null = null;
|
|
1253
1253
|
/** The conversation id — null until the first `send()` (unless resumed). */
|
|
1254
1254
|
conversationId: UUID | null;
|
|
1255
1255
|
|
|
1256
|
-
constructor(kc: KnowledgeCoreClient,
|
|
1256
|
+
constructor(kc: KnowledgeCoreClient, profileId: UUID, corpusIds: UUID[], conversationId: UUID | null) {
|
|
1257
1257
|
this.#kc = kc;
|
|
1258
|
-
this.#
|
|
1258
|
+
this.#profileId = profileId;
|
|
1259
1259
|
this.#corpusIds = corpusIds;
|
|
1260
1260
|
this.conversationId = conversationId;
|
|
1261
1261
|
}
|
|
@@ -1278,7 +1278,7 @@ export class ChatSession {
|
|
|
1278
1278
|
const convId = await this.#ensure(o, text);
|
|
1279
1279
|
o.onConversationId?.(convId);
|
|
1280
1280
|
await this.#kc.queryStream(
|
|
1281
|
-
this.#
|
|
1281
|
+
this.#profileId,
|
|
1282
1282
|
{ corpus_ids: this.#corpusIds, query: text, conversation_id: convId,
|
|
1283
1283
|
overrides: o.overrides, filter: o.filter, visual: o.visual },
|
|
1284
1284
|
o,
|