@promptbook/core 0.61.0-26 → 0.61.0-28
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/esm/index.es.js +29 -29
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +0 -1
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +6 -6
- package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -1
- package/esm/typings/src/execution/PromptResult.d.ts +15 -0
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +3 -3
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +2 -2
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +3 -3
- package/esm/typings/src/prepare/preparePipeline.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
- package/esm/typings/src/types/ModelRequirements.d.ts +1 -1
- package/esm/typings/src/utils/extractParameterNames.d.ts +0 -3
- package/package.json +1 -1
- package/umd/index.umd.js +29 -29
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +0 -1
- package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
- package/umd/typings/src/conversion/validation/validatePipeline.d.ts +6 -6
- package/umd/typings/src/execution/PipelineExecutor.d.ts +1 -1
- package/umd/typings/src/execution/PromptResult.d.ts +15 -0
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +3 -3
- package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +2 -2
- package/umd/typings/src/prepare/isPipelinePrepared.d.ts +3 -3
- package/umd/typings/src/prepare/preparePipeline.d.ts +1 -1
- package/umd/typings/src/prepare/prepareTemplates.d.ts +1 -1
- package/umd/typings/src/types/ModelRequirements.d.ts +1 -1
- package/umd/typings/src/utils/extractParameterNames.d.ts +0 -3
package/esm/index.es.js
CHANGED
|
@@ -575,7 +575,7 @@ function isValidPromptbookVersion(version) {
|
|
|
575
575
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
576
576
|
return false;
|
|
577
577
|
}
|
|
578
|
-
// <- TODO:
|
|
578
|
+
// <- TODO: !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
579
579
|
return true;
|
|
580
580
|
}
|
|
581
581
|
|
|
@@ -915,12 +915,12 @@ function validatePipeline(pipeline) {
|
|
|
915
915
|
* > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
|
|
916
916
|
*/
|
|
917
917
|
/**
|
|
918
|
-
* TODO: [
|
|
919
|
-
* TODO: [
|
|
920
|
-
* TODO: [
|
|
921
|
-
* TODO: !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
|
|
922
|
-
* TODO: !!!! Validate that reserved parameter is not used as joker
|
|
923
|
-
* TODO: [🧠]
|
|
918
|
+
* TODO: [🐣] !!!! Validate that all samples match expectations
|
|
919
|
+
* TODO: [🐣][🐝] !!!! Validate that knowledge is valid (non-void)
|
|
920
|
+
* TODO: [🐣] !!!! Validate that persona can be used only with CHAT variant
|
|
921
|
+
* TODO: [🐣] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
|
|
922
|
+
* TODO: [🐣] !!!! Validate that reserved parameter is not used as joker
|
|
923
|
+
* TODO: [🧠] Validation not only logic itself but imports around - files and websites and rerefenced pipelines exists
|
|
924
924
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
925
925
|
*/
|
|
926
926
|
|
|
@@ -978,9 +978,6 @@ function extractParameterNames(template) {
|
|
|
978
978
|
}
|
|
979
979
|
return parameterNames;
|
|
980
980
|
}
|
|
981
|
-
/**
|
|
982
|
-
* TODO: !!!!! Rename to extractParameterNames
|
|
983
|
-
*/
|
|
984
981
|
|
|
985
982
|
/**
|
|
986
983
|
* Unprepare just strips the preparation data of the pipeline
|
|
@@ -1520,7 +1517,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1520
1517
|
});
|
|
1521
1518
|
}
|
|
1522
1519
|
|
|
1523
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
1520
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-27",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.61.0-27",modelUsage:{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.61.0-27",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.61.0-27",modelUsage:{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.61.0-27",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.61.0-27",modelUsage:{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.61.0-27",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.61.0-27",modelUsage:{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"}];
|
|
1524
1521
|
|
|
1525
1522
|
var defaultDiacriticsRemovalMap = [
|
|
1526
1523
|
{
|
|
@@ -2032,7 +2029,7 @@ var ExpectError = /** @class */ (function (_super) {
|
|
|
2032
2029
|
/**
|
|
2033
2030
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
2034
2031
|
*/
|
|
2035
|
-
function isValidJsonString(value /* <-[👨⚖️] */) {
|
|
2032
|
+
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
2036
2033
|
try {
|
|
2037
2034
|
JSON.parse(value);
|
|
2038
2035
|
return true;
|
|
@@ -2316,9 +2313,9 @@ function isPipelinePrepared(pipeline) {
|
|
|
2316
2313
|
* TODO: [🔼] Export via core or utils
|
|
2317
2314
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2318
2315
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2319
|
-
* - Is context in each template
|
|
2320
|
-
* - Are samples prepared
|
|
2321
|
-
* - Are templates prepared
|
|
2316
|
+
* - [🏍] ? Is context in each template
|
|
2317
|
+
* - [♨] Are samples prepared
|
|
2318
|
+
* - [♨] Are templates prepared
|
|
2322
2319
|
*/
|
|
2323
2320
|
|
|
2324
2321
|
/**
|
|
@@ -2525,7 +2522,7 @@ function union() {
|
|
|
2525
2522
|
/**
|
|
2526
2523
|
* The version of the Promptbook library
|
|
2527
2524
|
*/
|
|
2528
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2525
|
+
var PROMPTBOOK_VERSION = '0.61.0-27';
|
|
2529
2526
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2530
2527
|
|
|
2531
2528
|
/**
|
|
@@ -2676,7 +2673,7 @@ function createPipelineExecutor(options) {
|
|
|
2676
2673
|
pipeline = rawPipeline;
|
|
2677
2674
|
}
|
|
2678
2675
|
else {
|
|
2679
|
-
// TODO:
|
|
2676
|
+
// TODO: !!!!! This should be maybe warning in report
|
|
2680
2677
|
console.warn(spaceTrim$1("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\n\n ").concat(rawPipeline.sourceFile, "\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
|
|
2681
2678
|
}
|
|
2682
2679
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -2686,7 +2683,7 @@ function createPipelineExecutor(options) {
|
|
|
2686
2683
|
return __awaiter(this, void 0, void 0, function () {
|
|
2687
2684
|
return __generator(this, function (_a) {
|
|
2688
2685
|
TODO_USE(template);
|
|
2689
|
-
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO:
|
|
2686
|
+
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
|
|
2690
2687
|
});
|
|
2691
2688
|
});
|
|
2692
2689
|
}
|
|
@@ -2694,7 +2691,7 @@ function createPipelineExecutor(options) {
|
|
|
2694
2691
|
template) {
|
|
2695
2692
|
return __awaiter(this, void 0, void 0, function () {
|
|
2696
2693
|
return __generator(this, function (_a) {
|
|
2697
|
-
// TODO:
|
|
2694
|
+
// TODO: [♨] Implement Better - use real index and keyword search
|
|
2698
2695
|
TODO_USE(template);
|
|
2699
2696
|
return [2 /*return*/, pipeline.knowledgePieces.map(function (_a) {
|
|
2700
2697
|
var content = _a.content;
|
|
@@ -2707,9 +2704,9 @@ function createPipelineExecutor(options) {
|
|
|
2707
2704
|
template) {
|
|
2708
2705
|
return __awaiter(this, void 0, void 0, function () {
|
|
2709
2706
|
return __generator(this, function (_a) {
|
|
2710
|
-
// TODO:
|
|
2707
|
+
// TODO: [♨] Implement Better - use real index and keyword search
|
|
2711
2708
|
TODO_USE(template);
|
|
2712
|
-
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO:
|
|
2709
|
+
return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
|
|
2713
2710
|
});
|
|
2714
2711
|
});
|
|
2715
2712
|
}
|
|
@@ -3435,8 +3432,8 @@ function createPipelineExecutor(options) {
|
|
|
3435
3432
|
return pipelineExecutor;
|
|
3436
3433
|
}
|
|
3437
3434
|
/**
|
|
3438
|
-
* TODO:
|
|
3439
|
-
* TODO:
|
|
3435
|
+
* TODO: !!!!! return `preparedPipeline` from execution
|
|
3436
|
+
* TODO: !!!!! `isNotPreparedWarningSupressed`
|
|
3440
3437
|
* TODO: Use isVerbose here (not only pass to `preparePipeline`)
|
|
3441
3438
|
* TODO: [🪂] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
3442
3439
|
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
@@ -3445,7 +3442,7 @@ function createPipelineExecutor(options) {
|
|
|
3445
3442
|
* Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
|
|
3446
3443
|
* TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
|
|
3447
3444
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3448
|
-
* TODO: [💷]
|
|
3445
|
+
* TODO: [🧠][💷] `assertsExecutionSuccessful` should be the method of `PipelineExecutor` result BUT maybe NOT to preserve pure JSON object
|
|
3449
3446
|
*/
|
|
3450
3447
|
|
|
3451
3448
|
/**
|
|
@@ -3721,7 +3718,7 @@ function prepareTemplates(pipeline, options) {
|
|
|
3721
3718
|
case 0:
|
|
3722
3719
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
|
|
3723
3720
|
promptTemplates = pipeline.promptTemplates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3724
|
-
// TODO:
|
|
3721
|
+
// TODO: !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
3725
3722
|
TODO_USE(parameters);
|
|
3726
3723
|
promptTemplatesPrepared = new Array(promptTemplates.length);
|
|
3727
3724
|
return [4 /*yield*/, forEachAsync(promptTemplates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -3751,7 +3748,7 @@ function prepareTemplates(pipeline, options) {
|
|
|
3751
3748
|
/**
|
|
3752
3749
|
* TODO: [🧠] Add context to each template (if missing)
|
|
3753
3750
|
* TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
|
|
3754
|
-
* TODO:
|
|
3751
|
+
* TODO: [♨] !!! Prepare index the samples and maybe templates
|
|
3755
3752
|
* TODO: [🔼] !!! Export via `@promptbook/core`
|
|
3756
3753
|
* TODO: Write tests for `preparePipeline`
|
|
3757
3754
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
@@ -3830,7 +3827,7 @@ function preparePipeline(pipeline, options) {
|
|
|
3830
3827
|
* TODO: Write tests for `preparePipeline`
|
|
3831
3828
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3832
3829
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
3833
|
-
* TODO: [🎐]
|
|
3830
|
+
* TODO: [🎐] !!!!! Use here countTotalUsage
|
|
3834
3831
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3835
3832
|
*/
|
|
3836
3833
|
|
|
@@ -5970,7 +5967,7 @@ function stringifyPipelineJson(pipeline) {
|
|
|
5970
5967
|
return pipelineJsonStringified;
|
|
5971
5968
|
}
|
|
5972
5969
|
/**
|
|
5973
|
-
* TODO:
|
|
5970
|
+
* TODO: [🐝] Not Working propperly @see https://promptbook.studio/samples/mixed-knowledge.ptbk.md
|
|
5974
5971
|
* TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
|
|
5975
5972
|
* TODO: [🧠] Maybe more elegant solution than replacing via regex
|
|
5976
5973
|
* TODO: [🍙] Make some standart order of json properties
|
|
@@ -6364,7 +6361,10 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
6364
6361
|
if (just(true)) {
|
|
6365
6362
|
executionReportString +=
|
|
6366
6363
|
'\n\n\n\n' +
|
|
6367
|
-
spaceTrim$1(function (block) {
|
|
6364
|
+
spaceTrim$1(function (block) {
|
|
6365
|
+
var _a;
|
|
6366
|
+
return "\n\n ### Prompt\n\n ```\n ".concat(block(escapeMarkdownBlock(((_a = promptExecution.result) === null || _a === void 0 ? void 0 : _a.rawPromptContent) || promptExecution.prompt.content)), "\n ```\n\n ");
|
|
6367
|
+
});
|
|
6368
6368
|
}
|
|
6369
6369
|
if (promptExecution.result && promptExecution.result.content) {
|
|
6370
6370
|
executionReportString += '\n\n\n\n' + '### Result' + '\n\n';
|