@kognitivedev/cloud-knowledge-base 0.2.29
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/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-test.log +11 -0
- package/CHANGELOG.md +14 -0
- package/README.md +88 -0
- package/dist/context-adapter.d.ts +2 -0
- package/dist/context-adapter.js +35 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +16 -0
- package/dist/search.d.ts +2 -0
- package/dist/search.js +38 -0
- package/dist/shared.d.ts +23 -0
- package/dist/shared.js +167 -0
- package/dist/tool.d.ts +18 -0
- package/dist/tool.js +56 -0
- package/dist/types.d.ts +118 -0
- package/dist/types.js +2 -0
- package/dist/workflow.d.ts +4 -0
- package/dist/workflow.js +59 -0
- package/package.json +47 -0
- package/src/__tests__/cloud-knowledge-base.test.ts +493 -0
- package/src/context-adapter.ts +65 -0
- package/src/index.ts +29 -0
- package/src/search.ts +40 -0
- package/src/shared.ts +224 -0
- package/src/tool.ts +70 -0
- package/src/types.ts +131 -0
- package/src/workflow.ts +102 -0
- package/tsconfig.json +13 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
$ vitest run
|
|
2
|
+
|
|
3
|
+
RUN v3.2.4 /Users/vserifsaglam/work/memory-experiment/packages/cloud-knowledge-base
|
|
4
|
+
|
|
5
|
+
✓ src/__tests__/cloud-knowledge-base.test.ts (12 tests) 49ms
|
|
6
|
+
|
|
7
|
+
Test Files 1 passed (1)
|
|
8
|
+
Tests 12 passed (12)
|
|
9
|
+
Start at 17:30:10
|
|
10
|
+
Duration 942ms (transform 115ms, setup 0ms, collect 225ms, tests 49ms, environment 0ms, prepare 187ms)
|
|
11
|
+
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @kognitivedev/cloud-knowledge-base
|
|
2
|
+
|
|
3
|
+
## 0.2.29
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- release
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @kognitivedev/agents@0.2.29
|
|
11
|
+
- @kognitivedev/documents@0.2.29
|
|
12
|
+
- @kognitivedev/shared@0.2.29
|
|
13
|
+
- @kognitivedev/tools@0.2.29
|
|
14
|
+
- @kognitivedev/workflows@0.2.29
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @kognitivedev/cloud-knowledge-base
|
|
2
|
+
|
|
3
|
+
Managed cloud knowledge base SDK for Kognitive agents and workflows.
|
|
4
|
+
|
|
5
|
+
This package targets managed cloud pipelines, which are also the dashboard knowledge-base resource. A pipeline ID is the knowledge-base ID across SDKs, dashboard, agents, and workflows.
|
|
6
|
+
|
|
7
|
+
Managed knowledge bases are zero-config at the API level: documents are parsed into indexed artifacts and searched through Qdrant-native hybrid retrieval, using dense semantic vectors plus Qdrant BM25 sparse vectors.
|
|
8
|
+
|
|
9
|
+
Backend requirements for managed KB indexing/search are `REDIS_URL`, `QDRANT_URL`, and `OPENROUTER_API_KEY`. `QDRANT_API_KEY` is optional depending on your Qdrant deployment. Pipeline sync is asynchronous, so clients should poll the pipeline run/status endpoints before relying on newly uploaded content in search.
|
|
10
|
+
|
|
11
|
+
Every normalized hit includes citation metadata suitable for enterprise rendering and audit trails:
|
|
12
|
+
|
|
13
|
+
- `sourceId`
|
|
14
|
+
- `snippet`
|
|
15
|
+
- `filename`
|
|
16
|
+
- `mimeType`
|
|
17
|
+
- `pageNumber`
|
|
18
|
+
- `artifactType`
|
|
19
|
+
- `parseDocumentId`
|
|
20
|
+
|
|
21
|
+
## Search
|
|
22
|
+
|
|
23
|
+
Create and sync the pipeline with `@kognitivedev/documents`, wait for the run to complete, then search it from this package:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { KognitiveDocumentsClient } from "@kognitivedev/documents";
|
|
27
|
+
import { searchCloudKnowledgeBase } from "@kognitivedev/cloud-knowledge-base";
|
|
28
|
+
|
|
29
|
+
const documents = new KognitiveDocumentsClient({
|
|
30
|
+
baseUrl: process.env.KOGNITIVE_BASE_URL!,
|
|
31
|
+
apiKey: process.env.KOGNITIVE_API_KEY,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const pipeline = await documents.pipelines.create({ name: "Support KB" });
|
|
35
|
+
const source = await documents.pipelines.addFile(pipeline.id, { fileId: "file-id" });
|
|
36
|
+
const run = await documents.pipelines.sync(pipeline.id, { sourceId: String(source.id) });
|
|
37
|
+
await documents.pipelines.getRun(pipeline.id, run.id);
|
|
38
|
+
|
|
39
|
+
const result = await searchCloudKnowledgeBase({
|
|
40
|
+
baseUrl: process.env.KOGNITIVE_BASE_URL!,
|
|
41
|
+
apiKey: process.env.KOGNITIVE_API_KEY,
|
|
42
|
+
pipelineId: pipeline.id,
|
|
43
|
+
query: "What is the retention policy?",
|
|
44
|
+
topK: 5,
|
|
45
|
+
resourceId: { userId: "user_123" },
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Agent Context Adapter
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { createAgent } from "@kognitivedev/agents";
|
|
53
|
+
import { createCloudKnowledgeBaseContextAdapter } from "@kognitivedev/cloud-knowledge-base";
|
|
54
|
+
|
|
55
|
+
const agent = createAgent({
|
|
56
|
+
name: "support-agent",
|
|
57
|
+
instructions: "Answer using the managed knowledge base when relevant.",
|
|
58
|
+
runtime,
|
|
59
|
+
contextAdapters: [
|
|
60
|
+
createCloudKnowledgeBaseContextAdapter({
|
|
61
|
+
baseUrl: process.env.KOGNITIVE_BASE_URL!,
|
|
62
|
+
apiKey: process.env.KOGNITIVE_API_KEY,
|
|
63
|
+
pipelineId: "pipe_123",
|
|
64
|
+
topK: 4,
|
|
65
|
+
}),
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Workflow Step
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { createWorkflow } from "@kognitivedev/workflows";
|
|
74
|
+
import { createCloudKnowledgeBaseAnswerStep } from "@kognitivedev/cloud-knowledge-base";
|
|
75
|
+
|
|
76
|
+
const workflow = createWorkflow<{ query: string }>({ name: "kb-answer" })
|
|
77
|
+
.then(createCloudKnowledgeBaseAnswerStep({
|
|
78
|
+
id: "answer",
|
|
79
|
+
agent,
|
|
80
|
+
baseUrl: process.env.KOGNITIVE_BASE_URL!,
|
|
81
|
+
apiKey: process.env.KOGNITIVE_API_KEY,
|
|
82
|
+
pipelineId: "pipe_123",
|
|
83
|
+
getQuery: (input) => input.query,
|
|
84
|
+
}))
|
|
85
|
+
.build();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
There is also a lower-level `createCloudKnowledgeBaseSearchStep()` when you want retrieval without the answering stage.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCloudKnowledgeBaseContextAdapter = createCloudKnowledgeBaseContextAdapter;
|
|
4
|
+
const shared_1 = require("./shared");
|
|
5
|
+
const search_1 = require("./search");
|
|
6
|
+
const tool_1 = require("./tool");
|
|
7
|
+
function createInheritedSearchTool(options, input) {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
9
|
+
if (options.autoRegisterSearchTool === false) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return (0, tool_1.createCloudKnowledgeBaseSearchTool)(Object.assign(Object.assign(Object.assign({}, options), options.searchTool), { client: (_b = (_a = options.searchTool) === null || _a === void 0 ? void 0 : _a.client) !== null && _b !== void 0 ? _b : options.client, baseUrl: (_e = (_d = (_c = options.searchTool) === null || _c === void 0 ? void 0 : _c.baseUrl) !== null && _d !== void 0 ? _d : options.baseUrl) !== null && _e !== void 0 ? _e : input.baseUrl, apiKey: (_h = (_g = (_f = options.searchTool) === null || _f === void 0 ? void 0 : _f.apiKey) !== null && _g !== void 0 ? _g : options.apiKey) !== null && _h !== void 0 ? _h : input.apiKey, fetch: (_k = (_j = options.searchTool) === null || _j === void 0 ? void 0 : _j.fetch) !== null && _k !== void 0 ? _k : options.fetch, timeout: (_m = (_l = options.searchTool) === null || _l === void 0 ? void 0 : _l.timeout) !== null && _m !== void 0 ? _m : options.timeout, logLevel: (_p = (_o = options.searchTool) === null || _o === void 0 ? void 0 : _o.logLevel) !== null && _p !== void 0 ? _p : options.logLevel, pipelineId: (_r = (_q = options.searchTool) === null || _q === void 0 ? void 0 : _q.pipelineId) !== null && _r !== void 0 ? _r : options.pipelineId, resolvePipelineId: (_t = (_s = options.searchTool) === null || _s === void 0 ? void 0 : _s.resolvePipelineId) !== null && _t !== void 0 ? _t : options.resolvePipelineId }));
|
|
13
|
+
}
|
|
14
|
+
function createCloudKnowledgeBaseContextAdapter(options) {
|
|
15
|
+
return {
|
|
16
|
+
async resolve(input) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const resolvedInput = input;
|
|
19
|
+
const searchTool = createInheritedSearchTool(options, resolvedInput);
|
|
20
|
+
const query = (options.buildQuery
|
|
21
|
+
? await options.buildQuery(resolvedInput)
|
|
22
|
+
: (0, shared_1.extractLastUserText)(resolvedInput.messages))
|
|
23
|
+
.trim();
|
|
24
|
+
if (!query) {
|
|
25
|
+
return searchTool ? { tools: [searchTool] } : {};
|
|
26
|
+
}
|
|
27
|
+
const search = await (0, search_1.searchCloudKnowledgeBase)(Object.assign(Object.assign({}, options), { query, resourceId: resolvedInput.resourceId, messages: resolvedInput.messages, metadata: resolvedInput.metadata, abortSignal: resolvedInput.abortSignal, apiKey: (_a = options.apiKey) !== null && _a !== void 0 ? _a : resolvedInput.apiKey, baseUrl: (_b = options.baseUrl) !== null && _b !== void 0 ? _b : resolvedInput.baseUrl }));
|
|
28
|
+
return Object.assign({ systemBlock: (0, shared_1.buildSystemBlock)(search, {
|
|
29
|
+
maxHits: options.maxContextHits,
|
|
30
|
+
maxCharacters: options.maxContextCharacters,
|
|
31
|
+
emptyStateMessage: options.emptyStateMessage,
|
|
32
|
+
}) }, (searchTool ? { tools: [searchTool] } : {}));
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { searchCloudKnowledgeBase } from "./search";
|
|
2
|
+
export { createCloudKnowledgeBaseSearchTool } from "./tool";
|
|
3
|
+
export { createCloudKnowledgeBaseContextAdapter } from "./context-adapter";
|
|
4
|
+
export { createCloudKnowledgeBaseSearchStep, createCloudKnowledgeBaseAnswerStep, } from "./workflow";
|
|
5
|
+
export { createKnowledgeBaseSearchStep, createKnowledgeBaseAnswerStep, DEFAULT_KNOWLEDGE_BASE_ANSWER_SCHEMA, } from "@kognitivedev/workflows";
|
|
6
|
+
export type { CloudKnowledgeBaseCitation, CloudKnowledgeBaseHit, CloudKnowledgeBaseSearchResponse, CloudKnowledgeBaseAnswer, CloudKnowledgeBaseResolverInput, CloudKnowledgeBaseClientOptions, CloudKnowledgeBasePipelineOptions, CloudKnowledgeBaseSearchOptions, CloudKnowledgeBaseSearchToolOptions, CloudKnowledgeBaseContextAdapterOptions, CloudKnowledgeBaseContextAdapter, CloudKnowledgeBaseSearchStepOptions, CloudKnowledgeBaseAnswerStepOptions, } from "./types";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_KNOWLEDGE_BASE_ANSWER_SCHEMA = exports.createKnowledgeBaseAnswerStep = exports.createKnowledgeBaseSearchStep = exports.createCloudKnowledgeBaseAnswerStep = exports.createCloudKnowledgeBaseSearchStep = exports.createCloudKnowledgeBaseContextAdapter = exports.createCloudKnowledgeBaseSearchTool = exports.searchCloudKnowledgeBase = void 0;
|
|
4
|
+
var search_1 = require("./search");
|
|
5
|
+
Object.defineProperty(exports, "searchCloudKnowledgeBase", { enumerable: true, get: function () { return search_1.searchCloudKnowledgeBase; } });
|
|
6
|
+
var tool_1 = require("./tool");
|
|
7
|
+
Object.defineProperty(exports, "createCloudKnowledgeBaseSearchTool", { enumerable: true, get: function () { return tool_1.createCloudKnowledgeBaseSearchTool; } });
|
|
8
|
+
var context_adapter_1 = require("./context-adapter");
|
|
9
|
+
Object.defineProperty(exports, "createCloudKnowledgeBaseContextAdapter", { enumerable: true, get: function () { return context_adapter_1.createCloudKnowledgeBaseContextAdapter; } });
|
|
10
|
+
var workflow_1 = require("./workflow");
|
|
11
|
+
Object.defineProperty(exports, "createCloudKnowledgeBaseSearchStep", { enumerable: true, get: function () { return workflow_1.createCloudKnowledgeBaseSearchStep; } });
|
|
12
|
+
Object.defineProperty(exports, "createCloudKnowledgeBaseAnswerStep", { enumerable: true, get: function () { return workflow_1.createCloudKnowledgeBaseAnswerStep; } });
|
|
13
|
+
var workflows_1 = require("@kognitivedev/workflows");
|
|
14
|
+
Object.defineProperty(exports, "createKnowledgeBaseSearchStep", { enumerable: true, get: function () { return workflows_1.createKnowledgeBaseSearchStep; } });
|
|
15
|
+
Object.defineProperty(exports, "createKnowledgeBaseAnswerStep", { enumerable: true, get: function () { return workflows_1.createKnowledgeBaseAnswerStep; } });
|
|
16
|
+
Object.defineProperty(exports, "DEFAULT_KNOWLEDGE_BASE_ANSWER_SCHEMA", { enumerable: true, get: function () { return workflows_1.DEFAULT_KNOWLEDGE_BASE_ANSWER_SCHEMA; } });
|
package/dist/search.d.ts
ADDED
package/dist/search.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.searchCloudKnowledgeBase = searchCloudKnowledgeBase;
|
|
4
|
+
const shared_1 = require("./shared");
|
|
5
|
+
async function searchCloudKnowledgeBase(options) {
|
|
6
|
+
const query = options.query.trim();
|
|
7
|
+
if (!query) {
|
|
8
|
+
throw new Error("Cloud knowledge base search requires a non-empty query.");
|
|
9
|
+
}
|
|
10
|
+
const { client, pipelineId } = await (0, shared_1.resolveSearchConfig)(options, {
|
|
11
|
+
resourceId: options.resourceId,
|
|
12
|
+
messages: options.messages,
|
|
13
|
+
metadata: options.metadata,
|
|
14
|
+
abortSignal: options.abortSignal,
|
|
15
|
+
apiKey: options.apiKey,
|
|
16
|
+
baseUrl: options.baseUrl,
|
|
17
|
+
});
|
|
18
|
+
try {
|
|
19
|
+
const results = await client.pipelines.search(pipelineId, {
|
|
20
|
+
query,
|
|
21
|
+
topK: options.topK,
|
|
22
|
+
retrievalMode: options.retrievalMode,
|
|
23
|
+
});
|
|
24
|
+
const hits = results.map((result) => (0, shared_1.normalizeSearchResult)(result, options.snippetMaxLength));
|
|
25
|
+
return {
|
|
26
|
+
pipelineId,
|
|
27
|
+
query,
|
|
28
|
+
hits,
|
|
29
|
+
citations: hits.map((hit) => hit.citation),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
34
|
+
const wrapped = new Error(`Cloud knowledge base search failed for pipeline "${pipelineId}": ${reason}`);
|
|
35
|
+
wrapped.cause = error;
|
|
36
|
+
throw wrapped;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { KognitiveDocumentsClient, type PipelineSearchResult } from "@kognitivedev/documents";
|
|
2
|
+
import type { CloudKnowledgeBaseClientOptions, CloudKnowledgeBasePipelineOptions, CloudKnowledgeBaseResolverInput, CloudKnowledgeBaseSearchResponse, ResolvedCloudKnowledgeBaseSearchConfig } from "./types";
|
|
3
|
+
export declare function createSnippet(content: string, maxLength?: number): string;
|
|
4
|
+
export declare function createModelSummary(response: CloudKnowledgeBaseSearchResponse, options?: {
|
|
5
|
+
maxHits?: number;
|
|
6
|
+
maxCharacters?: number;
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function buildSystemBlock(response: CloudKnowledgeBaseSearchResponse, options?: {
|
|
9
|
+
maxHits?: number;
|
|
10
|
+
maxCharacters?: number;
|
|
11
|
+
emptyStateMessage?: string;
|
|
12
|
+
}): string;
|
|
13
|
+
export declare function createDocumentsClient(options: CloudKnowledgeBaseClientOptions): KognitiveDocumentsClient;
|
|
14
|
+
export declare function resolveClientOptions(options: CloudKnowledgeBaseClientOptions, inherited?: Pick<CloudKnowledgeBaseResolverInput, "apiKey" | "baseUrl">): CloudKnowledgeBaseClientOptions;
|
|
15
|
+
export declare function resolveSearchConfig(options: CloudKnowledgeBaseClientOptions & CloudKnowledgeBasePipelineOptions, input: CloudKnowledgeBaseResolverInput): Promise<ResolvedCloudKnowledgeBaseSearchConfig>;
|
|
16
|
+
export declare function normalizeSearchResult(result: PipelineSearchResult, snippetMaxLength?: number): {
|
|
17
|
+
metadata?: Record<string, unknown> | undefined;
|
|
18
|
+
sourceId: string;
|
|
19
|
+
content: string;
|
|
20
|
+
score: number;
|
|
21
|
+
citation: import("packages/workflows/dist").KnowledgeBaseCitation;
|
|
22
|
+
};
|
|
23
|
+
export declare function extractLastUserText(messages: unknown[] | undefined): string;
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSnippet = createSnippet;
|
|
4
|
+
exports.createModelSummary = createModelSummary;
|
|
5
|
+
exports.buildSystemBlock = buildSystemBlock;
|
|
6
|
+
exports.createDocumentsClient = createDocumentsClient;
|
|
7
|
+
exports.resolveClientOptions = resolveClientOptions;
|
|
8
|
+
exports.resolveSearchConfig = resolveSearchConfig;
|
|
9
|
+
exports.normalizeSearchResult = normalizeSearchResult;
|
|
10
|
+
exports.extractLastUserText = extractLastUserText;
|
|
11
|
+
const documents_1 = require("@kognitivedev/documents");
|
|
12
|
+
function isRecord(value) {
|
|
13
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
function normalizeText(value) {
|
|
16
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
17
|
+
}
|
|
18
|
+
function normalizeNumber(value) {
|
|
19
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
20
|
+
return value;
|
|
21
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
22
|
+
const parsed = Number(value);
|
|
23
|
+
if (Number.isFinite(parsed))
|
|
24
|
+
return parsed;
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
function createSnippet(content, maxLength = 240) {
|
|
29
|
+
const normalized = content.replace(/\s+/g, " ").trim();
|
|
30
|
+
if (normalized.length <= maxLength) {
|
|
31
|
+
return normalized;
|
|
32
|
+
}
|
|
33
|
+
return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}…`;
|
|
34
|
+
}
|
|
35
|
+
function createModelSummary(response, options = {}) {
|
|
36
|
+
var _a, _b, _c, _d;
|
|
37
|
+
const maxHits = (_a = options.maxHits) !== null && _a !== void 0 ? _a : 4;
|
|
38
|
+
const maxCharacters = (_b = options.maxCharacters) !== null && _b !== void 0 ? _b : 320;
|
|
39
|
+
const lines = [
|
|
40
|
+
`Knowledge base search results for "${response.query}" in pipeline ${response.pipelineId}:`,
|
|
41
|
+
];
|
|
42
|
+
for (const [index, hit] of response.hits.slice(0, maxHits).entries()) {
|
|
43
|
+
const citation = hit.citation;
|
|
44
|
+
const source = [
|
|
45
|
+
(_c = citation.filename) !== null && _c !== void 0 ? _c : hit.sourceId,
|
|
46
|
+
typeof citation.pageNumber === "number" ? `page ${citation.pageNumber}` : null,
|
|
47
|
+
citation.sectionTitle ? `section ${citation.sectionTitle}` : null,
|
|
48
|
+
citation.sheetName ? `sheet ${citation.sheetName}` : null,
|
|
49
|
+
typeof citation.rowNumber === "number" ? `row ${citation.rowNumber}` : null,
|
|
50
|
+
citation.cellRange ? `range ${citation.cellRange}` : null,
|
|
51
|
+
(_d = citation.artifactType) !== null && _d !== void 0 ? _d : null,
|
|
52
|
+
].filter(Boolean).join(" | ");
|
|
53
|
+
lines.push(`[${index + 1}] score=${hit.score.toFixed(3)} source=${source}`, createSnippet(hit.content || citation.snippet, maxCharacters), `citation=${JSON.stringify(citation)}`);
|
|
54
|
+
}
|
|
55
|
+
if (response.hits.length > maxHits) {
|
|
56
|
+
lines.push(`Additional hits omitted: ${response.hits.length - maxHits}`);
|
|
57
|
+
}
|
|
58
|
+
return lines.join("\n");
|
|
59
|
+
}
|
|
60
|
+
function buildSystemBlock(response, options = {}) {
|
|
61
|
+
var _a;
|
|
62
|
+
if (response.hits.length === 0) {
|
|
63
|
+
return [
|
|
64
|
+
"<CloudKnowledgeBaseContext>",
|
|
65
|
+
(_a = options.emptyStateMessage) !== null && _a !== void 0 ? _a : `No relevant cloud knowledge base hits were found for query "${response.query}".`,
|
|
66
|
+
"</CloudKnowledgeBaseContext>",
|
|
67
|
+
].join("\n");
|
|
68
|
+
}
|
|
69
|
+
return [
|
|
70
|
+
"<CloudKnowledgeBaseContext>",
|
|
71
|
+
`Pipeline: ${response.pipelineId}`,
|
|
72
|
+
`Query: ${response.query}`,
|
|
73
|
+
createModelSummary(response, {
|
|
74
|
+
maxHits: options.maxHits,
|
|
75
|
+
maxCharacters: options.maxCharacters,
|
|
76
|
+
}),
|
|
77
|
+
"Use these results as authoritative managed knowledge base context and cite matching sources when answering.",
|
|
78
|
+
"</CloudKnowledgeBaseContext>",
|
|
79
|
+
].join("\n");
|
|
80
|
+
}
|
|
81
|
+
function createDocumentsClient(options) {
|
|
82
|
+
if (options.client) {
|
|
83
|
+
return options.client;
|
|
84
|
+
}
|
|
85
|
+
if (!options.baseUrl) {
|
|
86
|
+
throw new Error("Cloud knowledge base backend configuration is missing. Provide a documents client or a baseUrl.");
|
|
87
|
+
}
|
|
88
|
+
return new documents_1.KognitiveDocumentsClient({
|
|
89
|
+
baseUrl: options.baseUrl,
|
|
90
|
+
apiKey: options.apiKey,
|
|
91
|
+
fetch: options.fetch,
|
|
92
|
+
timeout: options.timeout,
|
|
93
|
+
logLevel: options.logLevel,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function resolveClientOptions(options, inherited) {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
if (options.client) {
|
|
99
|
+
return options;
|
|
100
|
+
}
|
|
101
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : inherited === null || inherited === void 0 ? void 0 : inherited.baseUrl;
|
|
102
|
+
if (!baseUrl) {
|
|
103
|
+
throw new Error("Cloud knowledge base backend configuration is missing. Provide a documents client or a baseUrl, or inherit them from the host agent/workflow.");
|
|
104
|
+
}
|
|
105
|
+
return Object.assign(Object.assign({}, options), { baseUrl, apiKey: (_b = options.apiKey) !== null && _b !== void 0 ? _b : inherited === null || inherited === void 0 ? void 0 : inherited.apiKey });
|
|
106
|
+
}
|
|
107
|
+
async function resolveSearchConfig(options, input) {
|
|
108
|
+
const hasPipelineId = typeof options.pipelineId === "string" && options.pipelineId.trim().length > 0;
|
|
109
|
+
const hasResolver = typeof options.resolvePipelineId === "function";
|
|
110
|
+
if (hasPipelineId === hasResolver) {
|
|
111
|
+
throw new Error("Configure exactly one of pipelineId or resolvePipelineId for the cloud knowledge base.");
|
|
112
|
+
}
|
|
113
|
+
const pipelineId = hasPipelineId
|
|
114
|
+
? options.pipelineId.trim()
|
|
115
|
+
: await options.resolvePipelineId({
|
|
116
|
+
resourceId: input.resourceId,
|
|
117
|
+
messages: input.messages,
|
|
118
|
+
metadata: input.metadata,
|
|
119
|
+
abortSignal: input.abortSignal,
|
|
120
|
+
apiKey: input.apiKey,
|
|
121
|
+
baseUrl: input.baseUrl,
|
|
122
|
+
});
|
|
123
|
+
if (typeof pipelineId !== "string" || pipelineId.trim().length === 0) {
|
|
124
|
+
throw new Error("Cloud knowledge base pipeline resolution returned an empty pipeline id.");
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
client: createDocumentsClient(resolveClientOptions(options, input)),
|
|
128
|
+
pipelineId: pipelineId.trim(),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function normalizeSearchResult(result, snippetMaxLength = 240) {
|
|
132
|
+
var _a, _b, _c, _d;
|
|
133
|
+
const metadata = isRecord(result.metadata) ? result.metadata : undefined;
|
|
134
|
+
const content = (_a = normalizeText(result.content)) !== null && _a !== void 0 ? _a : "";
|
|
135
|
+
const citation = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sourceId: result.id, snippet: (_b = normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.snippet)) !== null && _b !== void 0 ? _b : createSnippet(content, snippetMaxLength) }, (normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.filename) ? { filename: normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.filename) } : {})), (normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.mimeType) ? { mimeType: normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.mimeType) } : {})), (normalizeNumber(metadata === null || metadata === void 0 ? void 0 : metadata.pageNumber) !== undefined ? { pageNumber: normalizeNumber(metadata === null || metadata === void 0 ? void 0 : metadata.pageNumber) } : {})), (normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.artifactType) || normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.blockType) || normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.kind)
|
|
136
|
+
? { artifactType: (_d = (_c = normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.artifactType)) !== null && _c !== void 0 ? _c : normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.blockType)) !== null && _d !== void 0 ? _d : normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.kind) }
|
|
137
|
+
: {})), (normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.parseDocumentId) ? { parseDocumentId: normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.parseDocumentId) } : {})), (normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.sectionTitle) ? { sectionTitle: normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.sectionTitle) } : {})), (normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.sheetName) ? { sheetName: normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.sheetName) } : {})), (normalizeNumber(metadata === null || metadata === void 0 ? void 0 : metadata.rowNumber) !== undefined ? { rowNumber: normalizeNumber(metadata === null || metadata === void 0 ? void 0 : metadata.rowNumber) } : {})), (normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.cellRange) ? { cellRange: normalizeText(metadata === null || metadata === void 0 ? void 0 : metadata.cellRange) } : {}));
|
|
138
|
+
return Object.assign({ sourceId: result.id, content, score: typeof result.score === "number" ? result.score : 0, citation }, (metadata ? { metadata } : {}));
|
|
139
|
+
}
|
|
140
|
+
function extractLastUserText(messages) {
|
|
141
|
+
if (!Array.isArray(messages))
|
|
142
|
+
return "";
|
|
143
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
144
|
+
const message = messages[index];
|
|
145
|
+
if (!isRecord(message) || message.role !== "user")
|
|
146
|
+
continue;
|
|
147
|
+
const parts = Array.isArray(message.parts)
|
|
148
|
+
? message.parts
|
|
149
|
+
: Array.isArray(message.content)
|
|
150
|
+
? message.content
|
|
151
|
+
: [message.content];
|
|
152
|
+
const text = parts
|
|
153
|
+
.map((part) => {
|
|
154
|
+
if (typeof part === "string")
|
|
155
|
+
return part;
|
|
156
|
+
if (isRecord(part) && typeof part.text === "string")
|
|
157
|
+
return part.text;
|
|
158
|
+
return "";
|
|
159
|
+
})
|
|
160
|
+
.join("\n")
|
|
161
|
+
.trim();
|
|
162
|
+
if (text) {
|
|
163
|
+
return text;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return "";
|
|
167
|
+
}
|
package/dist/tool.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Tool } from "@kognitivedev/tools";
|
|
3
|
+
import type { CloudKnowledgeBaseSearchResponse, CloudKnowledgeBaseSearchToolOptions } from "./types";
|
|
4
|
+
declare const SearchInputSchema: z.ZodObject<{
|
|
5
|
+
query: z.ZodString;
|
|
6
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
retrievalMode: z.ZodOptional<z.ZodEnum<["chunks", "files_via_metadata", "files_via_content", "auto_routed"]>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
query: string;
|
|
10
|
+
topK?: number | undefined;
|
|
11
|
+
retrievalMode?: "chunks" | "files_via_metadata" | "files_via_content" | "auto_routed" | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
query: string;
|
|
14
|
+
topK?: number | undefined;
|
|
15
|
+
retrievalMode?: "chunks" | "files_via_metadata" | "files_via_content" | "auto_routed" | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function createCloudKnowledgeBaseSearchTool(options: CloudKnowledgeBaseSearchToolOptions): Tool<z.infer<typeof SearchInputSchema>, CloudKnowledgeBaseSearchResponse>;
|
|
18
|
+
export {};
|
package/dist/tool.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCloudKnowledgeBaseSearchTool = createCloudKnowledgeBaseSearchTool;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const tools_1 = require("@kognitivedev/tools");
|
|
6
|
+
const search_1 = require("./search");
|
|
7
|
+
const shared_1 = require("./shared");
|
|
8
|
+
const SearchInputSchema = zod_1.z.object({
|
|
9
|
+
query: zod_1.z.string().min(1).describe("Natural-language query to run against the managed cloud knowledge base."),
|
|
10
|
+
topK: zod_1.z.number().int().min(1).max(50).optional().describe("Maximum number of results to return."),
|
|
11
|
+
retrievalMode: zod_1.z.enum(["chunks", "files_via_metadata", "files_via_content", "auto_routed"]).optional()
|
|
12
|
+
.describe("Pipeline retrieval mode override."),
|
|
13
|
+
});
|
|
14
|
+
const CitationSchema = zod_1.z.object({
|
|
15
|
+
sourceId: zod_1.z.string(),
|
|
16
|
+
snippet: zod_1.z.string(),
|
|
17
|
+
filename: zod_1.z.string().optional(),
|
|
18
|
+
mimeType: zod_1.z.string().optional(),
|
|
19
|
+
pageNumber: zod_1.z.number().optional(),
|
|
20
|
+
artifactType: zod_1.z.string().optional(),
|
|
21
|
+
parseDocumentId: zod_1.z.string().optional(),
|
|
22
|
+
sectionTitle: zod_1.z.string().optional(),
|
|
23
|
+
sheetName: zod_1.z.string().optional(),
|
|
24
|
+
rowNumber: zod_1.z.number().optional(),
|
|
25
|
+
cellRange: zod_1.z.string().optional(),
|
|
26
|
+
});
|
|
27
|
+
const HitSchema = zod_1.z.object({
|
|
28
|
+
sourceId: zod_1.z.string(),
|
|
29
|
+
content: zod_1.z.string(),
|
|
30
|
+
score: zod_1.z.number(),
|
|
31
|
+
citation: CitationSchema,
|
|
32
|
+
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
33
|
+
});
|
|
34
|
+
const SearchOutputSchema = zod_1.z.object({
|
|
35
|
+
pipelineId: zod_1.z.string(),
|
|
36
|
+
query: zod_1.z.string(),
|
|
37
|
+
hits: zod_1.z.array(HitSchema),
|
|
38
|
+
citations: zod_1.z.array(CitationSchema),
|
|
39
|
+
});
|
|
40
|
+
function createCloudKnowledgeBaseSearchTool(options) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
return (0, tools_1.createTool)({
|
|
43
|
+
id: (_a = options.id) !== null && _a !== void 0 ? _a : "search-cloud-knowledge-base",
|
|
44
|
+
description: (_b = options.description) !== null && _b !== void 0 ? _b : "Search a managed cloud knowledge base pipeline and return normalized hits with enterprise-grade citations.",
|
|
45
|
+
inputSchema: SearchInputSchema,
|
|
46
|
+
outputSchema: SearchOutputSchema,
|
|
47
|
+
execute: async (input, context) => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
return (0, search_1.searchCloudKnowledgeBase)(Object.assign(Object.assign({}, options), { query: input.query, topK: (_a = input.topK) !== null && _a !== void 0 ? _a : options.topK, retrievalMode: (_b = input.retrievalMode) !== null && _b !== void 0 ? _b : options.retrievalMode, resourceId: context.resourceId, metadata: context.metadata, abortSignal: context.abortSignal }));
|
|
50
|
+
},
|
|
51
|
+
toModelOutput: (output) => (0, shared_1.createModelSummary)(output, {
|
|
52
|
+
maxHits: options.modelSummaryMaxHits,
|
|
53
|
+
maxCharacters: options.modelSummaryMaxCharacters,
|
|
54
|
+
}),
|
|
55
|
+
});
|
|
56
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { AgentContextAdapter } from "@kognitivedev/agents";
|
|
2
|
+
import type { DocumentsClientConfig, KognitiveDocumentsClient, LogLevel, PipelineRetrievalMode } from "@kognitivedev/documents";
|
|
3
|
+
import type { KognitiveMessage, Metadata, ResourceId } from "@kognitivedev/shared";
|
|
4
|
+
import type { KnowledgeBaseAnswer, KnowledgeBaseCitation, KnowledgeBaseHit, KnowledgeBaseSearchResponse } from "@kognitivedev/workflows";
|
|
5
|
+
export type CloudKnowledgeBaseCitation = KnowledgeBaseCitation;
|
|
6
|
+
export type CloudKnowledgeBaseHit = KnowledgeBaseHit;
|
|
7
|
+
export type CloudKnowledgeBaseSearchResponse = KnowledgeBaseSearchResponse;
|
|
8
|
+
export type CloudKnowledgeBaseAnswer = KnowledgeBaseAnswer;
|
|
9
|
+
export interface CloudKnowledgeBaseResolverInput {
|
|
10
|
+
resourceId: ResourceId;
|
|
11
|
+
messages?: KognitiveMessage[];
|
|
12
|
+
metadata?: Metadata;
|
|
13
|
+
abortSignal?: AbortSignal;
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CloudKnowledgeBaseClientOptions {
|
|
18
|
+
client?: KognitiveDocumentsClient;
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
fetch?: DocumentsClientConfig["fetch"];
|
|
22
|
+
timeout?: number;
|
|
23
|
+
logLevel?: LogLevel;
|
|
24
|
+
}
|
|
25
|
+
export interface CloudKnowledgeBasePipelineOptions {
|
|
26
|
+
pipelineId?: string;
|
|
27
|
+
resolvePipelineId?: (input: CloudKnowledgeBaseResolverInput) => Promise<string> | string;
|
|
28
|
+
}
|
|
29
|
+
export interface CloudKnowledgeBaseSearchOptions extends CloudKnowledgeBaseClientOptions, CloudKnowledgeBasePipelineOptions {
|
|
30
|
+
query: string;
|
|
31
|
+
topK?: number;
|
|
32
|
+
retrievalMode?: PipelineRetrievalMode;
|
|
33
|
+
resourceId: ResourceId;
|
|
34
|
+
messages?: KognitiveMessage[];
|
|
35
|
+
metadata?: Metadata;
|
|
36
|
+
abortSignal?: AbortSignal;
|
|
37
|
+
snippetMaxLength?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface CloudKnowledgeBaseSearchToolOptions extends CloudKnowledgeBaseClientOptions, CloudKnowledgeBasePipelineOptions {
|
|
40
|
+
id?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
topK?: number;
|
|
43
|
+
retrievalMode?: PipelineRetrievalMode;
|
|
44
|
+
snippetMaxLength?: number;
|
|
45
|
+
modelSummaryMaxHits?: number;
|
|
46
|
+
modelSummaryMaxCharacters?: number;
|
|
47
|
+
}
|
|
48
|
+
export interface CloudKnowledgeBaseContextAdapterOptions extends CloudKnowledgeBaseClientOptions, CloudKnowledgeBasePipelineOptions {
|
|
49
|
+
topK?: number;
|
|
50
|
+
retrievalMode?: PipelineRetrievalMode;
|
|
51
|
+
snippetMaxLength?: number;
|
|
52
|
+
maxContextHits?: number;
|
|
53
|
+
maxContextCharacters?: number;
|
|
54
|
+
autoRegisterSearchTool?: boolean;
|
|
55
|
+
searchTool?: CloudKnowledgeBaseSearchToolOptions;
|
|
56
|
+
buildQuery?: (input: CloudKnowledgeBaseResolverInput) => Promise<string> | string;
|
|
57
|
+
emptyStateMessage?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface CloudKnowledgeBaseSearchStepOptions<TInput, TOutput = CloudKnowledgeBaseSearchResponse> extends CloudKnowledgeBaseClientOptions, CloudKnowledgeBasePipelineOptions {
|
|
60
|
+
id: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
getQuery: (input: TInput, context: {
|
|
63
|
+
resourceId: ResourceId;
|
|
64
|
+
abortSignal: AbortSignal;
|
|
65
|
+
}) => Promise<string> | string;
|
|
66
|
+
topK?: number | ((input: TInput, context: {
|
|
67
|
+
resourceId: ResourceId;
|
|
68
|
+
abortSignal: AbortSignal;
|
|
69
|
+
}) => Promise<number | undefined> | number | undefined);
|
|
70
|
+
retrievalMode?: PipelineRetrievalMode | ((input: TInput, context: {
|
|
71
|
+
resourceId: ResourceId;
|
|
72
|
+
abortSignal: AbortSignal;
|
|
73
|
+
}) => Promise<PipelineRetrievalMode | undefined> | PipelineRetrievalMode | undefined);
|
|
74
|
+
snippetMaxLength?: number;
|
|
75
|
+
extractOutput?: (result: CloudKnowledgeBaseSearchResponse) => TOutput;
|
|
76
|
+
}
|
|
77
|
+
export interface CloudKnowledgeBaseAnswerStepOptions<TInput, TOutput = CloudKnowledgeBaseAnswer> extends CloudKnowledgeBaseClientOptions, CloudKnowledgeBasePipelineOptions {
|
|
78
|
+
id: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
agent: {
|
|
81
|
+
generateObject(options: {
|
|
82
|
+
messages: any[];
|
|
83
|
+
resourceId: ResourceId;
|
|
84
|
+
abortSignal?: AbortSignal;
|
|
85
|
+
structuredOutput: any;
|
|
86
|
+
temperature?: number;
|
|
87
|
+
maxOutputTokens?: number;
|
|
88
|
+
}): Promise<any>;
|
|
89
|
+
};
|
|
90
|
+
getQuery: (input: TInput, context: {
|
|
91
|
+
resourceId: ResourceId;
|
|
92
|
+
abortSignal: AbortSignal;
|
|
93
|
+
}) => Promise<string> | string;
|
|
94
|
+
topK?: number | ((input: TInput, context: {
|
|
95
|
+
resourceId: ResourceId;
|
|
96
|
+
abortSignal: AbortSignal;
|
|
97
|
+
}) => Promise<number | undefined> | number | undefined);
|
|
98
|
+
retrievalMode?: PipelineRetrievalMode | ((input: TInput, context: {
|
|
99
|
+
resourceId: ResourceId;
|
|
100
|
+
abortSignal: AbortSignal;
|
|
101
|
+
}) => Promise<PipelineRetrievalMode | undefined> | PipelineRetrievalMode | undefined);
|
|
102
|
+
snippetMaxLength?: number;
|
|
103
|
+
buildMessages?: (input: TInput, search: CloudKnowledgeBaseSearchResponse) => any[];
|
|
104
|
+
temperature?: number;
|
|
105
|
+
maxOutputTokens?: number;
|
|
106
|
+
emptyResultAnswer?: string;
|
|
107
|
+
extractOutput?: (result: {
|
|
108
|
+
answer: CloudKnowledgeBaseAnswer;
|
|
109
|
+
search: CloudKnowledgeBaseSearchResponse;
|
|
110
|
+
agentResult?: any;
|
|
111
|
+
}) => TOutput;
|
|
112
|
+
}
|
|
113
|
+
export interface ResolvedCloudKnowledgeBaseSearchConfig {
|
|
114
|
+
client: KognitiveDocumentsClient;
|
|
115
|
+
pipelineId: string;
|
|
116
|
+
}
|
|
117
|
+
export interface CloudKnowledgeBaseContextAdapter extends AgentContextAdapter {
|
|
118
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type StepDefinition } from "@kognitivedev/workflows";
|
|
2
|
+
import type { CloudKnowledgeBaseAnswer, CloudKnowledgeBaseAnswerStepOptions, CloudKnowledgeBaseSearchResponse, CloudKnowledgeBaseSearchStepOptions } from "./types";
|
|
3
|
+
export declare function createCloudKnowledgeBaseSearchStep<TInput, TOutput = CloudKnowledgeBaseSearchResponse>(options: CloudKnowledgeBaseSearchStepOptions<TInput, TOutput>): StepDefinition<TInput, TOutput>;
|
|
4
|
+
export declare function createCloudKnowledgeBaseAnswerStep<TInput, TOutput = CloudKnowledgeBaseAnswer>(options: CloudKnowledgeBaseAnswerStepOptions<TInput, TOutput>): StepDefinition<TInput, TOutput>;
|