@stackfactor/agent-utils 1.12.0 → 1.13.1
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/README.md +3 -1
- package/dist/cjs/langChain.d.ts.map +1 -1
- package/dist/cjs/langChain.js +31 -2
- package/dist/cjs/referenceContext.d.ts +1 -0
- package/dist/cjs/referenceContext.d.ts.map +1 -1
- package/dist/cjs/stackfactorKnowledge.d.ts +9 -1
- package/dist/cjs/stackfactorKnowledge.d.ts.map +1 -1
- package/dist/cjs/stackfactorKnowledge.js +11 -3
- package/dist/esm/langChain.d.ts.map +1 -1
- package/dist/esm/langChain.js +31 -2
- package/dist/esm/referenceContext.d.ts +1 -0
- package/dist/esm/referenceContext.d.ts.map +1 -1
- package/dist/esm/stackfactorKnowledge.d.ts +9 -1
- package/dist/esm/stackfactorKnowledge.d.ts.map +1 -1
- package/dist/esm/stackfactorKnowledge.js +11 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,7 +103,9 @@ Constructs a LangChain agent with a model, system prompt, and tools. When `onRep
|
|
|
103
103
|
|
|
104
104
|
### `langChain.runAIAgent(agent, prompt, config, onProgress?)`
|
|
105
105
|
|
|
106
|
-
Executes a LangChain agent with a user prompt. Registers callbacks for `tool_start`, `
|
|
106
|
+
Executes a LangChain agent with a user prompt. Registers callbacks for `tool_start`, `agent_action`, and error events when `onProgress` is provided. Logs execution time on completion.
|
|
107
|
+
|
|
108
|
+
A tool event's `message` is plain language for the progress bar: the web tools read "Searching the web", "Reading web pages", "Listing the pages of a site" and "Reading the pages of a site", and any other tool reads as its name in words (`lookup_record` → "Using lookup record"). It never carries the model's reasoning or the tool's input; the raw name and input stay on the event's `tool` and `input`.
|
|
107
109
|
|
|
108
110
|
| Parameter | Type | Default | Description |
|
|
109
111
|
| ------------ | ------------------ | ------- | -------------------------------- |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../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,SAAS,aAC7B,MAAM,kBACD,MAAM,YACZ,GAAG,KACZ,IAAI;uCAoBI,YAAY,GAAG,IAAI,GAAG,SAAS,aAC7B,MAAM,WACR,MAAM,YACL,GAAG,KACZ,IAAI;mCAuwBU,MAAM,mBACJ,MAAM,EAAE,KACxB,MAAM;;AA48CT,wBAkBE"}
|
package/dist/cjs/langChain.js
CHANGED
|
@@ -765,10 +765,36 @@ const createAgent = (name, modelName, systemPrompt, tools = [], responseFormat,
|
|
|
765
765
|
});
|
|
766
766
|
return agent;
|
|
767
767
|
};
|
|
768
|
+
// What the progress bar says while each tool agent-utils registers (the
|
|
769
|
+
// Tavily tools in tavily.ts) runs. A Map, so a tool named after an
|
|
770
|
+
// Object.prototype key ("constructor") is not mistaken for a label.
|
|
771
|
+
const TOOL_PROGRESS_LABELS = new Map([
|
|
772
|
+
["web_search", "Searching the web"],
|
|
773
|
+
["web_extract", "Reading web pages"],
|
|
774
|
+
["web_map", "Listing the pages of a site"],
|
|
775
|
+
["web_crawl", "Reading the pages of a site"],
|
|
776
|
+
]);
|
|
777
|
+
/**
|
|
778
|
+
* The progress message for a tool call, in words the person watching the run
|
|
779
|
+
* can read. A tool without a label (an agent's own) reads as its name with
|
|
780
|
+
* underscores as spaces: `lookup_record` → "Using lookup record".
|
|
781
|
+
* @param name - The tool's registered name
|
|
782
|
+
* @returns A plain-language message; never the raw name in quotes
|
|
783
|
+
*/
|
|
784
|
+
const toolProgressLabel = (name) => {
|
|
785
|
+
const text = String(name ?? "");
|
|
786
|
+
const label = TOOL_PROGRESS_LABELS.get(text);
|
|
787
|
+
if (label)
|
|
788
|
+
return label;
|
|
789
|
+
const words = text.replace(/_+/g, " ").trim();
|
|
790
|
+
return words ? `Using ${words}` : "Using a tool";
|
|
791
|
+
};
|
|
768
792
|
/**
|
|
769
793
|
* Executes a LangChain agent with a single user prompt and returns the raw agent
|
|
770
794
|
* response. When an `onProgress` callback is provided, LangChain callbacks are
|
|
771
795
|
* registered to forward `tool_start`, `agent_action`, and error events to the caller.
|
|
796
|
+
* A tool event's `message` is plain language (see `toolProgressLabel`); the raw tool
|
|
797
|
+
* name and input stay on its `tool` and `input` fields.
|
|
772
798
|
* Execution time is logged at the info level on completion.
|
|
773
799
|
* @param agent - A LangChain agent instance created by `createAgent`
|
|
774
800
|
* @param prompt - The user message string to send to the agent
|
|
@@ -798,15 +824,18 @@ const runAgent = async (agent, prompt, config, onProgress = null, usageTracker =
|
|
|
798
824
|
if (name)
|
|
799
825
|
onProgress({
|
|
800
826
|
type: "tool_start",
|
|
801
|
-
message:
|
|
827
|
+
message: toolProgressLabel(name),
|
|
802
828
|
tool: name,
|
|
803
829
|
progress,
|
|
804
830
|
});
|
|
805
831
|
},
|
|
832
|
+
// `action.log` is the model's own text (LangChain's default reads
|
|
833
|
+
// "Invoking: `web_extract` with `{...}`", the raw tool input), so it
|
|
834
|
+
// never reaches the progress bar.
|
|
806
835
|
handleAgentAction: (action) => {
|
|
807
836
|
onProgress({
|
|
808
837
|
type: "agent_action",
|
|
809
|
-
message: action.
|
|
838
|
+
message: toolProgressLabel(action.tool),
|
|
810
839
|
tool: action.tool,
|
|
811
840
|
input: action.toolInput,
|
|
812
841
|
progress,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"referenceContext.d.ts","sourceRoot":"","sources":["../../src/referenceContext.ts"],"names":[],"mappings":"AAuBA,OAAO,EACL,eAAe,EACf,aAAa,EAId,MAAM,2BAA2B,CAAC;AAQnC,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAEhE,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,GA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Q,CAAC,EAAE,MAAM,CAAC;KACnB,KAAG,OAAO,CAAC,gBAAgB,CAAC;wBA2JK,CAAC,SAAS;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,aAAa,CAAC,KAAG,CAAC;0CAjFpE,gBAAgB,KACxB;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE;qCAqG7C,OAAO,KAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;iCAoF5C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,cAAc;mCAjDtC,GAAG,WAAU,MAAM,KAAoB,eAAe;wBA3FjE,gBAAgB,KAAG;QAAE,MAAM,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YAAC,WAAW,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE;;AAkJ5G,wBAYE"}
|
|
@@ -17,6 +17,8 @@ export interface KnowledgeChunk {
|
|
|
17
17
|
knowledgeBaseId?: string;
|
|
18
18
|
documentId: string;
|
|
19
19
|
documentName?: string | null;
|
|
20
|
+
/** The title taken from the document itself (its front matter or first heading); null when it has none. */
|
|
21
|
+
documentTitle?: string | null;
|
|
20
22
|
/** The document's page at its source (sent by the platform's search since backend-core #630). */
|
|
21
23
|
documentUrl?: string | null;
|
|
22
24
|
sectionTitle?: string | null;
|
|
@@ -50,6 +52,8 @@ export interface GroundingPassage {
|
|
|
50
52
|
knowledgeBaseId: string;
|
|
51
53
|
documentId: string;
|
|
52
54
|
documentName: string | null;
|
|
55
|
+
/** The title taken from the document itself; null when it has none. */
|
|
56
|
+
documentTitle?: string | null;
|
|
53
57
|
/** The document's page at its source, an http(s) address; null when the platform has none. */
|
|
54
58
|
documentUrl?: string | null;
|
|
55
59
|
sectionTitle: string | null;
|
|
@@ -89,6 +93,8 @@ export interface StackFactorReference {
|
|
|
89
93
|
knowledgeBase: {
|
|
90
94
|
knowledgeBaseId: string;
|
|
91
95
|
documentId: string;
|
|
96
|
+
/** The document's name at its source (GitHub: `<repo>/<path>`); absent when the passage has none. */
|
|
97
|
+
documentName?: string;
|
|
92
98
|
chunkId: string;
|
|
93
99
|
sectionTitle: string | null;
|
|
94
100
|
};
|
|
@@ -154,7 +160,9 @@ export declare const passagesForPrompt: (passages: GroundingPassage[]) => {
|
|
|
154
160
|
* STACKFACTOR references for passages: one per passage, in their order, with no
|
|
155
161
|
* cap. With `tags`, only the passages the model cited by tag (any tag it made
|
|
156
162
|
* up is passed over); without, every passage. Each links to its document's
|
|
157
|
-
* page at the source (`url`) when the passage has one.
|
|
163
|
+
* page at the source (`url`) when the passage has one. Each is titled by its
|
|
164
|
+
* document's title, else its name, else its section; its pointer keeps the
|
|
165
|
+
* document's name (`knowledgeBase.documentName`) when the passage has one.
|
|
158
166
|
* @param passages From `retrievePassages`
|
|
159
167
|
* @param tags The tags the model cited ("k3", "K3" and " k3 " alike)
|
|
160
168
|
* @returns The references, ready for a skill's, a microskill's or a question's `references`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stackfactorKnowledge.d.ts","sourceRoot":"","sources":["../../src/stackfactorKnowledge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stackfactorKnowledge.d.ts","sourceRoot":"","sources":["../../src/stackfactorKnowledge.ts"],"names":[],"mappings":"AAsCA,kGAAkG;AAClG,eAAO,MAAM,qBAAqB;;;;;EAKhC,CAAC;AAEH,0FAA0F;AAC1F,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,0EAA0E;AAC1E,eAAO,MAAM,aAAa,IAAI,CAAC;AAW/B,iFAAiF;AACjF,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CA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OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,MAAM,EAAE,eAAe,CAAC;QACxB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,KAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;QAAC,OAAO,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;oCAjEzB,OAAO,KAAG,eAAe,EAAE;wCA5BvB,OAAO,KAAG,eAAe,EAAE;;AAwP7E,wBAUE"}
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
// A reference points at the content and never copies it: the passage is
|
|
25
25
|
// searched again, under the reader's own access, whenever it is used. Its
|
|
26
26
|
// `url` is the document's page at its source (GitHub, Confluence…), when the
|
|
27
|
-
// platform knows it, so a person can open what was cited.
|
|
27
|
+
// platform knows it, so a person can open what was cited. Its title is the
|
|
28
|
+
// title taken from the document itself, when ingestion found one, and its
|
|
29
|
+
// pointer keeps the document's name at the source (`documentName`), so a
|
|
30
|
+
// person can still see where the titled document lives. It is
|
|
28
31
|
// EDIT-only (`visibility: "EDIT"`): the platform strips it from what is
|
|
29
32
|
// published, so a knowledge base's titles never reach a learner; agents read
|
|
30
33
|
// it from the draft.
|
|
@@ -228,6 +231,7 @@ const retrievePassages = async (options) => {
|
|
|
228
231
|
chunkId,
|
|
229
232
|
documentId: id(chunk.documentId),
|
|
230
233
|
documentName: text(chunk.documentName) || null,
|
|
234
|
+
documentTitle: text(chunk.documentTitle) || null,
|
|
231
235
|
documentUrl: webUrl(chunk.documentUrl),
|
|
232
236
|
knowledgeBaseId: id(chunk.knowledgeBaseId) || knowledgeBaseId,
|
|
233
237
|
pageNumber: typeof chunk.pageNumber === "number" ? chunk.pageNumber : null,
|
|
@@ -259,7 +263,9 @@ exports.passagesForPrompt = passagesForPrompt;
|
|
|
259
263
|
* STACKFACTOR references for passages: one per passage, in their order, with no
|
|
260
264
|
* cap. With `tags`, only the passages the model cited by tag (any tag it made
|
|
261
265
|
* up is passed over); without, every passage. Each links to its document's
|
|
262
|
-
* page at the source (`url`) when the passage has one.
|
|
266
|
+
* page at the source (`url`) when the passage has one. Each is titled by its
|
|
267
|
+
* document's title, else its name, else its section; its pointer keeps the
|
|
268
|
+
* document's name (`knowledgeBase.documentName`) when the passage has one.
|
|
263
269
|
* @param passages From `retrievePassages`
|
|
264
270
|
* @param tags The tags the model cited ("k3", "K3" and " k3 " alike)
|
|
265
271
|
* @returns The references, ready for a skill's, a microskill's or a question's `references`
|
|
@@ -273,12 +279,14 @@ const referencesFor = (passages, tags) => {
|
|
|
273
279
|
.filter((passage) => !cited || cited.has(passage.tag.toLowerCase()))
|
|
274
280
|
.map((passage) => {
|
|
275
281
|
const url = webUrl(passage.documentUrl);
|
|
282
|
+
const documentName = text(passage.documentName);
|
|
276
283
|
return {
|
|
277
284
|
description: passage.sectionTitle,
|
|
278
285
|
kind: exports.STACKFACTOR_REFERENCE.KIND,
|
|
279
286
|
knowledgeBase: {
|
|
280
287
|
chunkId: passage.chunkId,
|
|
281
288
|
documentId: passage.documentId,
|
|
289
|
+
...(documentName ? { documentName } : {}),
|
|
282
290
|
knowledgeBaseId: passage.knowledgeBaseId,
|
|
283
291
|
sectionTitle: passage.sectionTitle,
|
|
284
292
|
},
|
|
@@ -288,7 +296,7 @@ const referencesFor = (passages, tags) => {
|
|
|
288
296
|
elementType: exports.STACKFACTOR_REFERENCE.TARGET_ELEMENT_TYPE,
|
|
289
297
|
parentId: passage.knowledgeBaseId,
|
|
290
298
|
},
|
|
291
|
-
title: passage.documentName || passage.sectionTitle || "Knowledge base document",
|
|
299
|
+
title: text(passage.documentTitle) || documentName || passage.sectionTitle || "Knowledge base document",
|
|
292
300
|
...(url ? { url } : {}),
|
|
293
301
|
visibility: exports.STACKFACTOR_REFERENCE.VISIBILITY,
|
|
294
302
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],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M,kBACD,MAAM,YACZ,GAAG,KACZ,IAAI;uCAoBI,YAAY,GAAG,IAAI,GAAG,SAAS,aAC7B,MAAM,WACR,MAAM,YACL,GAAG,KACZ,IAAI;mCAuwBU,MAAM,mBACJ,MAAM,EAAE,KACxB,MAAM;;AA48CT,wBAkBE"}
|
package/dist/esm/langChain.js
CHANGED
|
@@ -758,10 +758,36 @@ const createAgent = (name, modelName, systemPrompt, tools = [], responseFormat,
|
|
|
758
758
|
});
|
|
759
759
|
return agent;
|
|
760
760
|
};
|
|
761
|
+
// What the progress bar says while each tool agent-utils registers (the
|
|
762
|
+
// Tavily tools in tavily.ts) runs. A Map, so a tool named after an
|
|
763
|
+
// Object.prototype key ("constructor") is not mistaken for a label.
|
|
764
|
+
const TOOL_PROGRESS_LABELS = new Map([
|
|
765
|
+
["web_search", "Searching the web"],
|
|
766
|
+
["web_extract", "Reading web pages"],
|
|
767
|
+
["web_map", "Listing the pages of a site"],
|
|
768
|
+
["web_crawl", "Reading the pages of a site"],
|
|
769
|
+
]);
|
|
770
|
+
/**
|
|
771
|
+
* The progress message for a tool call, in words the person watching the run
|
|
772
|
+
* can read. A tool without a label (an agent's own) reads as its name with
|
|
773
|
+
* underscores as spaces: `lookup_record` → "Using lookup record".
|
|
774
|
+
* @param name - The tool's registered name
|
|
775
|
+
* @returns A plain-language message; never the raw name in quotes
|
|
776
|
+
*/
|
|
777
|
+
const toolProgressLabel = (name) => {
|
|
778
|
+
const text = String(name ?? "");
|
|
779
|
+
const label = TOOL_PROGRESS_LABELS.get(text);
|
|
780
|
+
if (label)
|
|
781
|
+
return label;
|
|
782
|
+
const words = text.replace(/_+/g, " ").trim();
|
|
783
|
+
return words ? `Using ${words}` : "Using a tool";
|
|
784
|
+
};
|
|
761
785
|
/**
|
|
762
786
|
* Executes a LangChain agent with a single user prompt and returns the raw agent
|
|
763
787
|
* response. When an `onProgress` callback is provided, LangChain callbacks are
|
|
764
788
|
* registered to forward `tool_start`, `agent_action`, and error events to the caller.
|
|
789
|
+
* A tool event's `message` is plain language (see `toolProgressLabel`); the raw tool
|
|
790
|
+
* name and input stay on its `tool` and `input` fields.
|
|
765
791
|
* Execution time is logged at the info level on completion.
|
|
766
792
|
* @param agent - A LangChain agent instance created by `createAgent`
|
|
767
793
|
* @param prompt - The user message string to send to the agent
|
|
@@ -791,15 +817,18 @@ const runAgent = async (agent, prompt, config, onProgress = null, usageTracker =
|
|
|
791
817
|
if (name)
|
|
792
818
|
onProgress({
|
|
793
819
|
type: "tool_start",
|
|
794
|
-
message:
|
|
820
|
+
message: toolProgressLabel(name),
|
|
795
821
|
tool: name,
|
|
796
822
|
progress,
|
|
797
823
|
});
|
|
798
824
|
},
|
|
825
|
+
// `action.log` is the model's own text (LangChain's default reads
|
|
826
|
+
// "Invoking: `web_extract` with `{...}`", the raw tool input), so it
|
|
827
|
+
// never reaches the progress bar.
|
|
799
828
|
handleAgentAction: (action) => {
|
|
800
829
|
onProgress({
|
|
801
830
|
type: "agent_action",
|
|
802
|
-
message: action.
|
|
831
|
+
message: toolProgressLabel(action.tool),
|
|
803
832
|
tool: action.tool,
|
|
804
833
|
input: action.toolInput,
|
|
805
834
|
progress,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"referenceContext.d.ts","sourceRoot":"","sources":["../../src/referenceContext.ts"],"names":[],"mappings":"AAuBA,OAAO,EACL,eAAe,EACf,aAAa,EAId,MAAM,2BAA2B,CAAC;AAQnC,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAEhE,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACx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M,CAAC;KACnB,KAAG,OAAO,CAAC,gBAAgB,CAAC;wBA2JK,CAAC,SAAS;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,aAAa,CAAC,KAAG,CAAC;0CAjFpE,gBAAgB,KACxB;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE;qCAqG7C,OAAO,KAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;iCAoF5C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,cAAc;mCAjDtC,GAAG,WAAU,MAAM,KAAoB,eAAe;wBA3FjE,gBAAgB,KAAG;QAAE,MAAM,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YAAC,WAAW,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE;;AAkJ5G,wBAYE"}
|
|
@@ -17,6 +17,8 @@ export interface KnowledgeChunk {
|
|
|
17
17
|
knowledgeBaseId?: string;
|
|
18
18
|
documentId: string;
|
|
19
19
|
documentName?: string | null;
|
|
20
|
+
/** The title taken from the document itself (its front matter or first heading); null when it has none. */
|
|
21
|
+
documentTitle?: string | null;
|
|
20
22
|
/** The document's page at its source (sent by the platform's search since backend-core #630). */
|
|
21
23
|
documentUrl?: string | null;
|
|
22
24
|
sectionTitle?: string | null;
|
|
@@ -50,6 +52,8 @@ export interface GroundingPassage {
|
|
|
50
52
|
knowledgeBaseId: string;
|
|
51
53
|
documentId: string;
|
|
52
54
|
documentName: string | null;
|
|
55
|
+
/** The title taken from the document itself; null when it has none. */
|
|
56
|
+
documentTitle?: string | null;
|
|
53
57
|
/** The document's page at its source, an http(s) address; null when the platform has none. */
|
|
54
58
|
documentUrl?: string | null;
|
|
55
59
|
sectionTitle: string | null;
|
|
@@ -89,6 +93,8 @@ export interface StackFactorReference {
|
|
|
89
93
|
knowledgeBase: {
|
|
90
94
|
knowledgeBaseId: string;
|
|
91
95
|
documentId: string;
|
|
96
|
+
/** The document's name at its source (GitHub: `<repo>/<path>`); absent when the passage has none. */
|
|
97
|
+
documentName?: string;
|
|
92
98
|
chunkId: string;
|
|
93
99
|
sectionTitle: string | null;
|
|
94
100
|
};
|
|
@@ -154,7 +160,9 @@ export declare const passagesForPrompt: (passages: GroundingPassage[]) => {
|
|
|
154
160
|
* STACKFACTOR references for passages: one per passage, in their order, with no
|
|
155
161
|
* cap. With `tags`, only the passages the model cited by tag (any tag it made
|
|
156
162
|
* up is passed over); without, every passage. Each links to its document's
|
|
157
|
-
* page at the source (`url`) when the passage has one.
|
|
163
|
+
* page at the source (`url`) when the passage has one. Each is titled by its
|
|
164
|
+
* document's title, else its name, else its section; its pointer keeps the
|
|
165
|
+
* document's name (`knowledgeBase.documentName`) when the passage has one.
|
|
158
166
|
* @param passages From `retrievePassages`
|
|
159
167
|
* @param tags The tags the model cited ("k3", "K3" and " k3 " alike)
|
|
160
168
|
* @returns The references, ready for a skill's, a microskill's or a question's `references`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stackfactorKnowledge.d.ts","sourceRoot":"","sources":["../../src/stackfactorKnowledge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stackfactorKnowledge.d.ts","sourceRoot":"","sources":["../../src/stackfactorKnowledge.ts"],"names":[],"mappings":"AAsCA,kGAAkG;AAClG,eAAO,MAAM,qBAAqB;;;;;EAKhC,CAAC;AAEH,0FAA0F;AAC1F,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,0EAA0E;AAC1E,eAAO,MAAM,aAAa,IAAI,CAAC;AAW/B,iFAAiF;AACjF,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,CAA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AAE,CAAC;QAClB,MAAM,EAAE,eAAe,CAAC;QACxB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,KAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;QAAC,OAAO,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;oCAjEzB,OAAO,KAAG,eAAe,EAAE;wCA5BvB,OAAO,KAAG,eAAe,EAAE;;AAwP7E,wBAUE"}
|
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
// A reference points at the content and never copies it: the passage is
|
|
24
24
|
// searched again, under the reader's own access, whenever it is used. Its
|
|
25
25
|
// `url` is the document's page at its source (GitHub, Confluence…), when the
|
|
26
|
-
// platform knows it, so a person can open what was cited.
|
|
26
|
+
// platform knows it, so a person can open what was cited. Its title is the
|
|
27
|
+
// title taken from the document itself, when ingestion found one, and its
|
|
28
|
+
// pointer keeps the document's name at the source (`documentName`), so a
|
|
29
|
+
// person can still see where the titled document lives. It is
|
|
27
30
|
// EDIT-only (`visibility: "EDIT"`): the platform strips it from what is
|
|
28
31
|
// published, so a knowledge base's titles never reach a learner; agents read
|
|
29
32
|
// it from the draft.
|
|
@@ -223,6 +226,7 @@ export const retrievePassages = async (options) => {
|
|
|
223
226
|
chunkId,
|
|
224
227
|
documentId: id(chunk.documentId),
|
|
225
228
|
documentName: text(chunk.documentName) || null,
|
|
229
|
+
documentTitle: text(chunk.documentTitle) || null,
|
|
226
230
|
documentUrl: webUrl(chunk.documentUrl),
|
|
227
231
|
knowledgeBaseId: id(chunk.knowledgeBaseId) || knowledgeBaseId,
|
|
228
232
|
pageNumber: typeof chunk.pageNumber === "number" ? chunk.pageNumber : null,
|
|
@@ -252,7 +256,9 @@ export const passagesForPrompt = (passages) => (Array.isArray(passages) ? passag
|
|
|
252
256
|
* STACKFACTOR references for passages: one per passage, in their order, with no
|
|
253
257
|
* cap. With `tags`, only the passages the model cited by tag (any tag it made
|
|
254
258
|
* up is passed over); without, every passage. Each links to its document's
|
|
255
|
-
* page at the source (`url`) when the passage has one.
|
|
259
|
+
* page at the source (`url`) when the passage has one. Each is titled by its
|
|
260
|
+
* document's title, else its name, else its section; its pointer keeps the
|
|
261
|
+
* document's name (`knowledgeBase.documentName`) when the passage has one.
|
|
256
262
|
* @param passages From `retrievePassages`
|
|
257
263
|
* @param tags The tags the model cited ("k3", "K3" and " k3 " alike)
|
|
258
264
|
* @returns The references, ready for a skill's, a microskill's or a question's `references`
|
|
@@ -266,12 +272,14 @@ export const referencesFor = (passages, tags) => {
|
|
|
266
272
|
.filter((passage) => !cited || cited.has(passage.tag.toLowerCase()))
|
|
267
273
|
.map((passage) => {
|
|
268
274
|
const url = webUrl(passage.documentUrl);
|
|
275
|
+
const documentName = text(passage.documentName);
|
|
269
276
|
return {
|
|
270
277
|
description: passage.sectionTitle,
|
|
271
278
|
kind: STACKFACTOR_REFERENCE.KIND,
|
|
272
279
|
knowledgeBase: {
|
|
273
280
|
chunkId: passage.chunkId,
|
|
274
281
|
documentId: passage.documentId,
|
|
282
|
+
...(documentName ? { documentName } : {}),
|
|
275
283
|
knowledgeBaseId: passage.knowledgeBaseId,
|
|
276
284
|
sectionTitle: passage.sectionTitle,
|
|
277
285
|
},
|
|
@@ -281,7 +289,7 @@ export const referencesFor = (passages, tags) => {
|
|
|
281
289
|
elementType: STACKFACTOR_REFERENCE.TARGET_ELEMENT_TYPE,
|
|
282
290
|
parentId: passage.knowledgeBaseId,
|
|
283
291
|
},
|
|
284
|
-
title: passage.documentName || passage.sectionTitle || "Knowledge base document",
|
|
292
|
+
title: text(passage.documentTitle) || documentName || passage.sectionTitle || "Knowledge base document",
|
|
285
293
|
...(url ? { url } : {}),
|
|
286
294
|
visibility: STACKFACTOR_REFERENCE.VISIBILITY,
|
|
287
295
|
};
|