@promptbook/cli 0.63.0-3 → 0.63.0-5
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 -0
- package/esm/index.es.js +32 -7
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/config.d.ts +12 -0
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +1 -0
- package/esm/typings/src/types/execution-report/executionReportJsonToString.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +32 -7
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
package/esm/index.es.js
CHANGED
|
@@ -17,7 +17,7 @@ import glob from 'glob-promise';
|
|
|
17
17
|
/**
|
|
18
18
|
* The version of the Promptbook library
|
|
19
19
|
*/
|
|
20
|
-
var PROMPTBOOK_VERSION = '0.63.0-
|
|
20
|
+
var PROMPTBOOK_VERSION = '0.63.0-4';
|
|
21
21
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
22
22
|
|
|
23
23
|
/*! *****************************************************************************
|
|
@@ -279,6 +279,19 @@ function deepFreezeWithSameType(objectValue) {
|
|
|
279
279
|
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
280
280
|
*/
|
|
281
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Warning message for the generated sections and files files
|
|
284
|
+
*
|
|
285
|
+
* @private within the repository
|
|
286
|
+
*/
|
|
287
|
+
var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so that any manual changes will be overwritten";
|
|
288
|
+
/**
|
|
289
|
+
* Warning message for the generated sections and files files
|
|
290
|
+
*
|
|
291
|
+
* @private within the repository
|
|
292
|
+
*/
|
|
293
|
+
var GENERATOR_WARNING_BY_PROMPTBOOK_CLI = "\u26A0\uFE0F WARNING: This code has been generated by `@promptbook/cli` so that any manual changes will be overwritten";
|
|
294
|
+
// <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
|
|
282
295
|
/**
|
|
283
296
|
* The maximum number of iterations for a loops
|
|
284
297
|
*
|
|
@@ -593,6 +606,7 @@ function promptTemplateParameterJsonToString(promptTemplateParameterJson) {
|
|
|
593
606
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
594
607
|
* TODO: [🏛] Maybe make some markdown builder
|
|
595
608
|
* TODO: [🏛] Escape all
|
|
609
|
+
* TODO: [🧠] Should be in generated .ptbk.md file GENERATOR_WARNING
|
|
596
610
|
*/
|
|
597
611
|
|
|
598
612
|
/**
|
|
@@ -791,7 +805,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
791
805
|
});
|
|
792
806
|
}
|
|
793
807
|
|
|
794
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.63.0-
|
|
808
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.63.0-4",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-4",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.63.0-4",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-4",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.63.0-4",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-4",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.63.0-4",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-4",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
795
809
|
|
|
796
810
|
/**
|
|
797
811
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -5872,6 +5886,7 @@ function pipelineStringToJson(pipelineString, options) {
|
|
|
5872
5886
|
/**
|
|
5873
5887
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
5874
5888
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
5889
|
+
* TODO: [🧠] Should be in generated JSON file GENERATOR_WARNING
|
|
5875
5890
|
*/
|
|
5876
5891
|
|
|
5877
5892
|
/**
|
|
@@ -7829,23 +7844,33 @@ function initializeMakeCommand(program) {
|
|
|
7829
7844
|
});
|
|
7830
7845
|
}); };
|
|
7831
7846
|
if (!formats.includes('json')) return [3 /*break*/, 19];
|
|
7847
|
+
formats = formats.filter(function (format) { return format !== 'json'; });
|
|
7832
7848
|
return [4 /*yield*/, saveFile('json', collectionJsonString)];
|
|
7833
7849
|
case 18:
|
|
7834
7850
|
_f.sent();
|
|
7835
7851
|
_f.label = 19;
|
|
7836
7852
|
case 19:
|
|
7837
|
-
if (!formats.includes('javascript')) return [3 /*break*/, 21];
|
|
7838
|
-
|
|
7853
|
+
if (!(formats.includes('javascript') || formats.includes('js'))) return [3 /*break*/, 21];
|
|
7854
|
+
formats = formats.filter(function (format) { return format !== 'javascript' && format !== 'js'; });
|
|
7855
|
+
return [4 /*yield*/, saveFile('js', spaceTrim(function (block) {
|
|
7856
|
+
return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @private internal cache for `getPipelineCollection`\n */\n let pipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function getPipelineCollection(){\n if(pipelineCollection===null){\n pipelineCollection = createCollectionFromJson(").concat(collectionJsonString.substring(1, collectionJsonString.length - 1), ");\n }\n\n return pipelineCollection;\n }\n ") + '\n';
|
|
7857
|
+
}))];
|
|
7839
7858
|
case 20:
|
|
7840
7859
|
_f.sent();
|
|
7841
7860
|
_f.label = 21;
|
|
7842
7861
|
case 21:
|
|
7843
|
-
if (!formats.includes('typescript')) return [3 /*break*/, 23];
|
|
7844
|
-
|
|
7862
|
+
if (!(formats.includes('typescript') || formats.includes('ts'))) return [3 /*break*/, 23];
|
|
7863
|
+
formats = formats.filter(function (format) { return format !== 'typescript' && format !== 'ts'; });
|
|
7864
|
+
return [4 /*yield*/, saveFile('ts', spaceTrim(function (block) {
|
|
7865
|
+
return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n import type { PipelineCollection } from '@promptbook/types';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @private internal cache for `getPipelineCollection`\n */\n let pipelineCollection: null | PipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function getPipelineCollection(): PipelineCollection{\n if(pipelineCollection===null){\n pipelineCollection = createCollectionFromJson(").concat(collectionJsonString.substring(1, collectionJsonString.length - 1), ");\n }\n\n return pipelineCollection as PipelineCollection;\n }\n ") + '\n';
|
|
7866
|
+
}))];
|
|
7845
7867
|
case 22:
|
|
7846
7868
|
_f.sent();
|
|
7847
7869
|
_f.label = 23;
|
|
7848
7870
|
case 23:
|
|
7871
|
+
if (formats.length > 0) {
|
|
7872
|
+
console.warn(colors.yellow("Format ".concat(formats.join(' and '), " is not supported")));
|
|
7873
|
+
}
|
|
7849
7874
|
if (isVerbose) {
|
|
7850
7875
|
console.info(colors.green("Collection builded"));
|
|
7851
7876
|
console.info(colors.cyan(usageToHuman(llmTools.getTotalUsage())));
|
|
@@ -7868,7 +7893,7 @@ function initializeMakeCommand(program) {
|
|
|
7868
7893
|
*/
|
|
7869
7894
|
function addAutoGeneratedSection(content, options) {
|
|
7870
7895
|
var sectionName = options.sectionName, sectionContent = options.sectionContent;
|
|
7871
|
-
var warningLine = "<!--
|
|
7896
|
+
var warningLine = "<!-- ".concat(GENERATOR_WARNING, " -->");
|
|
7872
7897
|
var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
|
|
7873
7898
|
var sectionMatch = content.match(sectionRegex);
|
|
7874
7899
|
if (sectionMatch) {
|