@promptbook/markdown-utils 0.74.0-8 → 0.75.0-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 +2 -11
- package/esm/index.es.js +54 -32
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +3 -0
- package/esm/typings/src/_packages/core.index.d.ts +17 -1
- package/esm/typings/src/_packages/types.index.d.ts +10 -0
- 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/FORMFACTOR/FormfactorCommand.d.ts +11 -0
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommand.test.d.ts +1 -0
- package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +11 -0
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +2 -0
- package/esm/typings/src/commands/index.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/formfactors/_common/AbstractFormfactorDefinition.d.ts +29 -0
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +5 -0
- package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +5 -0
- package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +10 -0
- package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +10 -0
- package/esm/typings/src/formfactors/index.d.ts +14 -0
- package/esm/typings/src/pipeline/pipeline-interface/PipelineInterface.d.ts +22 -0
- package/esm/typings/src/pipeline/pipeline-interface/getPipelineInterface.d.ts +11 -0
- package/esm/typings/src/pipeline/pipeline-interface/isPipelineImplementingInterface.d.ts +25 -0
- package/esm/typings/src/pipeline/pipeline-interface/isPipelineInterfacesEqual.d.ts +11 -0
- 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 +11 -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 +1 -1
- package/umd/index.umd.js +54 -32
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Promisable } from 'type-fest';
|
|
2
|
-
import type { PromptbookStorage } from '
|
|
2
|
+
import type { PromptbookStorage } from '../_common/PromptbookStorage';
|
|
3
3
|
/**
|
|
4
4
|
* This class behaves like LocalStorage but separates keys by prefix
|
|
5
5
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { string_formfactor_name } from '../../formfactors/_common/string_formfactor_name';
|
|
1
2
|
import type { ModelRequirements } from '../ModelRequirements';
|
|
2
3
|
import type { string_filename } from '../typeAliases';
|
|
3
4
|
import type { string_markdown_text } from '../typeAliases';
|
|
@@ -26,12 +27,12 @@ export type PipelineJson = {
|
|
|
26
27
|
* Note: It must be unique across all pipeline collections
|
|
27
28
|
* Note: It must use HTTPs URL
|
|
28
29
|
* Tip: You can do versioning in the URL
|
|
29
|
-
* For example: https://promptbook.studio/webgpt/write-website-content-cs.
|
|
30
|
+
* For example: https://promptbook.studio/webgpt/write-website-content-cs.book.md@1.0.0
|
|
30
31
|
* Warning: Do not hash part of the URL, hash part is used for identification of the template in the pipeline
|
|
31
32
|
*/
|
|
32
33
|
readonly pipelineUrl?: string_pipeline_url;
|
|
33
34
|
/**
|
|
34
|
-
* Internal helper for tracking the source `.
|
|
35
|
+
* Internal helper for tracking the source `.book.md` file of the pipeline
|
|
35
36
|
*/
|
|
36
37
|
readonly sourceFile?: string_filename;
|
|
37
38
|
/**
|
|
@@ -40,14 +41,20 @@ export type PipelineJson = {
|
|
|
40
41
|
*/
|
|
41
42
|
readonly title: string_markdown_text;
|
|
42
43
|
/**
|
|
43
|
-
* Version of the
|
|
44
|
+
* Version of the Book language
|
|
45
|
+
*
|
|
46
|
+
* @see https://github.com/webgptorg/book
|
|
44
47
|
*/
|
|
45
|
-
readonly
|
|
48
|
+
readonly bookVersion?: string_semantic_version;
|
|
46
49
|
/**
|
|
47
50
|
* Description of the promptbook
|
|
48
51
|
* It can use multiple paragraphs of simple markdown formatting like **bold**, *italic*, [link](https://example.com), ... BUT not code blocks and structure
|
|
49
52
|
*/
|
|
50
53
|
readonly description?: string_markdown_text;
|
|
54
|
+
/**
|
|
55
|
+
* Name of the formfactor that the pipeline is shaped for
|
|
56
|
+
*/
|
|
57
|
+
readonly formfactorName: string_formfactor_name;
|
|
51
58
|
/**
|
|
52
59
|
* Set of variables that are used across the pipeline
|
|
53
60
|
*/
|
|
@@ -18,5 +18,5 @@ export type PreparationJson = {
|
|
|
18
18
|
/**
|
|
19
19
|
* TODO: [🍙] Make some standard order of json properties
|
|
20
20
|
* TODO: Maybe put here used `modelName`
|
|
21
|
-
* TODO: [🍥] When using `date` it changes all examples .
|
|
21
|
+
* TODO: [🍥] When using `date` it changes all examples .book.json files each time so until some more elegant solution omit the time from prepared pipeline
|
|
22
22
|
*/
|
|
@@ -95,7 +95,7 @@ export type CommonPrompt = {
|
|
|
95
95
|
/**
|
|
96
96
|
* Unique identifier of the pipeline with specific template name as hash
|
|
97
97
|
*
|
|
98
|
-
* @example https://promptbook.studio/webgpt/write-website-content-cs.
|
|
98
|
+
* @example https://promptbook.studio/webgpt/write-website-content-cs.book.md#keywords
|
|
99
99
|
*/
|
|
100
100
|
readonly pipelineUrl?: string_pipeline_url_with_hashtemplate;
|
|
101
101
|
/**
|
|
@@ -298,13 +298,13 @@ export type string_base_url = string;
|
|
|
298
298
|
/**
|
|
299
299
|
* Semantic helper
|
|
300
300
|
*
|
|
301
|
-
* For example `"https://promptbook.studio/webgpt/write-website-content-cs.
|
|
301
|
+
* For example `"https://promptbook.studio/webgpt/write-website-content-cs.book.md"`
|
|
302
302
|
*/
|
|
303
303
|
export type string_pipeline_url = string;
|
|
304
304
|
/**
|
|
305
305
|
* Semantic helper
|
|
306
306
|
*
|
|
307
|
-
* For example `"https://promptbook.studio/webgpt/write-website-content-cs.
|
|
307
|
+
* For example `"https://promptbook.studio/webgpt/write-website-content-cs.book.md#keywords"`
|
|
308
308
|
*/
|
|
309
309
|
export type string_pipeline_url_with_hashtemplate = string;
|
|
310
310
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Number of characters per standard line with 11pt Arial font size.
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/utils`
|
|
5
|
+
*/
|
|
6
|
+
export declare const CHARACTERS_PER_STANDARD_LINE = 63;
|
|
7
|
+
/**
|
|
8
|
+
* Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
|
|
9
|
+
*
|
|
10
|
+
* @public exported from `@promptbook/utils`
|
|
11
|
+
*/
|
|
12
|
+
export declare const LINES_PER_STANDARD_PAGE = 44;
|
|
@@ -2,6 +2,8 @@ import type { ExpectationAmount } from '../../types/PipelineJson/Expectations';
|
|
|
2
2
|
/**
|
|
3
3
|
* Counts number of lines in the text
|
|
4
4
|
*
|
|
5
|
+
* Note: This does not check only for the presence of newlines, but also for the length of the standard line.
|
|
6
|
+
*
|
|
5
7
|
* @public exported from `@promptbook/utils`
|
|
6
8
|
*/
|
|
7
9
|
export declare function countLines(text: string): ExpectationAmount;
|
|
@@ -2,6 +2,8 @@ import type { ExpectationAmount } from '../../types/PipelineJson/Expectations';
|
|
|
2
2
|
/**
|
|
3
3
|
* Counts number of pages in the text
|
|
4
4
|
*
|
|
5
|
+
* 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.
|
|
6
|
+
*
|
|
5
7
|
* @public exported from `@promptbook/utils`
|
|
6
8
|
*/
|
|
7
9
|
export declare function countPages(text: string): ExpectationAmount;
|
package/package.json
CHANGED
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
|
*/
|
|
@@ -357,7 +357,7 @@
|
|
|
357
357
|
* TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
|
|
358
358
|
*/
|
|
359
359
|
|
|
360
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.
|
|
360
|
+
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}],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",formfactorName:"GENERIC",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",formfactorName:"GENERIC",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",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}],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"}];
|
|
361
361
|
|
|
362
362
|
/**
|
|
363
363
|
* Prettify the html code
|
|
@@ -396,13 +396,13 @@
|
|
|
396
396
|
/**
|
|
397
397
|
* Converts promptbook in JSON format to string format
|
|
398
398
|
*
|
|
399
|
-
* @param pipelineJson Promptbook in JSON format (.
|
|
400
|
-
* @returns Promptbook in string format (.
|
|
399
|
+
* @param pipelineJson Promptbook in JSON format (.book.json)
|
|
400
|
+
* @returns Promptbook in string format (.book.md)
|
|
401
401
|
* @public exported from `@promptbook/core`
|
|
402
402
|
*/
|
|
403
403
|
function pipelineJsonToString(pipelineJson) {
|
|
404
404
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
405
|
-
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl,
|
|
405
|
+
var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
|
|
406
406
|
var pipelineString = "# ".concat(title);
|
|
407
407
|
if (description) {
|
|
408
408
|
pipelineString += '\n\n';
|
|
@@ -412,8 +412,10 @@
|
|
|
412
412
|
if (pipelineUrl) {
|
|
413
413
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
414
414
|
}
|
|
415
|
-
|
|
416
|
-
|
|
415
|
+
if (bookVersion !== "undefined") {
|
|
416
|
+
commands.push("BOOK VERSION ".concat(bookVersion));
|
|
417
|
+
}
|
|
418
|
+
// TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
|
|
417
419
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
418
420
|
try {
|
|
419
421
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -593,7 +595,7 @@
|
|
|
593
595
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
594
596
|
* TODO: [🏛] Maybe make some markdown builder
|
|
595
597
|
* TODO: [🏛] Escape all
|
|
596
|
-
* TODO: [🧠] Should be in generated .
|
|
598
|
+
* TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
|
|
597
599
|
*/
|
|
598
600
|
|
|
599
601
|
/**
|
|
@@ -815,6 +817,13 @@
|
|
|
815
817
|
* @private within the repository
|
|
816
818
|
*/
|
|
817
819
|
var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so that any manual changes will be overwritten";
|
|
820
|
+
// <- TODO: [🐊] Pick the best claim
|
|
821
|
+
/**
|
|
822
|
+
* When the title is not provided, the default title is used
|
|
823
|
+
*
|
|
824
|
+
* @public exported from `@promptbook/core`
|
|
825
|
+
*/
|
|
826
|
+
var DEFAULT_TITLE = "Untitled";
|
|
818
827
|
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
819
828
|
/**
|
|
820
829
|
* The maximum number of iterations for a loops
|
|
@@ -1060,7 +1069,7 @@
|
|
|
1060
1069
|
if (!url.startsWith('https://')) {
|
|
1061
1070
|
return false;
|
|
1062
1071
|
}
|
|
1063
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.
|
|
1072
|
+
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
1064
1073
|
return false;
|
|
1065
1074
|
}
|
|
1066
1075
|
if (url.includes('#')) {
|
|
@@ -1129,9 +1138,9 @@
|
|
|
1129
1138
|
// <- Note: [🚲]
|
|
1130
1139
|
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1131
1140
|
}
|
|
1132
|
-
if (pipeline.
|
|
1141
|
+
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
1133
1142
|
// <- Note: [🚲]
|
|
1134
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.
|
|
1143
|
+
throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
1135
1144
|
}
|
|
1136
1145
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
1137
1146
|
if (!Array.isArray(pipeline.parameters)) {
|
|
@@ -2780,7 +2789,7 @@
|
|
|
2780
2789
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
2781
2790
|
_b = createPipelineExecutor;
|
|
2782
2791
|
_c = {};
|
|
2783
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.
|
|
2792
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
|
|
2784
2793
|
case 1:
|
|
2785
2794
|
preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
|
|
2786
2795
|
_c.tools = tools,
|
|
@@ -3452,13 +3461,14 @@
|
|
|
3452
3461
|
*/
|
|
3453
3462
|
function clonePipeline(pipeline) {
|
|
3454
3463
|
// Note: Not using spread operator (...) because @@@
|
|
3455
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title,
|
|
3464
|
+
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
|
|
3456
3465
|
return {
|
|
3457
3466
|
pipelineUrl: pipelineUrl,
|
|
3458
3467
|
sourceFile: sourceFile,
|
|
3459
3468
|
title: title,
|
|
3460
|
-
|
|
3469
|
+
bookVersion: bookVersion,
|
|
3461
3470
|
description: description,
|
|
3471
|
+
formfactorName: formfactorName,
|
|
3462
3472
|
parameters: parameters,
|
|
3463
3473
|
templates: templates,
|
|
3464
3474
|
knowledgeSources: knowledgeSources,
|
|
@@ -4265,30 +4275,42 @@
|
|
|
4265
4275
|
return text.length;
|
|
4266
4276
|
}
|
|
4267
4277
|
|
|
4278
|
+
/**
|
|
4279
|
+
* Number of characters per standard line with 11pt Arial font size.
|
|
4280
|
+
*
|
|
4281
|
+
* @public exported from `@promptbook/utils`
|
|
4282
|
+
*/
|
|
4283
|
+
var CHARACTERS_PER_STANDARD_LINE = 63;
|
|
4284
|
+
/**
|
|
4285
|
+
* Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
|
|
4286
|
+
*
|
|
4287
|
+
* @public exported from `@promptbook/utils`
|
|
4288
|
+
*/
|
|
4289
|
+
var LINES_PER_STANDARD_PAGE = 44;
|
|
4290
|
+
|
|
4268
4291
|
/**
|
|
4269
4292
|
* Counts number of lines in the text
|
|
4270
4293
|
*
|
|
4294
|
+
* Note: This does not check only for the presence of newlines, but also for the length of the standard line.
|
|
4295
|
+
*
|
|
4271
4296
|
* @public exported from `@promptbook/utils`
|
|
4272
4297
|
*/
|
|
4273
4298
|
function countLines(text) {
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
return
|
|
4299
|
+
text = text.replace('\r\n', '\n');
|
|
4300
|
+
text = text.replace('\r', '\n');
|
|
4301
|
+
var lines = text.split('\n');
|
|
4302
|
+
return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
|
|
4278
4303
|
}
|
|
4279
4304
|
|
|
4280
4305
|
/**
|
|
4281
4306
|
* Counts number of pages in the text
|
|
4282
4307
|
*
|
|
4308
|
+
* 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.
|
|
4309
|
+
*
|
|
4283
4310
|
* @public exported from `@promptbook/utils`
|
|
4284
4311
|
*/
|
|
4285
4312
|
function countPages(text) {
|
|
4286
|
-
|
|
4287
|
-
return 0;
|
|
4288
|
-
}
|
|
4289
|
-
var pagesByLinesCount = Math.ceil(countLines(text) / 44);
|
|
4290
|
-
var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
|
|
4291
|
-
return Math.max(pagesByLinesCount, pagesByCharactersCount);
|
|
4313
|
+
return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
|
|
4292
4314
|
}
|
|
4293
4315
|
|
|
4294
4316
|
/**
|
|
@@ -4568,7 +4590,7 @@
|
|
|
4568
4590
|
promptTitle: template.title,
|
|
4569
4591
|
promptMessage: replaceParameters(template.description || '', parameters),
|
|
4570
4592
|
defaultValue: replaceParameters(preparedContent, parameters),
|
|
4571
|
-
// TODO: [🧠] !! Figure out how to define placeholder in .
|
|
4593
|
+
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
4572
4594
|
placeholder: undefined,
|
|
4573
4595
|
priority: priority,
|
|
4574
4596
|
}))];
|
|
@@ -5134,7 +5156,7 @@
|
|
|
5134
5156
|
pipelineUrl: preparedPipeline.pipelineUrl,
|
|
5135
5157
|
title: preparedPipeline.title,
|
|
5136
5158
|
promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
5137
|
-
promptbookRequestedVersion: preparedPipeline.
|
|
5159
|
+
promptbookRequestedVersion: preparedPipeline.bookVersion,
|
|
5138
5160
|
description: preparedPipeline.description,
|
|
5139
5161
|
promptExecutions: [],
|
|
5140
5162
|
};
|
|
@@ -5530,7 +5552,7 @@
|
|
|
5530
5552
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
5531
5553
|
_d = createPipelineExecutor;
|
|
5532
5554
|
_g = {};
|
|
5533
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.
|
|
5555
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md')];
|
|
5534
5556
|
case 1:
|
|
5535
5557
|
prepareKnowledgeFromMarkdownExecutor = _d.apply(void 0, [(_g.pipeline = _k.sent(),
|
|
5536
5558
|
_g.tools = {
|
|
@@ -5539,7 +5561,7 @@
|
|
|
5539
5561
|
_g)]);
|
|
5540
5562
|
_e = createPipelineExecutor;
|
|
5541
5563
|
_h = {};
|
|
5542
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.
|
|
5564
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.book.md')];
|
|
5543
5565
|
case 2:
|
|
5544
5566
|
prepareTitleExecutor = _e.apply(void 0, [(_h.pipeline = _k.sent(),
|
|
5545
5567
|
_h.tools = {
|
|
@@ -5548,7 +5570,7 @@
|
|
|
5548
5570
|
_h)]);
|
|
5549
5571
|
_f = createPipelineExecutor;
|
|
5550
5572
|
_j = {};
|
|
5551
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.
|
|
5573
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md')];
|
|
5552
5574
|
case 3:
|
|
5553
5575
|
prepareKeywordsExecutor = _f.apply(void 0, [(_j.pipeline = _k.sent(),
|
|
5554
5576
|
_j.tools = {
|
|
@@ -5906,7 +5928,7 @@
|
|
|
5906
5928
|
return;
|
|
5907
5929
|
}
|
|
5908
5930
|
if (!section.startsWith('#')) {
|
|
5909
|
-
section = "#
|
|
5931
|
+
section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
|
|
5910
5932
|
}
|
|
5911
5933
|
sections.push(section);
|
|
5912
5934
|
buffer = [];
|
|
@@ -5970,7 +5992,7 @@
|
|
|
5970
5992
|
var e_1, _a;
|
|
5971
5993
|
var sections = splitMarkdownIntoSections(markdown);
|
|
5972
5994
|
if (sections.length === 0) {
|
|
5973
|
-
return
|
|
5995
|
+
return "# ".concat(DEFAULT_TITLE);
|
|
5974
5996
|
}
|
|
5975
5997
|
var flattenedMarkdown = '';
|
|
5976
5998
|
var parsedSections = sections.map(parseMarkdownSection);
|
|
@@ -5981,7 +6003,7 @@
|
|
|
5981
6003
|
}
|
|
5982
6004
|
else {
|
|
5983
6005
|
parsedSections.unshift(firstSection);
|
|
5984
|
-
flattenedMarkdown += "#
|
|
6006
|
+
flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
|
|
5985
6007
|
}
|
|
5986
6008
|
try {
|
|
5987
6009
|
for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
|