@promptbook/pdf 0.74.0-7 → 0.74.0
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 -15
- package/esm/index.es.js +43 -27
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +5 -1
- package/esm/typings/src/_packages/utils.index.d.ts +4 -0
- package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
- package/esm/typings/src/cli/main.d.ts +4 -1
- package/esm/typings/src/cli/promptbookCli.d.ts +1 -1
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/collection/collectionToJson.test.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
- package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -2
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
- package/esm/typings/src/config.d.ts +6 -0
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -3
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +7 -7
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
- package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +1 -1
- package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
- package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +6 -4
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +2 -2
- package/esm/typings/src/utils/expectation-counters/config.d.ts +12 -0
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
- package/package.json +2 -2
- package/umd/index.umd.js +43 -27
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
|
24
24
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.74.0-13';
|
|
26
26
|
/**
|
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
28
|
*/
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
function TODO_USE() {
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.
|
|
178
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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\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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",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}],templates:[{templateType:"PROMPT_TEMPLATE",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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.book.md"}];
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* Prettify the html code
|
|
@@ -223,13 +223,13 @@
|
|
|
223
223
|
/**
|
|
224
224
|
* Converts promptbook in JSON format to string format
|
|
225
225
|
*
|
|
226
|
-
* @param pipelineJson Promptbook in JSON format (.
|
|
227
|
-
* @returns Promptbook in string format (.
|
|
226
|
+
* @param pipelineJson Promptbook in JSON format (.book.json)
|
|
227
|
+
* @returns Promptbook in string format (.book.md)
|
|
228
228
|
* @public exported from `@promptbook/core`
|
|
229
229
|
*/
|
|
230
230
|
function pipelineJsonToString(pipelineJson) {
|
|
231
231
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
232
|
-
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl,
|
|
232
|
+
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
|
|
233
233
|
var pipelineString = "# ".concat(title);
|
|
234
234
|
if (description) {
|
|
235
235
|
pipelineString += '\n\n';
|
|
@@ -239,8 +239,10 @@
|
|
|
239
239
|
if (pipelineUrl) {
|
|
240
240
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
241
241
|
}
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
if (bookVersion !== "undefined") {
|
|
243
|
+
commands.push("BOOK VERSION ".concat(bookVersion));
|
|
244
|
+
}
|
|
245
|
+
// TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
|
|
244
246
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
245
247
|
try {
|
|
246
248
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -420,7 +422,7 @@
|
|
|
420
422
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
421
423
|
* TODO: [🏛] Maybe make some markdown builder
|
|
422
424
|
* TODO: [🏛] Escape all
|
|
423
|
-
* TODO: [🧠] Should be in generated .
|
|
425
|
+
* TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
|
|
424
426
|
*/
|
|
425
427
|
|
|
426
428
|
/**
|
|
@@ -900,7 +902,7 @@
|
|
|
900
902
|
if (!url.startsWith('https://')) {
|
|
901
903
|
return false;
|
|
902
904
|
}
|
|
903
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.
|
|
905
|
+
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
904
906
|
return false;
|
|
905
907
|
}
|
|
906
908
|
if (url.includes('#')) {
|
|
@@ -969,9 +971,9 @@
|
|
|
969
971
|
// <- Note: [🚲]
|
|
970
972
|
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
971
973
|
}
|
|
972
|
-
if (pipeline.
|
|
974
|
+
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
973
975
|
// <- Note: [🚲]
|
|
974
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.
|
|
976
|
+
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
975
977
|
}
|
|
976
978
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
977
979
|
if (!Array.isArray(pipeline.parameters)) {
|
|
@@ -2604,7 +2606,7 @@
|
|
|
2604
2606
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
2605
2607
|
_b = createPipelineExecutor;
|
|
2606
2608
|
_c = {};
|
|
2607
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.
|
|
2609
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
|
|
2608
2610
|
case 1:
|
|
2609
2611
|
preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
|
|
2610
2612
|
_c.tools = tools,
|
|
@@ -3276,12 +3278,12 @@
|
|
|
3276
3278
|
*/
|
|
3277
3279
|
function clonePipeline(pipeline) {
|
|
3278
3280
|
// Note: Not using spread operator (...) because @@@
|
|
3279
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title,
|
|
3281
|
+
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
|
|
3280
3282
|
return {
|
|
3281
3283
|
pipelineUrl: pipelineUrl,
|
|
3282
3284
|
sourceFile: sourceFile,
|
|
3283
3285
|
title: title,
|
|
3284
|
-
|
|
3286
|
+
bookVersion: bookVersion,
|
|
3285
3287
|
description: description,
|
|
3286
3288
|
parameters: parameters,
|
|
3287
3289
|
templates: templates,
|
|
@@ -4226,28 +4228,42 @@
|
|
|
4226
4228
|
return text.length;
|
|
4227
4229
|
}
|
|
4228
4230
|
|
|
4231
|
+
/**
|
|
4232
|
+
* Number of characters per standard line with 11pt Arial font size.
|
|
4233
|
+
*
|
|
4234
|
+
* @public exported from `@promptbook/utils`
|
|
4235
|
+
*/
|
|
4236
|
+
var CHARACTERS_PER_STANDARD_LINE = 63;
|
|
4237
|
+
/**
|
|
4238
|
+
* Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
|
|
4239
|
+
*
|
|
4240
|
+
* @public exported from `@promptbook/utils`
|
|
4241
|
+
*/
|
|
4242
|
+
var LINES_PER_STANDARD_PAGE = 44;
|
|
4243
|
+
|
|
4229
4244
|
/**
|
|
4230
4245
|
* Counts number of lines in the text
|
|
4231
4246
|
*
|
|
4247
|
+
* Note: This does not check only for the presence of newlines, but also for the length of the standard line.
|
|
4248
|
+
*
|
|
4232
4249
|
* @public exported from `@promptbook/utils`
|
|
4233
4250
|
*/
|
|
4234
4251
|
function countLines(text) {
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
return
|
|
4252
|
+
text = text.replace('\r\n', '\n');
|
|
4253
|
+
text = text.replace('\r', '\n');
|
|
4254
|
+
var lines = text.split('\n');
|
|
4255
|
+
return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
|
|
4239
4256
|
}
|
|
4240
4257
|
|
|
4241
4258
|
/**
|
|
4242
4259
|
* Counts number of pages in the text
|
|
4243
4260
|
*
|
|
4261
|
+
* Note: This does not check only for the count of newlines, but also for the length of the standard line and length of the standard page.
|
|
4262
|
+
*
|
|
4244
4263
|
* @public exported from `@promptbook/utils`
|
|
4245
4264
|
*/
|
|
4246
4265
|
function countPages(text) {
|
|
4247
|
-
|
|
4248
|
-
var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
|
|
4249
|
-
var pageCount = Math.ceil(sentences.length / sentencesPerPage);
|
|
4250
|
-
return pageCount;
|
|
4266
|
+
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
4251
4267
|
}
|
|
4252
4268
|
|
|
4253
4269
|
/**
|
|
@@ -4527,7 +4543,7 @@
|
|
|
4527
4543
|
promptTitle: template.title,
|
|
4528
4544
|
promptMessage: replaceParameters(template.description || '', parameters),
|
|
4529
4545
|
defaultValue: replaceParameters(preparedContent, parameters),
|
|
4530
|
-
// TODO: [🧠] !! Figure out how to define placeholder in .
|
|
4546
|
+
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
4531
4547
|
placeholder: undefined,
|
|
4532
4548
|
priority: priority,
|
|
4533
4549
|
}))];
|
|
@@ -5093,7 +5109,7 @@
|
|
|
5093
5109
|
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
5094
5110
|
title: preparedPipeline.title,
|
|
5095
5111
|
promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
5096
|
-
promptbookRequestedVersion: preparedPipeline.
|
|
5112
|
+
promptbookRequestedVersion: preparedPipeline.bookVersion,
|
|
5097
5113
|
description: preparedPipeline.description,
|
|
5098
5114
|
promptExecutions: [],
|
|
5099
5115
|
};
|
|
@@ -5489,7 +5505,7 @@
|
|
|
5489
5505
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
5490
5506
|
_d = createPipelineExecutor;
|
|
5491
5507
|
_g = {};
|
|
5492
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.
|
|
5508
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md')];
|
|
5493
5509
|
case 1:
|
|
5494
5510
|
prepareKnowledgeFromMarkdownExecutor = _d.apply(void 0, [(_g.pipeline = _k.sent(),
|
|
5495
5511
|
_g.tools = {
|
|
@@ -5498,7 +5514,7 @@
|
|
|
5498
5514
|
_g)]);
|
|
5499
5515
|
_e = createPipelineExecutor;
|
|
5500
5516
|
_h = {};
|
|
5501
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.
|
|
5517
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.book.md')];
|
|
5502
5518
|
case 2:
|
|
5503
5519
|
prepareTitleExecutor = _e.apply(void 0, [(_h.pipeline = _k.sent(),
|
|
5504
5520
|
_h.tools = {
|
|
@@ -5507,7 +5523,7 @@
|
|
|
5507
5523
|
_h)]);
|
|
5508
5524
|
_f = createPipelineExecutor;
|
|
5509
5525
|
_j = {};
|
|
5510
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.
|
|
5526
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md')];
|
|
5511
5527
|
case 3:
|
|
5512
5528
|
prepareKeywordsExecutor = _f.apply(void 0, [(_j.pipeline = _k.sent(),
|
|
5513
5529
|
_j.tools = {
|