@promptbook/cli 0.80.0-0 → 0.80.0-1
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 +114 -113
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -4
- package/esm/typings/src/_packages/types.index.d.ts +0 -4
- package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -1
- package/esm/typings/src/conversion/{pipelineStringToJson.d.ts → compilePipeline.d.ts} +3 -3
- package/esm/typings/src/conversion/{pipelineStringToJsonSync.d.ts → precompilePipeline.d.ts} +3 -3
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +1 -1
- package/esm/typings/src/high-level-abstractions/index.d.ts +1 -1
- package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +114 -113
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/conversion/{pipelineStringToJson.test.d.ts → compilePipeline.test.d.ts} +0 -0
- /package/esm/typings/src/conversion/{pipelineStringToJsonSync.test.d.ts → precompilePipeline.test.d.ts} +0 -0
|
@@ -29,9 +29,9 @@ import { SET_IS_VERBOSE } from '../config';
|
|
|
29
29
|
import { DEFAULT_IS_AUTO_INSTALLED } from '../config';
|
|
30
30
|
import { ORDER_OF_PIPELINE_JSON } from '../constants';
|
|
31
31
|
import { RESERVED_PARAMETER_NAMES } from '../constants';
|
|
32
|
+
import { compilePipeline } from '../conversion/compilePipeline';
|
|
32
33
|
import { pipelineJsonToString } from '../conversion/pipelineJsonToString';
|
|
33
|
-
import {
|
|
34
|
-
import { pipelineStringToJsonSync } from '../conversion/pipelineStringToJsonSync';
|
|
34
|
+
import { precompilePipeline } from '../conversion/precompilePipeline';
|
|
35
35
|
import { prettifyPipelineString } from '../conversion/prettify/prettifyPipelineString';
|
|
36
36
|
import { extractParameterNamesFromTask } from '../conversion/utils/extractParameterNamesFromTask';
|
|
37
37
|
import { removePipelineCommand } from '../conversion/utils/removePipelineCommand';
|
|
@@ -150,9 +150,9 @@ export { SET_IS_VERBOSE };
|
|
|
150
150
|
export { DEFAULT_IS_AUTO_INSTALLED };
|
|
151
151
|
export { ORDER_OF_PIPELINE_JSON };
|
|
152
152
|
export { RESERVED_PARAMETER_NAMES };
|
|
153
|
+
export { compilePipeline };
|
|
153
154
|
export { pipelineJsonToString };
|
|
154
|
-
export {
|
|
155
|
-
export { pipelineStringToJsonSync };
|
|
155
|
+
export { precompilePipeline };
|
|
156
156
|
export { prettifyPipelineString };
|
|
157
157
|
export { extractParameterNamesFromTask };
|
|
158
158
|
export { removePipelineCommand };
|
|
@@ -46,8 +46,6 @@ import type { CsvSettings } from '../formats/csv/CsvSettings';
|
|
|
46
46
|
import type { AbstractFormfactorDefinition } from '../formfactors/_common/AbstractFormfactorDefinition';
|
|
47
47
|
import type { FormfactorDefinition } from '../formfactors/_common/FormfactorDefinition';
|
|
48
48
|
import type { string_formfactor_name } from '../formfactors/_common/string_formfactor_name';
|
|
49
|
-
import type { AsyncHighLevelAbstraction } from '../high-level-abstractions/_common/HighLevelAbstraction';
|
|
50
|
-
import type { CommonHighLevelAbstraction } from '../high-level-abstractions/_common/HighLevelAbstraction';
|
|
51
49
|
import type { LlmToolsConfiguration } from '../llm-providers/_common/register/LlmToolsConfiguration';
|
|
52
50
|
import type { LlmToolsMetadata } from '../llm-providers/_common/register/LlmToolsMetadata';
|
|
53
51
|
import type { LlmToolsOptions } from '../llm-providers/_common/register/LlmToolsOptions';
|
|
@@ -310,8 +308,6 @@ export type { CsvSettings };
|
|
|
310
308
|
export type { AbstractFormfactorDefinition };
|
|
311
309
|
export type { FormfactorDefinition };
|
|
312
310
|
export type { string_formfactor_name };
|
|
313
|
-
export type { AsyncHighLevelAbstraction };
|
|
314
|
-
export type { CommonHighLevelAbstraction };
|
|
315
311
|
export type { LlmToolsConfiguration };
|
|
316
312
|
export type { LlmToolsMetadata };
|
|
317
313
|
export type { LlmToolsOptions };
|
|
@@ -6,6 +6,6 @@ import type { CommandParser } from './types/CommandParser';
|
|
|
6
6
|
* @returns the parser for the command
|
|
7
7
|
* @throws {UnexpectedError} if the parser is not found
|
|
8
8
|
*
|
|
9
|
-
* @private within the
|
|
9
|
+
* @private within the compilePipeline
|
|
10
10
|
*/
|
|
11
11
|
export declare function getParserForCommand<TCommand extends Command>(command: TCommand): CommandParser<TCommand>;
|
|
@@ -7,6 +7,6 @@ import type { CommandUsagePlace } from './types/CommandUsagePlaces';
|
|
|
7
7
|
* @returns parsed command object
|
|
8
8
|
* @throws {ParseError} if the command is invalid
|
|
9
9
|
*
|
|
10
|
-
* @private within the
|
|
10
|
+
* @private within the compilePipeline
|
|
11
11
|
*/
|
|
12
12
|
export declare function parseCommand(raw: string_markdown_text, usagePlace: CommandUsagePlace): Command;
|
|
@@ -6,6 +6,6 @@ import type { Command } from './types/Command';
|
|
|
6
6
|
* @returns stringified command
|
|
7
7
|
* @throws {UnexpectedError} if the command is invalid
|
|
8
8
|
*
|
|
9
|
-
* @private within the
|
|
9
|
+
* @private within the compilePipeline
|
|
10
10
|
*/
|
|
11
11
|
export declare function stringifyCommand(command: Command): string_markdown_text;
|
|
@@ -6,8 +6,8 @@ import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions
|
|
|
6
6
|
* Compile pipeline from string (markdown) format to JSON format
|
|
7
7
|
*
|
|
8
8
|
* Note: There are 3 similar functions:
|
|
9
|
-
* - `
|
|
10
|
-
* - `
|
|
9
|
+
* - `compilePipeline` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
|
|
10
|
+
* - `precompilePipeline` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
11
11
|
* - `preparePipeline` - just one step in the compilation process
|
|
12
12
|
*
|
|
13
13
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
@@ -20,7 +20,7 @@ import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions
|
|
|
20
20
|
* @throws {ParseError} if the promptbook string is not valid
|
|
21
21
|
* @public exported from `@promptbook/core`
|
|
22
22
|
*/
|
|
23
|
-
export declare function
|
|
23
|
+
export declare function compilePipeline(pipelineString: PipelineString, tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options?: PrepareAndScrapeOptions): Promise<PipelineJson>;
|
|
24
24
|
/**
|
|
25
25
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
26
26
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
package/esm/typings/src/conversion/{pipelineStringToJsonSync.d.ts → precompilePipeline.d.ts}
RENAMED
|
@@ -4,8 +4,8 @@ import type { PipelineString } from '../pipeline/PipelineString';
|
|
|
4
4
|
* Compile pipeline from string (markdown) format to JSON format synchronously
|
|
5
5
|
*
|
|
6
6
|
* Note: There are 3 similar functions:
|
|
7
|
-
* - `
|
|
8
|
-
* - `
|
|
7
|
+
* - `compilePipeline` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
|
|
8
|
+
* - `precompilePipeline` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
9
9
|
* - `preparePipeline` - just one step in the compilation process
|
|
10
10
|
*
|
|
11
11
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
@@ -16,7 +16,7 @@ import type { PipelineString } from '../pipeline/PipelineString';
|
|
|
16
16
|
* @throws {ParseError} if the promptbook string is not valid
|
|
17
17
|
* @public exported from `@promptbook/core`
|
|
18
18
|
*/
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function precompilePipeline(pipelineString: PipelineString): PipelineJson;
|
|
20
20
|
/**
|
|
21
21
|
* TODO: [🧠] Maybe more things here can be refactored as high-level abstractions
|
|
22
22
|
* TODO: [main] !!!! Warn if used only sync version
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* All high-level abstractions
|
|
3
3
|
*
|
|
4
|
-
* @private internal index of `
|
|
4
|
+
* @private internal index of `precompilePipeline` (= used for sync) and `preparePipeline` (= used for async)
|
|
5
5
|
*/
|
|
6
6
|
export declare const HIGH_LEVEL_ABSTRACTIONS: readonly [{
|
|
7
7
|
type: "SYNC";
|
|
@@ -2,6 +2,7 @@ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
|
2
2
|
/**
|
|
3
3
|
* Unprepare just strips the preparation data of the pipeline
|
|
4
4
|
*
|
|
5
|
+
* @deprecated In future version this function will be removed or deprecated
|
|
5
6
|
* @public exported from `@promptbook/core`
|
|
6
7
|
*/
|
|
7
8
|
export declare function unpreparePipeline(pipeline: PipelineJson): PipelineJson;
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
*
|
|
50
50
|
* @see https://github.com/webgptorg/promptbook
|
|
51
51
|
*/
|
|
52
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
52
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.80.0-0';
|
|
53
53
|
/**
|
|
54
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
55
55
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2664,6 +2664,100 @@
|
|
|
2664
2664
|
* TODO: [🧠] Maybe clear `sourceFile` or clear when exposing through API or remote server
|
|
2665
2665
|
*/
|
|
2666
2666
|
|
|
2667
|
+
/**
|
|
2668
|
+
* This error type indicates that some tools are missing for pipeline execution or preparation
|
|
2669
|
+
*
|
|
2670
|
+
* @public exported from `@promptbook/core`
|
|
2671
|
+
*/
|
|
2672
|
+
var MissingToolsError = /** @class */ (function (_super) {
|
|
2673
|
+
__extends(MissingToolsError, _super);
|
|
2674
|
+
function MissingToolsError(message) {
|
|
2675
|
+
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: You have probbably forgot to provide some tools for pipeline execution or preparation\n\n "); })) || this;
|
|
2676
|
+
_this.name = 'MissingToolsError';
|
|
2677
|
+
Object.setPrototypeOf(_this, MissingToolsError.prototype);
|
|
2678
|
+
return _this;
|
|
2679
|
+
}
|
|
2680
|
+
return MissingToolsError;
|
|
2681
|
+
}(Error));
|
|
2682
|
+
|
|
2683
|
+
/**
|
|
2684
|
+
* Async version of Array.forEach
|
|
2685
|
+
*
|
|
2686
|
+
* @param array - Array to iterate over
|
|
2687
|
+
* @param options - Options for the function
|
|
2688
|
+
* @param callbackfunction - Function to call for each item
|
|
2689
|
+
* @public exported from `@promptbook/utils`
|
|
2690
|
+
* @deprecated [🪂] Use queues instead
|
|
2691
|
+
*/
|
|
2692
|
+
function forEachAsync(array, options, callbackfunction) {
|
|
2693
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2694
|
+
var _a, maxParallelCount, index, runningTasks, tasks, _loop_1, _b, _c, item, e_1_1;
|
|
2695
|
+
var e_1, _d;
|
|
2696
|
+
return __generator(this, function (_e) {
|
|
2697
|
+
switch (_e.label) {
|
|
2698
|
+
case 0:
|
|
2699
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? Infinity : _a;
|
|
2700
|
+
index = 0;
|
|
2701
|
+
runningTasks = [];
|
|
2702
|
+
tasks = [];
|
|
2703
|
+
_loop_1 = function (item) {
|
|
2704
|
+
var currentIndex, task;
|
|
2705
|
+
return __generator(this, function (_f) {
|
|
2706
|
+
switch (_f.label) {
|
|
2707
|
+
case 0:
|
|
2708
|
+
currentIndex = index++;
|
|
2709
|
+
task = callbackfunction(item, currentIndex, array);
|
|
2710
|
+
tasks.push(task);
|
|
2711
|
+
runningTasks.push(task);
|
|
2712
|
+
/* not await */ Promise.resolve(task).then(function () {
|
|
2713
|
+
runningTasks = runningTasks.filter(function (t) { return t !== task; });
|
|
2714
|
+
});
|
|
2715
|
+
if (!(maxParallelCount < runningTasks.length)) return [3 /*break*/, 2];
|
|
2716
|
+
return [4 /*yield*/, Promise.race(runningTasks)];
|
|
2717
|
+
case 1:
|
|
2718
|
+
_f.sent();
|
|
2719
|
+
_f.label = 2;
|
|
2720
|
+
case 2: return [2 /*return*/];
|
|
2721
|
+
}
|
|
2722
|
+
});
|
|
2723
|
+
};
|
|
2724
|
+
_e.label = 1;
|
|
2725
|
+
case 1:
|
|
2726
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
2727
|
+
_b = __values(array), _c = _b.next();
|
|
2728
|
+
_e.label = 2;
|
|
2729
|
+
case 2:
|
|
2730
|
+
if (!!_c.done) return [3 /*break*/, 5];
|
|
2731
|
+
item = _c.value;
|
|
2732
|
+
return [5 /*yield**/, _loop_1(item)];
|
|
2733
|
+
case 3:
|
|
2734
|
+
_e.sent();
|
|
2735
|
+
_e.label = 4;
|
|
2736
|
+
case 4:
|
|
2737
|
+
_c = _b.next();
|
|
2738
|
+
return [3 /*break*/, 2];
|
|
2739
|
+
case 5: return [3 /*break*/, 8];
|
|
2740
|
+
case 6:
|
|
2741
|
+
e_1_1 = _e.sent();
|
|
2742
|
+
e_1 = { error: e_1_1 };
|
|
2743
|
+
return [3 /*break*/, 8];
|
|
2744
|
+
case 7:
|
|
2745
|
+
try {
|
|
2746
|
+
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
2747
|
+
}
|
|
2748
|
+
finally { if (e_1) throw e_1.error; }
|
|
2749
|
+
return [7 /*endfinally*/];
|
|
2750
|
+
case 8: return [4 /*yield*/, Promise.all(tasks)];
|
|
2751
|
+
case 9:
|
|
2752
|
+
_e.sent();
|
|
2753
|
+
return [2 /*return*/];
|
|
2754
|
+
}
|
|
2755
|
+
});
|
|
2756
|
+
});
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
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:[],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:[],sourceFile:"./books/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}],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\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:[],sourceFile:"./books/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}],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:[],sourceFile:"./books/prepare-persona.book.md"}];
|
|
2760
|
+
|
|
2667
2761
|
/**
|
|
2668
2762
|
* Prettify the html code
|
|
2669
2763
|
*
|
|
@@ -2914,100 +3008,6 @@
|
|
|
2914
3008
|
* TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
|
|
2915
3009
|
*/
|
|
2916
3010
|
|
|
2917
|
-
/**
|
|
2918
|
-
* This error type indicates that some tools are missing for pipeline execution or preparation
|
|
2919
|
-
*
|
|
2920
|
-
* @public exported from `@promptbook/core`
|
|
2921
|
-
*/
|
|
2922
|
-
var MissingToolsError = /** @class */ (function (_super) {
|
|
2923
|
-
__extends(MissingToolsError, _super);
|
|
2924
|
-
function MissingToolsError(message) {
|
|
2925
|
-
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: You have probbably forgot to provide some tools for pipeline execution or preparation\n\n "); })) || this;
|
|
2926
|
-
_this.name = 'MissingToolsError';
|
|
2927
|
-
Object.setPrototypeOf(_this, MissingToolsError.prototype);
|
|
2928
|
-
return _this;
|
|
2929
|
-
}
|
|
2930
|
-
return MissingToolsError;
|
|
2931
|
-
}(Error));
|
|
2932
|
-
|
|
2933
|
-
/**
|
|
2934
|
-
* Async version of Array.forEach
|
|
2935
|
-
*
|
|
2936
|
-
* @param array - Array to iterate over
|
|
2937
|
-
* @param options - Options for the function
|
|
2938
|
-
* @param callbackfunction - Function to call for each item
|
|
2939
|
-
* @public exported from `@promptbook/utils`
|
|
2940
|
-
* @deprecated [🪂] Use queues instead
|
|
2941
|
-
*/
|
|
2942
|
-
function forEachAsync(array, options, callbackfunction) {
|
|
2943
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2944
|
-
var _a, maxParallelCount, index, runningTasks, tasks, _loop_1, _b, _c, item, e_1_1;
|
|
2945
|
-
var e_1, _d;
|
|
2946
|
-
return __generator(this, function (_e) {
|
|
2947
|
-
switch (_e.label) {
|
|
2948
|
-
case 0:
|
|
2949
|
-
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? Infinity : _a;
|
|
2950
|
-
index = 0;
|
|
2951
|
-
runningTasks = [];
|
|
2952
|
-
tasks = [];
|
|
2953
|
-
_loop_1 = function (item) {
|
|
2954
|
-
var currentIndex, task;
|
|
2955
|
-
return __generator(this, function (_f) {
|
|
2956
|
-
switch (_f.label) {
|
|
2957
|
-
case 0:
|
|
2958
|
-
currentIndex = index++;
|
|
2959
|
-
task = callbackfunction(item, currentIndex, array);
|
|
2960
|
-
tasks.push(task);
|
|
2961
|
-
runningTasks.push(task);
|
|
2962
|
-
/* not await */ Promise.resolve(task).then(function () {
|
|
2963
|
-
runningTasks = runningTasks.filter(function (t) { return t !== task; });
|
|
2964
|
-
});
|
|
2965
|
-
if (!(maxParallelCount < runningTasks.length)) return [3 /*break*/, 2];
|
|
2966
|
-
return [4 /*yield*/, Promise.race(runningTasks)];
|
|
2967
|
-
case 1:
|
|
2968
|
-
_f.sent();
|
|
2969
|
-
_f.label = 2;
|
|
2970
|
-
case 2: return [2 /*return*/];
|
|
2971
|
-
}
|
|
2972
|
-
});
|
|
2973
|
-
};
|
|
2974
|
-
_e.label = 1;
|
|
2975
|
-
case 1:
|
|
2976
|
-
_e.trys.push([1, 6, 7, 8]);
|
|
2977
|
-
_b = __values(array), _c = _b.next();
|
|
2978
|
-
_e.label = 2;
|
|
2979
|
-
case 2:
|
|
2980
|
-
if (!!_c.done) return [3 /*break*/, 5];
|
|
2981
|
-
item = _c.value;
|
|
2982
|
-
return [5 /*yield**/, _loop_1(item)];
|
|
2983
|
-
case 3:
|
|
2984
|
-
_e.sent();
|
|
2985
|
-
_e.label = 4;
|
|
2986
|
-
case 4:
|
|
2987
|
-
_c = _b.next();
|
|
2988
|
-
return [3 /*break*/, 2];
|
|
2989
|
-
case 5: return [3 /*break*/, 8];
|
|
2990
|
-
case 6:
|
|
2991
|
-
e_1_1 = _e.sent();
|
|
2992
|
-
e_1 = { error: e_1_1 };
|
|
2993
|
-
return [3 /*break*/, 8];
|
|
2994
|
-
case 7:
|
|
2995
|
-
try {
|
|
2996
|
-
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
2997
|
-
}
|
|
2998
|
-
finally { if (e_1) throw e_1.error; }
|
|
2999
|
-
return [7 /*endfinally*/];
|
|
3000
|
-
case 8: return [4 /*yield*/, Promise.all(tasks)];
|
|
3001
|
-
case 9:
|
|
3002
|
-
_e.sent();
|
|
3003
|
-
return [2 /*return*/];
|
|
3004
|
-
}
|
|
3005
|
-
});
|
|
3006
|
-
});
|
|
3007
|
-
}
|
|
3008
|
-
|
|
3009
|
-
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:[],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:[],sourceFile:"./books/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}],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\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:[],sourceFile:"./books/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}],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:[],sourceFile:"./books/prepare-persona.book.md"}];
|
|
3010
|
-
|
|
3011
3011
|
/**
|
|
3012
3012
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
3013
3013
|
*
|
|
@@ -3515,6 +3515,7 @@
|
|
|
3515
3515
|
/**
|
|
3516
3516
|
* Unprepare just strips the preparation data of the pipeline
|
|
3517
3517
|
*
|
|
3518
|
+
* @deprecated In future version this function will be removed or deprecated
|
|
3518
3519
|
* @public exported from `@promptbook/core`
|
|
3519
3520
|
*/
|
|
3520
3521
|
function unpreparePipeline(pipeline) {
|
|
@@ -8294,7 +8295,7 @@
|
|
|
8294
8295
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
8295
8296
|
*/
|
|
8296
8297
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
8297
|
-
// Note: [🍣] Do nothing, its application is implemented separately in `
|
|
8298
|
+
// Note: [🍣] Do nothing, its application is implemented separately in `precompilePipeline`
|
|
8298
8299
|
},
|
|
8299
8300
|
/**
|
|
8300
8301
|
* Apply the PARAMETER command to the `pipelineJson`
|
|
@@ -8302,7 +8303,7 @@
|
|
|
8302
8303
|
* Note: `$` is used to indicate that this function mutates given `taskJson`
|
|
8303
8304
|
*/
|
|
8304
8305
|
$applyToTaskJson: function (command, $taskJson, $pipelineJson) {
|
|
8305
|
-
// Note: [🍣] Do nothing, its application is implemented separately in `
|
|
8306
|
+
// Note: [🍣] Do nothing, its application is implemented separately in `precompilePipeline`
|
|
8306
8307
|
},
|
|
8307
8308
|
/**
|
|
8308
8309
|
* Converts the PARAMETER command back to string
|
|
@@ -8810,7 +8811,7 @@
|
|
|
8810
8811
|
* @returns the parser for the command
|
|
8811
8812
|
* @throws {UnexpectedError} if the parser is not found
|
|
8812
8813
|
*
|
|
8813
|
-
* @private within the
|
|
8814
|
+
* @private within the compilePipeline
|
|
8814
8815
|
*/
|
|
8815
8816
|
function getParserForCommand(command) {
|
|
8816
8817
|
var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
|
|
@@ -8846,7 +8847,7 @@
|
|
|
8846
8847
|
* @returns parsed command object
|
|
8847
8848
|
* @throws {ParseError} if the command is invalid
|
|
8848
8849
|
*
|
|
8849
|
-
* @private within the
|
|
8850
|
+
* @private within the compilePipeline
|
|
8850
8851
|
*/
|
|
8851
8852
|
function parseCommand(raw, usagePlace) {
|
|
8852
8853
|
if (raw.includes('\n') || raw.includes('\r')) {
|
|
@@ -9261,7 +9262,7 @@
|
|
|
9261
9262
|
/**
|
|
9262
9263
|
* All high-level abstractions
|
|
9263
9264
|
*
|
|
9264
|
-
* @private internal index of `
|
|
9265
|
+
* @private internal index of `precompilePipeline` (= used for sync) and `preparePipeline` (= used for async)
|
|
9265
9266
|
*/
|
|
9266
9267
|
var HIGH_LEVEL_ABSTRACTIONS = [
|
|
9267
9268
|
ImplicitFormfactorHla,
|
|
@@ -9511,8 +9512,8 @@
|
|
|
9511
9512
|
* Compile pipeline from string (markdown) format to JSON format synchronously
|
|
9512
9513
|
*
|
|
9513
9514
|
* Note: There are 3 similar functions:
|
|
9514
|
-
* - `
|
|
9515
|
-
* - `
|
|
9515
|
+
* - `compilePipeline` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
|
|
9516
|
+
* - `precompilePipeline` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
9516
9517
|
* - `preparePipeline` - just one step in the compilation process
|
|
9517
9518
|
*
|
|
9518
9519
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
@@ -9523,7 +9524,7 @@
|
|
|
9523
9524
|
* @throws {ParseError} if the promptbook string is not valid
|
|
9524
9525
|
* @public exported from `@promptbook/core`
|
|
9525
9526
|
*/
|
|
9526
|
-
function
|
|
9527
|
+
function precompilePipeline(pipelineString) {
|
|
9527
9528
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
9528
9529
|
var $pipelineJson = {
|
|
9529
9530
|
title: DEFAULT_TITLE,
|
|
@@ -9943,7 +9944,7 @@
|
|
|
9943
9944
|
// TODO: [🍙] Maybe do reorder of `$pipelineJson` here
|
|
9944
9945
|
return exportJson({
|
|
9945
9946
|
name: 'pipelineJson',
|
|
9946
|
-
message: "Result of `
|
|
9947
|
+
message: "Result of `precompilePipeline`",
|
|
9947
9948
|
order: ORDER_OF_PIPELINE_JSON,
|
|
9948
9949
|
value: __assign({ formfactorName: 'GENERIC' }, $pipelineJson),
|
|
9949
9950
|
});
|
|
@@ -9964,8 +9965,8 @@
|
|
|
9964
9965
|
* Compile pipeline from string (markdown) format to JSON format
|
|
9965
9966
|
*
|
|
9966
9967
|
* Note: There are 3 similar functions:
|
|
9967
|
-
* - `
|
|
9968
|
-
* - `
|
|
9968
|
+
* - `compilePipeline` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
|
|
9969
|
+
* - `precompilePipeline` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
9969
9970
|
* - `preparePipeline` - just one step in the compilation process
|
|
9970
9971
|
*
|
|
9971
9972
|
* Note: This function does not validate logic of the pipeline only the parsing
|
|
@@ -9978,13 +9979,13 @@
|
|
|
9978
9979
|
* @throws {ParseError} if the promptbook string is not valid
|
|
9979
9980
|
* @public exported from `@promptbook/core`
|
|
9980
9981
|
*/
|
|
9981
|
-
function
|
|
9982
|
+
function compilePipeline(pipelineString, tools, options) {
|
|
9982
9983
|
return __awaiter(this, void 0, void 0, function () {
|
|
9983
9984
|
var pipelineJson;
|
|
9984
9985
|
return __generator(this, function (_a) {
|
|
9985
9986
|
switch (_a.label) {
|
|
9986
9987
|
case 0:
|
|
9987
|
-
pipelineJson =
|
|
9988
|
+
pipelineJson = precompilePipeline(pipelineString);
|
|
9988
9989
|
if (!(tools !== undefined && tools.llm !== undefined)) return [3 /*break*/, 2];
|
|
9989
9990
|
return [4 /*yield*/, preparePipeline(pipelineJson, tools, options || {
|
|
9990
9991
|
rootDirname: null,
|
|
@@ -9993,7 +9994,7 @@
|
|
|
9993
9994
|
pipelineJson = _a.sent();
|
|
9994
9995
|
_a.label = 2;
|
|
9995
9996
|
case 2:
|
|
9996
|
-
// Note: No need to use `$exportJson` because `
|
|
9997
|
+
// Note: No need to use `$exportJson` because `precompilePipeline` and `preparePipeline` already do that
|
|
9997
9998
|
return [2 /*return*/, pipelineJson];
|
|
9998
9999
|
}
|
|
9999
10000
|
});
|
|
@@ -11120,7 +11121,7 @@
|
|
|
11120
11121
|
return [4 /*yield*/, promises.readFile(fileName, 'utf-8')];
|
|
11121
11122
|
case 2:
|
|
11122
11123
|
pipelineString = (_e.sent());
|
|
11123
|
-
return [4 /*yield*/,
|
|
11124
|
+
return [4 /*yield*/, compilePipeline(pipelineString, tools, {
|
|
11124
11125
|
rootDirname: rootDirname,
|
|
11125
11126
|
})];
|
|
11126
11127
|
case 3:
|
|
@@ -11617,7 +11618,7 @@
|
|
|
11617
11618
|
case 0:
|
|
11618
11619
|
isGraphAdded = options.isGraphAdded, isPrettifyed = options.isPrettifyed;
|
|
11619
11620
|
if (!isGraphAdded) return [3 /*break*/, 2];
|
|
11620
|
-
return [4 /*yield*/,
|
|
11621
|
+
return [4 /*yield*/, compilePipeline(pipelineString)];
|
|
11621
11622
|
case 1:
|
|
11622
11623
|
pipelineJson = _a.sent();
|
|
11623
11624
|
promptbookMermaid_1 = renderPromptbookMermaid(pipelineJson, {
|
|
@@ -12311,7 +12312,7 @@
|
|
|
12311
12312
|
_m.label = 12;
|
|
12312
12313
|
case 12:
|
|
12313
12314
|
_m.trys.push([12, 14, , 15]);
|
|
12314
|
-
return [4 /*yield*/,
|
|
12315
|
+
return [4 /*yield*/, compilePipeline(pipelineString, tools)];
|
|
12315
12316
|
case 13:
|
|
12316
12317
|
pipeline = _m.sent();
|
|
12317
12318
|
return [3 /*break*/, 15];
|
|
@@ -12575,7 +12576,7 @@
|
|
|
12575
12576
|
return [4 /*yield*/, promises.readFile(filename, 'utf-8')];
|
|
12576
12577
|
case 7:
|
|
12577
12578
|
pipelineMarkdown = (_f.sent());
|
|
12578
|
-
return [4 /*yield*/,
|
|
12579
|
+
return [4 /*yield*/, compilePipeline(pipelineMarkdown, tools)];
|
|
12579
12580
|
case 8:
|
|
12580
12581
|
pipeline = _f.sent();
|
|
12581
12582
|
if (isVerbose) {
|