@promptbook/pdf 0.81.0-22 → 0.81.0-24
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 +4 -20
- package/esm/index.es.js +92 -77
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +2 -2
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +11 -0
- package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
- package/esm/typings/src/commands/index.d.ts +1 -1
- package/esm/typings/src/config.d.ts +2 -2
- package/esm/typings/src/conversion/parsePipeline.d.ts +1 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +7 -7
- package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
- package/esm/typings/src/llm-providers/vercel/playground/playground.d.ts +1 -1
- package/esm/typings/src/other/templates/getBookTemplates.d.ts +1 -1
- package/esm/typings/src/personas/preparePersona.d.ts +4 -4
- package/esm/typings/src/pipeline/PipelineString.d.ts +0 -3
- package/esm/typings/src/pipeline/book-notation.d.ts +0 -1
- package/esm/typings/src/pipeline/isValidPipelineString.d.ts +3 -1
- package/esm/typings/src/pipeline/validatePipelineString.d.ts +14 -0
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTasks.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.test.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +8 -2
- package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +1 -1
- package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +92 -77
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @generated
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
27
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-23';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -180,6 +180,66 @@
|
|
|
180
180
|
|
|
181
181
|
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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 - Write maximum ideally 2 words, maximum 5 words\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou 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 - Write maximum ideally 2 words, maximum 5 words\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",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}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\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- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `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### Key `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}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book.md`\n- INPUT PARAMETER `{availableModelNames}` List of available model names separated by comma (,)\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\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- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `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### Key `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}\n```\n\n`-> {modelRequirements}`\n"}],sourceFile:"./books/prepare-persona.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book.md",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the task:\n\n> {book}\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Title starts with emoticon",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book.md`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the task:\n\n> {book}\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Title starts with emoticon\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book.md"}];
|
|
182
182
|
|
|
183
|
+
/**
|
|
184
|
+
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
185
|
+
*
|
|
186
|
+
* @public exported from `@promptbook/utils`
|
|
187
|
+
*/
|
|
188
|
+
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
189
|
+
try {
|
|
190
|
+
JSON.parse(value);
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
if (!(error instanceof Error)) {
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
if (error.message.includes('Unexpected token')) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
206
|
+
*
|
|
207
|
+
* @public exported from `@promptbook/core`
|
|
208
|
+
*/
|
|
209
|
+
var ParseError = /** @class */ (function (_super) {
|
|
210
|
+
__extends(ParseError, _super);
|
|
211
|
+
function ParseError(message) {
|
|
212
|
+
var _this = _super.call(this, message) || this;
|
|
213
|
+
_this.name = 'ParseError';
|
|
214
|
+
Object.setPrototypeOf(_this, ParseError.prototype);
|
|
215
|
+
return _this;
|
|
216
|
+
}
|
|
217
|
+
return ParseError;
|
|
218
|
+
}(Error));
|
|
219
|
+
/**
|
|
220
|
+
* TODO: Maybe split `ParseError` and `ApplyError`
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
225
|
+
* It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
|
|
226
|
+
*
|
|
227
|
+
* @param {string} pipelineString the candidate for a pipeline string
|
|
228
|
+
* @returns {PipelineString} the same string as input, but validated as valid
|
|
229
|
+
* @throws {ParseError} if the string is not a valid pipeline string
|
|
230
|
+
* @public exported from `@promptbook/core`
|
|
231
|
+
*/
|
|
232
|
+
function validatePipelineString(pipelineString) {
|
|
233
|
+
if (isValidJsonString(pipelineString)) {
|
|
234
|
+
throw new ParseError('Expected a book, but got a JSON string');
|
|
235
|
+
}
|
|
236
|
+
// <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
|
|
237
|
+
return pipelineString;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* TODO: [🧠][🈴] Where is the best location for this file
|
|
241
|
+
*/
|
|
242
|
+
|
|
183
243
|
/**
|
|
184
244
|
* Prettify the html code
|
|
185
245
|
*
|
|
@@ -246,7 +306,7 @@
|
|
|
246
306
|
if (bookVersion !== "undefined") {
|
|
247
307
|
commands.push("BOOK VERSION ".concat(bookVersion));
|
|
248
308
|
}
|
|
249
|
-
// TODO: [main]
|
|
309
|
+
// TODO: [main] !!5 This increases size of the bundle and is probbably not necessary
|
|
250
310
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
251
311
|
try {
|
|
252
312
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -394,12 +454,12 @@
|
|
|
394
454
|
pipelineString += '```' + contentLanguage;
|
|
395
455
|
pipelineString += '\n';
|
|
396
456
|
pipelineString += spaceTrim__default["default"](content);
|
|
397
|
-
// <- TODO: [main]
|
|
457
|
+
// <- TODO: [main] !!3 Escape
|
|
398
458
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
399
459
|
pipelineString += '\n';
|
|
400
460
|
pipelineString += '```';
|
|
401
461
|
pipelineString += '\n\n';
|
|
402
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main]
|
|
462
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!3 If the parameter here has description, add it and use taskParameterJsonToString
|
|
403
463
|
}
|
|
404
464
|
}
|
|
405
465
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -409,7 +469,7 @@
|
|
|
409
469
|
}
|
|
410
470
|
finally { if (e_3) throw e_3.error; }
|
|
411
471
|
}
|
|
412
|
-
return pipelineString;
|
|
472
|
+
return validatePipelineString(pipelineString);
|
|
413
473
|
}
|
|
414
474
|
/**
|
|
415
475
|
* @private internal utility of `pipelineJsonToString`
|
|
@@ -627,7 +687,7 @@
|
|
|
627
687
|
/**
|
|
628
688
|
* Make error report URL for the given error
|
|
629
689
|
*
|
|
630
|
-
* @private
|
|
690
|
+
* @private private within the repository
|
|
631
691
|
*/
|
|
632
692
|
function getErrorReportUrl(error) {
|
|
633
693
|
var report = {
|
|
@@ -778,7 +838,7 @@
|
|
|
778
838
|
}
|
|
779
839
|
/**
|
|
780
840
|
* TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
|
|
781
|
-
* TODO: [🧠][main]
|
|
841
|
+
* TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
|
|
782
842
|
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
783
843
|
*/
|
|
784
844
|
|
|
@@ -901,25 +961,6 @@
|
|
|
901
961
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
902
962
|
*/
|
|
903
963
|
|
|
904
|
-
/**
|
|
905
|
-
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
906
|
-
*
|
|
907
|
-
* @public exported from `@promptbook/core`
|
|
908
|
-
*/
|
|
909
|
-
var ParseError = /** @class */ (function (_super) {
|
|
910
|
-
__extends(ParseError, _super);
|
|
911
|
-
function ParseError(message) {
|
|
912
|
-
var _this = _super.call(this, message) || this;
|
|
913
|
-
_this.name = 'ParseError';
|
|
914
|
-
Object.setPrototypeOf(_this, ParseError.prototype);
|
|
915
|
-
return _this;
|
|
916
|
-
}
|
|
917
|
-
return ParseError;
|
|
918
|
-
}(Error));
|
|
919
|
-
/**
|
|
920
|
-
* TODO: Maybe split `ParseError` and `ApplyError`
|
|
921
|
-
*/
|
|
922
|
-
|
|
923
964
|
/**
|
|
924
965
|
* This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
|
|
925
966
|
*
|
|
@@ -974,7 +1015,7 @@
|
|
|
974
1015
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
975
1016
|
return false;
|
|
976
1017
|
}
|
|
977
|
-
// <- TODO: [main]
|
|
1018
|
+
// <- TODO: [main] !!3 Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
|
|
978
1019
|
return true;
|
|
979
1020
|
}
|
|
980
1021
|
|
|
@@ -1104,11 +1145,11 @@
|
|
|
1104
1145
|
*/
|
|
1105
1146
|
function validatePipeline(pipeline) {
|
|
1106
1147
|
if (IS_PIPELINE_LOGIC_VALIDATED) {
|
|
1107
|
-
|
|
1148
|
+
validatePipeline_InnerFunction(pipeline);
|
|
1108
1149
|
}
|
|
1109
1150
|
else {
|
|
1110
1151
|
try {
|
|
1111
|
-
|
|
1152
|
+
validatePipeline_InnerFunction(pipeline);
|
|
1112
1153
|
}
|
|
1113
1154
|
catch (error) {
|
|
1114
1155
|
if (!(error instanceof PipelineLogicError)) {
|
|
@@ -1122,7 +1163,7 @@
|
|
|
1122
1163
|
/**
|
|
1123
1164
|
* @private internal function for `validatePipeline`
|
|
1124
1165
|
*/
|
|
1125
|
-
function
|
|
1166
|
+
function validatePipeline_InnerFunction(pipeline) {
|
|
1126
1167
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
1127
1168
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
1128
1169
|
var pipelineIdentification = (function () {
|
|
@@ -1346,11 +1387,11 @@
|
|
|
1346
1387
|
_loop_3();
|
|
1347
1388
|
}
|
|
1348
1389
|
// Note: Check that formfactor is corresponding to the pipeline interface
|
|
1349
|
-
// TODO:
|
|
1390
|
+
// TODO: !!6 Implement this
|
|
1350
1391
|
// pipeline.formfactorName
|
|
1351
1392
|
}
|
|
1352
1393
|
/**
|
|
1353
|
-
* TODO:
|
|
1394
|
+
* TODO: [🧞♀️] Do not allow joker + foreach
|
|
1354
1395
|
* TODO: [🧠] Work with promptbookVersion
|
|
1355
1396
|
* TODO: Use here some json-schema, Zod or something similar and change it to:
|
|
1356
1397
|
* > /**
|
|
@@ -1362,11 +1403,11 @@
|
|
|
1362
1403
|
* > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
|
|
1363
1404
|
*/
|
|
1364
1405
|
/**
|
|
1365
|
-
* TODO: [🧳][main]
|
|
1366
|
-
* TODO: [🧳][🐝][main]
|
|
1367
|
-
* TODO: [🧳][main]
|
|
1368
|
-
* TODO: [🧳][main]
|
|
1369
|
-
* TODO: [🧳][main]
|
|
1406
|
+
* TODO: [🧳][main] !!4 Validate that all examples match expectations
|
|
1407
|
+
* TODO: [🧳][🐝][main] !!4 Validate that knowledge is valid (non-void)
|
|
1408
|
+
* TODO: [🧳][main] !!4 Validate that persona can be used only with CHAT variant
|
|
1409
|
+
* TODO: [🧳][main] !!4 Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
|
|
1410
|
+
* TODO: [🧳][main] !!4 Validate that reserved parameter is not used as joker
|
|
1370
1411
|
* TODO: [🧠] Validation not only logic itself but imports around - files and websites and rerefenced pipelines exists
|
|
1371
1412
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
1372
1413
|
*/
|
|
@@ -1502,7 +1543,7 @@
|
|
|
1502
1543
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
1503
1544
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
1504
1545
|
var existing = this.collection.get(pipeline.pipelineUrl);
|
|
1505
|
-
throw new PipelineUrlError(spaceTrim.spaceTrim("\n Pipeline with URL
|
|
1546
|
+
throw new PipelineUrlError(spaceTrim.spaceTrim("\n Pipeline with URL ".concat(pipeline.pipelineUrl, " is already in the collection \uD83C\uDF4E\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: You have probably forgotten to run \"ptbk make\" to update the collection\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
|
|
1506
1547
|
}
|
|
1507
1548
|
// Note: [🧠] Overwrite existing pipeline with the same URL
|
|
1508
1549
|
this.collection.set(pipeline.pipelineUrl, pipeline);
|
|
@@ -1847,7 +1888,7 @@
|
|
|
1847
1888
|
return true;
|
|
1848
1889
|
}
|
|
1849
1890
|
/**
|
|
1850
|
-
* TODO: [🔃][main]
|
|
1891
|
+
* TODO: [🔃][main] If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
1851
1892
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
1852
1893
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
1853
1894
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
@@ -2612,10 +2653,10 @@
|
|
|
2612
2653
|
});
|
|
2613
2654
|
}
|
|
2614
2655
|
/**
|
|
2615
|
-
* TODO: [🔃][main]
|
|
2616
|
-
* TODO: [🏢]
|
|
2617
|
-
* TODO: [🏢]
|
|
2618
|
-
* TODO: [🏢]
|
|
2656
|
+
* TODO: [🔃][main] If the persona was prepared with different version or different set of models, prepare it once again
|
|
2657
|
+
* TODO: [🏢] Check validity of `modelName` in pipeline
|
|
2658
|
+
* TODO: [🏢] Check validity of `systemMessage` in pipeline
|
|
2659
|
+
* TODO: [🏢] Check validity of `temperature` in pipeline
|
|
2619
2660
|
*/
|
|
2620
2661
|
|
|
2621
2662
|
/**
|
|
@@ -3699,7 +3740,7 @@
|
|
|
3699
3740
|
* TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
|
|
3700
3741
|
* TODO: [🧠] Add context to each task (if missing)
|
|
3701
3742
|
* TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
|
|
3702
|
-
* TODO: [♨][main]
|
|
3743
|
+
* TODO: [♨][main] !!3 Prepare index the examples and maybe tasks
|
|
3703
3744
|
* TODO: Write tests for `preparePipeline`
|
|
3704
3745
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3705
3746
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -3762,17 +3803,10 @@
|
|
|
3762
3803
|
_d.tools = tools,
|
|
3763
3804
|
_d)]);
|
|
3764
3805
|
return [4 /*yield*/, prepareTitleExecutor({
|
|
3765
|
-
book: sources
|
|
3766
|
-
.map(function (_a) {
|
|
3806
|
+
book: sources.map(function (_a) {
|
|
3767
3807
|
var content = _a.content;
|
|
3768
3808
|
return content;
|
|
3769
|
-
})
|
|
3770
|
-
.join('\n\n')
|
|
3771
|
-
// TODO: !!!!!!! Parameters in parameters - DO NOT ALLOW, ESCAPE:
|
|
3772
|
-
.split('{')
|
|
3773
|
-
.join('[')
|
|
3774
|
-
.split('}')
|
|
3775
|
-
.join(']'),
|
|
3809
|
+
}).join('\n\n'),
|
|
3776
3810
|
})];
|
|
3777
3811
|
case 2:
|
|
3778
3812
|
result = _e.sent();
|
|
@@ -4182,27 +4216,6 @@
|
|
|
4182
4216
|
* TODO: [🏢] Allow to expect something inside CSV objects and other formats
|
|
4183
4217
|
*/
|
|
4184
4218
|
|
|
4185
|
-
/**
|
|
4186
|
-
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
4187
|
-
*
|
|
4188
|
-
* @public exported from `@promptbook/utils`
|
|
4189
|
-
*/
|
|
4190
|
-
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
4191
|
-
try {
|
|
4192
|
-
JSON.parse(value);
|
|
4193
|
-
return true;
|
|
4194
|
-
}
|
|
4195
|
-
catch (error) {
|
|
4196
|
-
if (!(error instanceof Error)) {
|
|
4197
|
-
throw error;
|
|
4198
|
-
}
|
|
4199
|
-
if (error.message.includes('Unexpected token')) {
|
|
4200
|
-
return false;
|
|
4201
|
-
}
|
|
4202
|
-
return false;
|
|
4203
|
-
}
|
|
4204
|
-
}
|
|
4205
|
-
|
|
4206
4219
|
/**
|
|
4207
4220
|
* Definition for JSON format
|
|
4208
4221
|
*
|
|
@@ -4577,6 +4590,8 @@
|
|
|
4577
4590
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4578
4591
|
}
|
|
4579
4592
|
parameterValue = valueToString(parameterValue);
|
|
4593
|
+
// Escape curly braces in parameter values to prevent prompt-injection
|
|
4594
|
+
parameterValue = parameterValue.replace(/[{}]/g, '\\$&');
|
|
4580
4595
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
4581
4596
|
parameterValue = parameterValue
|
|
4582
4597
|
.split('\n')
|
|
@@ -4936,7 +4951,7 @@
|
|
|
4936
4951
|
promptTitle: task.title,
|
|
4937
4952
|
promptMessage: templateParameters(task.description || '', parameters),
|
|
4938
4953
|
defaultValue: templateParameters(preparedContent, parameters),
|
|
4939
|
-
// TODO: [🧠]
|
|
4954
|
+
// TODO: [🧠] Figure out how to define placeholder in .book.md file
|
|
4940
4955
|
placeholder: undefined,
|
|
4941
4956
|
priority: priority,
|
|
4942
4957
|
}))];
|
|
@@ -6021,12 +6036,12 @@
|
|
|
6021
6036
|
outputParameters = result.outputParameters;
|
|
6022
6037
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
6023
6038
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
6024
|
-
// <- TODO: [main]
|
|
6039
|
+
// <- TODO: [main] Smarter split and filter out empty pieces
|
|
6025
6040
|
if (isVerbose) {
|
|
6026
6041
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
6027
6042
|
}
|
|
6028
6043
|
return [4 /*yield*/, Promise.all(
|
|
6029
|
-
// TODO: [🪂]
|
|
6044
|
+
// TODO: [🪂] Do not send all at once but in chunks
|
|
6030
6045
|
knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
|
|
6031
6046
|
var name, title, knowledgePieceContent, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
|
|
6032
6047
|
return __generator(this, function (_c) {
|