@promptbook/cli 0.61.0-24 → 0.61.0-25
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 -3
- package/esm/index.es.js +81 -46
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/config.d.ts +5 -1
- package/esm/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +2 -0
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/extractParameters.d.ts +3 -0
- package/package.json +2 -2
- package/umd/index.umd.js +81 -46
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/config.d.ts +5 -1
- package/umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +1 -1
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +2 -0
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
- package/umd/typings/src/utils/extractParameters.d.ts +3 -0
package/README.md
CHANGED
|
@@ -146,7 +146,7 @@ File `write-website-content.ptbk.md`:
|
|
|
146
146
|
> - PROMPTBOOK VERSION 0.0.1
|
|
147
147
|
> - INPUT PARAM `{rawTitle}` Automatically suggested a site name or empty text
|
|
148
148
|
> - INPUT PARAM `{rawAssigment}` Automatically generated site entry from image recognition
|
|
149
|
-
> - OUTPUT PARAM `{
|
|
149
|
+
> - OUTPUT PARAM `{websiteContent}` Web content
|
|
150
150
|
> - OUTPUT PARAM `{keywords}` Keywords
|
|
151
151
|
>
|
|
152
152
|
> ## 👤 Specifying the assigment
|
|
@@ -305,7 +305,7 @@ File `write-website-content.ptbk.md`:
|
|
|
305
305
|
> {contentBody}
|
|
306
306
|
> ```
|
|
307
307
|
>
|
|
308
|
-
> `-> {
|
|
308
|
+
> `-> {websiteContent}`
|
|
309
309
|
|
|
310
310
|
|
|
311
311
|
|
|
@@ -345,7 +345,7 @@ flowchart LR
|
|
|
345
345
|
templateCombineTheBeginning--"{contentBeginning}"-->templateCombineTheContent
|
|
346
346
|
templateWriteTheContent--"{contentBody}"-->templateCombineTheContent
|
|
347
347
|
|
|
348
|
-
templateCombineTheContent--"{
|
|
348
|
+
templateCombineTheContent--"{websiteContent}"-->output
|
|
349
349
|
output((Output)):::output
|
|
350
350
|
|
|
351
351
|
classDef input color: grey;
|
package/esm/index.es.js
CHANGED
|
@@ -150,7 +150,7 @@ new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined'
|
|
|
150
150
|
/**
|
|
151
151
|
* The version of the Promptbook library
|
|
152
152
|
*/
|
|
153
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
153
|
+
var PROMPTBOOK_VERSION = '0.61.0-24';
|
|
154
154
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
155
155
|
|
|
156
156
|
/**
|
|
@@ -287,6 +287,7 @@ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
|
287
287
|
* The names of the parameters that are reserved for special purposes
|
|
288
288
|
*/
|
|
289
289
|
var RESERVED_PARAMETER_NAMES = deepFreeze([
|
|
290
|
+
'content',
|
|
290
291
|
'context',
|
|
291
292
|
'knowledge',
|
|
292
293
|
'samples',
|
|
@@ -299,6 +300,10 @@ var RESERVED_PARAMETER_NAMES = deepFreeze([
|
|
|
299
300
|
* @@@
|
|
300
301
|
*/
|
|
301
302
|
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
303
|
+
/**
|
|
304
|
+
* @@@
|
|
305
|
+
*/
|
|
306
|
+
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
302
307
|
/*
|
|
303
308
|
TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
|
|
304
309
|
*/
|
|
@@ -742,7 +747,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
742
747
|
});
|
|
743
748
|
}
|
|
744
749
|
|
|
745
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
750
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-24",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-24",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-24",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-24",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-24",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
746
751
|
|
|
747
752
|
/**
|
|
748
753
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -1176,6 +1181,36 @@ var ReferenceError$1 = /** @class */ (function (_super) {
|
|
|
1176
1181
|
return ReferenceError;
|
|
1177
1182
|
}(Error));
|
|
1178
1183
|
|
|
1184
|
+
/**
|
|
1185
|
+
* Parses the template and returns the list of all parameter names
|
|
1186
|
+
*
|
|
1187
|
+
* @param template the template with parameters in {curly} braces
|
|
1188
|
+
* @returns the list of parameter names
|
|
1189
|
+
*/
|
|
1190
|
+
function extractParameters(template) {
|
|
1191
|
+
var e_1, _a;
|
|
1192
|
+
var matches = template.matchAll(/{\w+}/g);
|
|
1193
|
+
var parameterNames = new Set();
|
|
1194
|
+
try {
|
|
1195
|
+
for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
|
|
1196
|
+
var match = matches_1_1.value;
|
|
1197
|
+
var parameterName = match[0].slice(1, -1);
|
|
1198
|
+
parameterNames.add(parameterName);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1202
|
+
finally {
|
|
1203
|
+
try {
|
|
1204
|
+
if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
|
|
1205
|
+
}
|
|
1206
|
+
finally { if (e_1) throw e_1.error; }
|
|
1207
|
+
}
|
|
1208
|
+
return parameterNames;
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* TODO: !!!!! Rename to extractParameterNames
|
|
1212
|
+
*/
|
|
1213
|
+
|
|
1179
1214
|
/**
|
|
1180
1215
|
* Unprepare just strips the preparation data of the pipeline
|
|
1181
1216
|
*/
|
|
@@ -1183,7 +1218,14 @@ function unpreparePipeline(pipeline) {
|
|
|
1183
1218
|
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, promptTemplates = pipeline.promptTemplates;
|
|
1184
1219
|
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
1185
1220
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
1186
|
-
promptTemplates = promptTemplates.map(function (promptTemplate) {
|
|
1221
|
+
promptTemplates = promptTemplates.map(function (promptTemplate) {
|
|
1222
|
+
var dependentParameterNames = promptTemplate.dependentParameterNames;
|
|
1223
|
+
var parameterNames = extractParameters(promptTemplate.preparedContent || '');
|
|
1224
|
+
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
1225
|
+
var promptTemplateUnprepared = __assign(__assign({}, promptTemplate), { dependentParameterNames: dependentParameterNames });
|
|
1226
|
+
delete promptTemplateUnprepared.preparedContent;
|
|
1227
|
+
return promptTemplateUnprepared;
|
|
1228
|
+
});
|
|
1187
1229
|
return __assign(__assign({}, pipeline), { promptTemplates: promptTemplates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
|
|
1188
1230
|
}
|
|
1189
1231
|
/**
|
|
@@ -1680,33 +1722,6 @@ function assertsExecutionSuccessful(executionResult) {
|
|
|
1680
1722
|
* TODO: [🧠] Can this return type be better typed than void
|
|
1681
1723
|
*/
|
|
1682
1724
|
|
|
1683
|
-
/**
|
|
1684
|
-
* Parses the template and returns the list of all parameter names
|
|
1685
|
-
*
|
|
1686
|
-
* @param template the template with parameters in {curly} braces
|
|
1687
|
-
* @returns the list of parameter names
|
|
1688
|
-
*/
|
|
1689
|
-
function extractParameters(template) {
|
|
1690
|
-
var e_1, _a;
|
|
1691
|
-
var matches = template.matchAll(/{\w+}/g);
|
|
1692
|
-
var parameterNames = new Set();
|
|
1693
|
-
try {
|
|
1694
|
-
for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
|
|
1695
|
-
var match = matches_1_1.value;
|
|
1696
|
-
var parameterName = match[0].slice(1, -1);
|
|
1697
|
-
parameterNames.add(parameterName);
|
|
1698
|
-
}
|
|
1699
|
-
}
|
|
1700
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1701
|
-
finally {
|
|
1702
|
-
try {
|
|
1703
|
-
if (matches_1_1 && !matches_1_1.done && (_a = matches_1.return)) _a.call(matches_1);
|
|
1704
|
-
}
|
|
1705
|
-
finally { if (e_1) throw e_1.error; }
|
|
1706
|
-
}
|
|
1707
|
-
return parameterNames;
|
|
1708
|
-
}
|
|
1709
|
-
|
|
1710
1725
|
/**
|
|
1711
1726
|
* Parses the given script and returns the list of all used variables that are not defined in the script
|
|
1712
1727
|
*
|
|
@@ -1764,10 +1779,10 @@ function extractVariables(script) {
|
|
|
1764
1779
|
*/
|
|
1765
1780
|
function extractParametersFromPromptTemplate(promptTemplate) {
|
|
1766
1781
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
1767
|
-
var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, jokerParameterNames = promptTemplate.jokerParameterNames;
|
|
1782
|
+
var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
|
|
1768
1783
|
var parameterNames = new Set();
|
|
1769
1784
|
try {
|
|
1770
|
-
for (var _d = __values(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameters(title)), false), __read(extractParameters(description || '')), false), __read(extractParameters(content)), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1785
|
+
for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameters(title)), false), __read(extractParameters(description || '')), false), __read(extractParameters(content)), false), __read(extractParameters(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1771
1786
|
var parameterName = _e.value;
|
|
1772
1787
|
parameterNames.add(parameterName);
|
|
1773
1788
|
}
|
|
@@ -1807,6 +1822,8 @@ function extractParametersFromPromptTemplate(promptTemplate) {
|
|
|
1807
1822
|
}
|
|
1808
1823
|
finally { if (e_3) throw e_3.error; }
|
|
1809
1824
|
}
|
|
1825
|
+
parameterNames.delete('content');
|
|
1826
|
+
// <- Note {websiteContent} is used in `preparedContent`
|
|
1810
1827
|
return parameterNames;
|
|
1811
1828
|
}
|
|
1812
1829
|
/**
|
|
@@ -1976,7 +1993,14 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
1976
1993
|
throw errors[0];
|
|
1977
1994
|
}
|
|
1978
1995
|
else if (errors.length > 1) {
|
|
1979
|
-
throw new PipelineExecutionError(
|
|
1996
|
+
throw new PipelineExecutionError(
|
|
1997
|
+
// TODO: Tell which execution tools failed like
|
|
1998
|
+
// 1) OpenAI throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
1999
|
+
// 2) AnthropicClaude throw PipelineExecutionError: Parameter {knowledge} is not defined
|
|
2000
|
+
// 3) ...
|
|
2001
|
+
spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors
|
|
2002
|
+
.map(function (error, i) { return "".concat(i + 1, ") **").concat(error.name || 'Error', ":** ").concat(error.message); })
|
|
2003
|
+
.join('\n')), "\n\n "); }));
|
|
1980
2004
|
}
|
|
1981
2005
|
else {
|
|
1982
2006
|
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.llmExecutionTools
|
|
@@ -2181,6 +2205,10 @@ function replaceParameters(template, parameters) {
|
|
|
2181
2205
|
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
2182
2206
|
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
2183
2207
|
}
|
|
2208
|
+
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
2209
|
+
// TODO: [🍵]
|
|
2210
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
2211
|
+
}
|
|
2184
2212
|
}
|
|
2185
2213
|
}
|
|
2186
2214
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -2443,7 +2471,7 @@ function createPipelineExecutor(options) {
|
|
|
2443
2471
|
console.warn(spaceTrim$1("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\n\n ").concat(rawPipeline.sourceFile, "\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
|
|
2444
2472
|
}
|
|
2445
2473
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2446
|
-
// TODO:
|
|
2474
|
+
// TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
|
|
2447
2475
|
function getContextForTemplate(// <- TODO: [🧠][🥜]
|
|
2448
2476
|
template) {
|
|
2449
2477
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2494,6 +2522,7 @@ function createPipelineExecutor(options) {
|
|
|
2494
2522
|
currentDate = new Date().toISOString();
|
|
2495
2523
|
modelName = RESERVED_PARAMETER_MISSING_VALUE;
|
|
2496
2524
|
reservedParameters = {
|
|
2525
|
+
content: RESERVED_PARAMETER_RESTRICTED,
|
|
2497
2526
|
context: context,
|
|
2498
2527
|
knowledge: knowledge,
|
|
2499
2528
|
samples: samples,
|
|
@@ -3204,6 +3233,8 @@ function createPipelineExecutor(options) {
|
|
|
3204
3233
|
return pipelineExecutor;
|
|
3205
3234
|
}
|
|
3206
3235
|
/**
|
|
3236
|
+
* TODO: !!!! return `preparedPipeline` from execution
|
|
3237
|
+
* TODO: !!!! `isNotPreparedWarningSupressed`
|
|
3207
3238
|
* TODO: Use isVerbose here (not only pass to `preparePipeline`)
|
|
3208
3239
|
* TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
3209
3240
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
@@ -3218,7 +3249,7 @@ function createPipelineExecutor(options) {
|
|
|
3218
3249
|
/**
|
|
3219
3250
|
* @@@
|
|
3220
3251
|
*/
|
|
3221
|
-
function prepareKnowledgeFromMarkdown(
|
|
3252
|
+
function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
|
|
3222
3253
|
return __awaiter(this, void 0, void 0, function () {
|
|
3223
3254
|
var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgePiecesRaw, knowledgeTextPieces, knowledge;
|
|
3224
3255
|
var _f, _g, _h;
|
|
@@ -3256,7 +3287,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
|
|
|
3256
3287
|
llm: llmTools,
|
|
3257
3288
|
},
|
|
3258
3289
|
_h)]);
|
|
3259
|
-
return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({
|
|
3290
|
+
return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ knowledgeContent: knowledgeContent })];
|
|
3260
3291
|
case 4:
|
|
3261
3292
|
result = _j.sent();
|
|
3262
3293
|
assertsExecutionSuccessful(result);
|
|
@@ -3269,25 +3300,25 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
|
|
|
3269
3300
|
return [4 /*yield*/, Promise.all(
|
|
3270
3301
|
// TODO: [🪂] !! Do not send all at once but in chunks
|
|
3271
3302
|
knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
|
|
3272
|
-
var name, title,
|
|
3303
|
+
var name, title, knowledgePieceContent, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
|
|
3273
3304
|
return __generator(this, function (_c) {
|
|
3274
3305
|
switch (_c.label) {
|
|
3275
3306
|
case 0:
|
|
3276
3307
|
name = "piece-".concat(i);
|
|
3277
3308
|
title = spaceTrim(knowledgeTextPiece.substring(0, 100));
|
|
3278
|
-
|
|
3309
|
+
knowledgePieceContent = spaceTrim(knowledgeTextPiece);
|
|
3279
3310
|
keywords = [];
|
|
3280
3311
|
index = [];
|
|
3281
3312
|
_c.label = 1;
|
|
3282
3313
|
case 1:
|
|
3283
3314
|
_c.trys.push([1, 7, , 8]);
|
|
3284
|
-
return [4 /*yield*/, prepareTitleExecutor({
|
|
3315
|
+
return [4 /*yield*/, prepareTitleExecutor({ knowledgePieceContent: knowledgePieceContent })];
|
|
3285
3316
|
case 2:
|
|
3286
3317
|
titleResult = _c.sent();
|
|
3287
3318
|
_a = titleResult.outputParameters.title, titleRaw = _a === void 0 ? 'Untitled' : _a;
|
|
3288
3319
|
title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
3289
3320
|
name = titleToName(title);
|
|
3290
|
-
return [4 /*yield*/, prepareKeywordsExecutor({
|
|
3321
|
+
return [4 /*yield*/, prepareKeywordsExecutor({ knowledgePieceContent: knowledgePieceContent })];
|
|
3291
3322
|
case 3:
|
|
3292
3323
|
keywordsResult = _c.sent();
|
|
3293
3324
|
_b = keywordsResult.outputParameters.keywords, keywordsRaw = _b === void 0 ? '' : _b;
|
|
@@ -3305,7 +3336,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
|
|
|
3305
3336
|
case 4: return [4 /*yield*/, llmTools.callEmbeddingModel({
|
|
3306
3337
|
title: "Embedding for ".concat(title) /* <- Note: No impact on embedding result itself, just for logging */,
|
|
3307
3338
|
parameters: {},
|
|
3308
|
-
content:
|
|
3339
|
+
content: knowledgePieceContent,
|
|
3309
3340
|
modelRequirements: {
|
|
3310
3341
|
modelVariant: 'EMBEDDING',
|
|
3311
3342
|
},
|
|
@@ -3326,7 +3357,7 @@ function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Al
|
|
|
3326
3357
|
case 8: return [2 /*return*/, {
|
|
3327
3358
|
name: name,
|
|
3328
3359
|
title: title,
|
|
3329
|
-
content:
|
|
3360
|
+
content: knowledgePieceContent,
|
|
3330
3361
|
keywords: keywords,
|
|
3331
3362
|
index: index,
|
|
3332
3363
|
// <- TODO: [☀] sources,
|
|
@@ -3492,14 +3523,18 @@ function prepareTemplates(pipeline, options) {
|
|
|
3492
3523
|
TODO_USE(parameters);
|
|
3493
3524
|
promptTemplatesPrepared = new Array(promptTemplates.length);
|
|
3494
3525
|
return [4 /*yield*/, forEachAsync(promptTemplates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3495
|
-
var preparedContent, preparedTemplate;
|
|
3526
|
+
var dependentParameterNames, preparedContent, preparedTemplate;
|
|
3496
3527
|
return __generator(this, function (_a) {
|
|
3528
|
+
dependentParameterNames = template.dependentParameterNames;
|
|
3497
3529
|
preparedContent = undefined;
|
|
3498
|
-
if (knowledgePiecesCount > 0) {
|
|
3530
|
+
if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
|
|
3499
3531
|
preparedContent = spaceTrim$1("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
|
|
3500
3532
|
// <- TODO: [🧠][🧻] Cutomize shape/language/formatting of the addition to the prompt
|
|
3533
|
+
dependentParameterNames = __spreadArray(__spreadArray([], __read(dependentParameterNames), false), [
|
|
3534
|
+
'knowledge',
|
|
3535
|
+
], false);
|
|
3501
3536
|
}
|
|
3502
|
-
preparedTemplate = __assign(__assign({}, template), { preparedContent: preparedContent });
|
|
3537
|
+
preparedTemplate = __assign(__assign({}, template), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
|
|
3503
3538
|
promptTemplatesPrepared[index] = preparedTemplate;
|
|
3504
3539
|
return [2 /*return*/];
|
|
3505
3540
|
});
|
|
@@ -4315,7 +4350,7 @@ var parameterCommandParser = {
|
|
|
4315
4350
|
/**
|
|
4316
4351
|
* Example usages of the PARAMETER command
|
|
4317
4352
|
*/
|
|
4318
|
-
examples: ['PARAMETER {title} Title of the book', 'OUTPUT PARAMETER {
|
|
4353
|
+
examples: ['PARAMETER {title} Title of the book', 'OUTPUT PARAMETER {websiteContent} Content of the book'],
|
|
4319
4354
|
/**
|
|
4320
4355
|
* Parses the PARAMETER command
|
|
4321
4356
|
*/
|