@promptbook/markdown-utils 0.81.0-21 → 0.81.0-23
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 +52 -37
- 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 +1 -1
- package/umd/index.umd.js +52 -37
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -132,32 +132,25 @@ We also have a community of developers and users of **Promptbook**:
|
|
|
132
132
|
- [Landing page `ptbk.io`](https://ptbk.io)
|
|
133
133
|
- [Github discussions](https://github.com/webgptorg/promptbook/discussions)
|
|
134
134
|
- [LinkedIn `Promptbook`](https://linkedin.com/company/promptbook)
|
|
135
|
-
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
135
|
+
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
136
136
|
|
|
137
137
|
And **Promptbook.studio** branded socials:
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
139
|
- [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
|
|
142
140
|
|
|
143
|
-
|
|
144
|
-
|
|
145
141
|
And **Promptujeme** sub-brand:
|
|
146
142
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
_/Subbrand for Czech clients/_
|
|
150
144
|
|
|
151
145
|
- [Promptujeme.cz](https://www.promptujeme.cz/)
|
|
152
146
|
- [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
|
|
153
147
|
|
|
154
|
-
|
|
155
148
|
And **Promptbook.city** branded socials:
|
|
156
149
|
|
|
157
|
-
|
|
150
|
+
_/Sub-brand for images and graphics generated via Promptbook prompting/_
|
|
158
151
|
|
|
159
152
|
- [Instagram `@promptbook.city`](https://www.instagram.com/promptbook.city/)
|
|
160
|
-
- [Facebook `Promptbook City`](https://www.facebook.com/61565718625569)
|
|
153
|
+
- [Facebook `Promptbook City`](https://www.facebook.com/61565718625569)
|
|
161
154
|
|
|
162
155
|
|
|
163
156
|
|
|
@@ -291,11 +284,6 @@ Or you can install them separately:
|
|
|
291
284
|
|
|
292
285
|
## 📚 Dictionary
|
|
293
286
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
287
|
### 📚 Dictionary
|
|
300
288
|
|
|
301
289
|
The following glossary is used to clarify certain concepts:
|
|
@@ -311,8 +299,6 @@ The following glossary is used to clarify certain concepts:
|
|
|
311
299
|
- **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.
|
|
312
300
|
- **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.
|
|
313
301
|
|
|
314
|
-
|
|
315
|
-
|
|
316
302
|
_Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
317
303
|
|
|
318
304
|
#### Promptbook core
|
|
@@ -373,8 +359,6 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
373
359
|
- [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
|
|
374
360
|
- [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
|
|
375
361
|
|
|
376
|
-
|
|
377
|
-
|
|
378
362
|
### Terms specific to Promptbook TypeScript implementation
|
|
379
363
|
|
|
380
364
|
- Anonymous mode
|
package/esm/index.es.js
CHANGED
|
@@ -22,7 +22,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
22
22
|
* @generated
|
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
|
24
24
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-22';
|
|
26
26
|
/**
|
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
28
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -360,6 +360,26 @@ function extractJsonBlock(markdown) {
|
|
|
360
360
|
|
|
361
361
|
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"}];
|
|
362
362
|
|
|
363
|
+
/**
|
|
364
|
+
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
365
|
+
* 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.
|
|
366
|
+
*
|
|
367
|
+
* @param {string} pipelineString the candidate for a pipeline string
|
|
368
|
+
* @returns {PipelineString} the same string as input, but validated as valid
|
|
369
|
+
* @throws {ParseError} if the string is not a valid pipeline string
|
|
370
|
+
* @public exported from `@promptbook/core`
|
|
371
|
+
*/
|
|
372
|
+
function validatePipelineString(pipelineString) {
|
|
373
|
+
if (isValidJsonString(pipelineString)) {
|
|
374
|
+
throw new ParseError('Expected a book, but got a JSON string');
|
|
375
|
+
}
|
|
376
|
+
// <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
|
|
377
|
+
return pipelineString;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* TODO: [🧠][🈴] Where is the best location for this file
|
|
381
|
+
*/
|
|
382
|
+
|
|
363
383
|
/**
|
|
364
384
|
* Prettify the html code
|
|
365
385
|
*
|
|
@@ -417,7 +437,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
417
437
|
if (bookVersion !== "undefined") {
|
|
418
438
|
commands.push("BOOK VERSION ".concat(bookVersion));
|
|
419
439
|
}
|
|
420
|
-
// TODO: [main]
|
|
440
|
+
// TODO: [main] !!5 This increases size of the bundle and is probbably not necessary
|
|
421
441
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
422
442
|
try {
|
|
423
443
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -565,12 +585,12 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
565
585
|
pipelineString += '```' + contentLanguage;
|
|
566
586
|
pipelineString += '\n';
|
|
567
587
|
pipelineString += spaceTrim(content);
|
|
568
|
-
// <- TODO: [main]
|
|
588
|
+
// <- TODO: [main] !!3 Escape
|
|
569
589
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
570
590
|
pipelineString += '\n';
|
|
571
591
|
pipelineString += '```';
|
|
572
592
|
pipelineString += '\n\n';
|
|
573
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main]
|
|
593
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!3 If the parameter here has description, add it and use taskParameterJsonToString
|
|
574
594
|
}
|
|
575
595
|
}
|
|
576
596
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -580,7 +600,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
580
600
|
}
|
|
581
601
|
finally { if (e_3) throw e_3.error; }
|
|
582
602
|
}
|
|
583
|
-
return pipelineString;
|
|
603
|
+
return validatePipelineString(pipelineString);
|
|
584
604
|
}
|
|
585
605
|
/**
|
|
586
606
|
* @private internal utility of `pipelineJsonToString`
|
|
@@ -804,7 +824,7 @@ function $deepFreeze(objectValue) {
|
|
|
804
824
|
/**
|
|
805
825
|
* Make error report URL for the given error
|
|
806
826
|
*
|
|
807
|
-
* @private
|
|
827
|
+
* @private private within the repository
|
|
808
828
|
*/
|
|
809
829
|
function getErrorReportUrl(error) {
|
|
810
830
|
var report = {
|
|
@@ -955,7 +975,7 @@ function checkSerializableAsJson(options) {
|
|
|
955
975
|
}
|
|
956
976
|
/**
|
|
957
977
|
* TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
|
|
958
|
-
* TODO: [🧠][main]
|
|
978
|
+
* TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
|
|
959
979
|
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
960
980
|
*/
|
|
961
981
|
|
|
@@ -1132,7 +1152,7 @@ function isValidPromptbookVersion(version) {
|
|
|
1132
1152
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
1133
1153
|
return false;
|
|
1134
1154
|
}
|
|
1135
|
-
// <- TODO: [main]
|
|
1155
|
+
// <- TODO: [main] !!3 Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
|
|
1136
1156
|
return true;
|
|
1137
1157
|
}
|
|
1138
1158
|
|
|
@@ -1262,11 +1282,11 @@ function isValidPipelineUrl(url) {
|
|
|
1262
1282
|
*/
|
|
1263
1283
|
function validatePipeline(pipeline) {
|
|
1264
1284
|
if (IS_PIPELINE_LOGIC_VALIDATED) {
|
|
1265
|
-
|
|
1285
|
+
validatePipeline_InnerFunction(pipeline);
|
|
1266
1286
|
}
|
|
1267
1287
|
else {
|
|
1268
1288
|
try {
|
|
1269
|
-
|
|
1289
|
+
validatePipeline_InnerFunction(pipeline);
|
|
1270
1290
|
}
|
|
1271
1291
|
catch (error) {
|
|
1272
1292
|
if (!(error instanceof PipelineLogicError)) {
|
|
@@ -1280,7 +1300,7 @@ function validatePipeline(pipeline) {
|
|
|
1280
1300
|
/**
|
|
1281
1301
|
* @private internal function for `validatePipeline`
|
|
1282
1302
|
*/
|
|
1283
|
-
function
|
|
1303
|
+
function validatePipeline_InnerFunction(pipeline) {
|
|
1284
1304
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
1285
1305
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
1286
1306
|
var pipelineIdentification = (function () {
|
|
@@ -1504,11 +1524,11 @@ function validatePipelineCore(pipeline) {
|
|
|
1504
1524
|
_loop_3();
|
|
1505
1525
|
}
|
|
1506
1526
|
// Note: Check that formfactor is corresponding to the pipeline interface
|
|
1507
|
-
// TODO:
|
|
1527
|
+
// TODO: !!6 Implement this
|
|
1508
1528
|
// pipeline.formfactorName
|
|
1509
1529
|
}
|
|
1510
1530
|
/**
|
|
1511
|
-
* TODO:
|
|
1531
|
+
* TODO: [🧞♀️] Do not allow joker + foreach
|
|
1512
1532
|
* TODO: [🧠] Work with promptbookVersion
|
|
1513
1533
|
* TODO: Use here some json-schema, Zod or something similar and change it to:
|
|
1514
1534
|
* > /**
|
|
@@ -1520,11 +1540,11 @@ function validatePipelineCore(pipeline) {
|
|
|
1520
1540
|
* > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
|
|
1521
1541
|
*/
|
|
1522
1542
|
/**
|
|
1523
|
-
* TODO: [🧳][main]
|
|
1524
|
-
* TODO: [🧳][🐝][main]
|
|
1525
|
-
* TODO: [🧳][main]
|
|
1526
|
-
* TODO: [🧳][main]
|
|
1527
|
-
* TODO: [🧳][main]
|
|
1543
|
+
* TODO: [🧳][main] !!4 Validate that all examples match expectations
|
|
1544
|
+
* TODO: [🧳][🐝][main] !!4 Validate that knowledge is valid (non-void)
|
|
1545
|
+
* TODO: [🧳][main] !!4 Validate that persona can be used only with CHAT variant
|
|
1546
|
+
* TODO: [🧳][main] !!4 Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
|
|
1547
|
+
* TODO: [🧳][main] !!4 Validate that reserved parameter is not used as joker
|
|
1528
1548
|
* TODO: [🧠] Validation not only logic itself but imports around - files and websites and rerefenced pipelines exists
|
|
1529
1549
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
1530
1550
|
*/
|
|
@@ -1660,7 +1680,7 @@ var SimplePipelineCollection = /** @class */ (function () {
|
|
|
1660
1680
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
1661
1681
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
1662
1682
|
var existing = this.collection.get(pipeline.pipelineUrl);
|
|
1663
|
-
throw new PipelineUrlError(spaceTrim$1("\n Pipeline with URL
|
|
1683
|
+
throw new PipelineUrlError(spaceTrim$1("\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 ")));
|
|
1664
1684
|
}
|
|
1665
1685
|
// Note: [🧠] Overwrite existing pipeline with the same URL
|
|
1666
1686
|
this.collection.set(pipeline.pipelineUrl, pipeline);
|
|
@@ -2021,7 +2041,7 @@ function isPipelinePrepared(pipeline) {
|
|
|
2021
2041
|
return true;
|
|
2022
2042
|
}
|
|
2023
2043
|
/**
|
|
2024
|
-
* TODO: [🔃][main]
|
|
2044
|
+
* TODO: [🔃][main] If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
2025
2045
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
2026
2046
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2027
2047
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
@@ -2786,10 +2806,10 @@ function preparePersona(personaDescription, tools, options) {
|
|
|
2786
2806
|
});
|
|
2787
2807
|
}
|
|
2788
2808
|
/**
|
|
2789
|
-
* TODO: [🔃][main]
|
|
2790
|
-
* TODO: [🏢]
|
|
2791
|
-
* TODO: [🏢]
|
|
2792
|
-
* TODO: [🏢]
|
|
2809
|
+
* TODO: [🔃][main] If the persona was prepared with different version or different set of models, prepare it once again
|
|
2810
|
+
* TODO: [🏢] Check validity of `modelName` in pipeline
|
|
2811
|
+
* TODO: [🏢] Check validity of `systemMessage` in pipeline
|
|
2812
|
+
* TODO: [🏢] Check validity of `temperature` in pipeline
|
|
2793
2813
|
*/
|
|
2794
2814
|
|
|
2795
2815
|
/**
|
|
@@ -3873,7 +3893,7 @@ function prepareTasks(pipeline, tools, options) {
|
|
|
3873
3893
|
* TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
|
|
3874
3894
|
* TODO: [🧠] Add context to each task (if missing)
|
|
3875
3895
|
* TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
|
|
3876
|
-
* TODO: [♨][main]
|
|
3896
|
+
* TODO: [♨][main] !!3 Prepare index the examples and maybe tasks
|
|
3877
3897
|
* TODO: Write tests for `preparePipeline`
|
|
3878
3898
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3879
3899
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -3936,17 +3956,10 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3936
3956
|
_d.tools = tools,
|
|
3937
3957
|
_d)]);
|
|
3938
3958
|
return [4 /*yield*/, prepareTitleExecutor({
|
|
3939
|
-
book: sources
|
|
3940
|
-
.map(function (_a) {
|
|
3959
|
+
book: sources.map(function (_a) {
|
|
3941
3960
|
var content = _a.content;
|
|
3942
3961
|
return content;
|
|
3943
|
-
})
|
|
3944
|
-
.join('\n\n')
|
|
3945
|
-
// TODO: !!!!!!! Parameters in parameters - DO NOT ALLOW, ESCAPE:
|
|
3946
|
-
.split('{')
|
|
3947
|
-
.join('[')
|
|
3948
|
-
.split('}')
|
|
3949
|
-
.join(']'),
|
|
3962
|
+
}).join('\n\n'),
|
|
3950
3963
|
})];
|
|
3951
3964
|
case 2:
|
|
3952
3965
|
result = _e.sent();
|
|
@@ -4614,6 +4627,8 @@ function templateParameters(template, parameters) {
|
|
|
4614
4627
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4615
4628
|
}
|
|
4616
4629
|
parameterValue = valueToString(parameterValue);
|
|
4630
|
+
// Escape curly braces in parameter values to prevent prompt-injection
|
|
4631
|
+
parameterValue = parameterValue.replace(/[{}]/g, '\\$&');
|
|
4617
4632
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
4618
4633
|
parameterValue = parameterValue
|
|
4619
4634
|
.split('\n')
|
|
@@ -4973,7 +4988,7 @@ function executeAttempts(options) {
|
|
|
4973
4988
|
promptTitle: task.title,
|
|
4974
4989
|
promptMessage: templateParameters(task.description || '', parameters),
|
|
4975
4990
|
defaultValue: templateParameters(preparedContent, parameters),
|
|
4976
|
-
// TODO: [🧠]
|
|
4991
|
+
// TODO: [🧠] Figure out how to define placeholder in .book.md file
|
|
4977
4992
|
placeholder: undefined,
|
|
4978
4993
|
priority: priority,
|
|
4979
4994
|
}))];
|
|
@@ -6058,12 +6073,12 @@ var MarkdownScraper = /** @class */ (function () {
|
|
|
6058
6073
|
outputParameters = result.outputParameters;
|
|
6059
6074
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
6060
6075
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
6061
|
-
// <- TODO: [main]
|
|
6076
|
+
// <- TODO: [main] Smarter split and filter out empty pieces
|
|
6062
6077
|
if (isVerbose) {
|
|
6063
6078
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
6064
6079
|
}
|
|
6065
6080
|
return [4 /*yield*/, Promise.all(
|
|
6066
|
-
// TODO: [🪂]
|
|
6081
|
+
// TODO: [🪂] Do not send all at once but in chunks
|
|
6067
6082
|
knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
|
|
6068
6083
|
var name, title, knowledgePieceContent, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
|
|
6069
6084
|
return __generator(this, function (_c) {
|