@promptbook/core 0.61.0-18 → 0.61.0-19
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 +83 -77
- package/esm/index.es.js.map +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +83 -77
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -958,17 +958,23 @@ var SimplePipelineCollection = /** @class */ (function () {
|
|
|
958
958
|
try {
|
|
959
959
|
for (var pipelines_1 = __values(pipelines), pipelines_1_1 = pipelines_1.next(); !pipelines_1_1.done; pipelines_1_1 = pipelines_1.next()) {
|
|
960
960
|
var pipeline = pipelines_1_1.value;
|
|
961
|
+
// TODO: [👠] DRY
|
|
961
962
|
if (pipeline.pipelineUrl === undefined) {
|
|
962
963
|
throw new ReferenceError$1(spaceTrim$1("\n Pipeline with name \"".concat(pipeline.title, "\" does not have defined URL\n\n File:\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: Pipelines without URLs are called anonymous pipelines\n They can be used as standalone pipelines, but they cannot be referenced by other pipelines\n And also they cannot be used in the pipeline collection\n\n ")));
|
|
963
964
|
}
|
|
965
|
+
// Note: [🐨]
|
|
964
966
|
validatePipeline(pipeline);
|
|
967
|
+
// TODO: [🦄] DRY
|
|
965
968
|
// Note: [🦄]
|
|
966
|
-
if (
|
|
969
|
+
if (
|
|
970
|
+
// TODO: [🐽]
|
|
971
|
+
this.collection.has(pipeline.pipelineUrl) &&
|
|
967
972
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
968
973
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
969
974
|
var existing = this.collection.get(pipeline.pipelineUrl);
|
|
970
975
|
throw new ReferenceError$1(spaceTrim$1("\n Pipeline with URL \"".concat(pipeline.pipelineUrl, "\" is already in the collection\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
|
|
971
976
|
}
|
|
977
|
+
// Note: [🧠] Overwrite existing pipeline with the same URL
|
|
972
978
|
this.collection.set(pipeline.pipelineUrl, pipeline);
|
|
973
979
|
}
|
|
974
980
|
}
|
|
@@ -1439,7 +1445,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1439
1445
|
});
|
|
1440
1446
|
}
|
|
1441
1447
|
|
|
1442
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
1448
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-18",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",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> {content}",dependentParameterNames:["content"],resultingParameterName:"knowledge"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",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-18",parameters:[{name:"content",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> {content}",dependentParameterNames:["content"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",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-18",parameters:[{name:"content",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> {content}",expectations:{words:{min:1,max:8}},dependentParameterNames:["content"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",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-18",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-18",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"}];
|
|
1443
1449
|
|
|
1444
1450
|
var defaultDiacriticsRemovalMap = [
|
|
1445
1451
|
{
|
|
@@ -1819,39 +1825,6 @@ function assertsExecutionSuccessful(executionResult) {
|
|
|
1819
1825
|
* TODO: [🧠] Can this return type be better typed than void
|
|
1820
1826
|
*/
|
|
1821
1827
|
|
|
1822
|
-
/**
|
|
1823
|
-
* Create difference set of two sets.
|
|
1824
|
-
*
|
|
1825
|
-
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
1826
|
-
*/
|
|
1827
|
-
function difference(a, b, isEqual) {
|
|
1828
|
-
var e_1, _a;
|
|
1829
|
-
if (isEqual === void 0) { isEqual = function (a, b) { return a === b; }; }
|
|
1830
|
-
var diff = new Set();
|
|
1831
|
-
var _loop_1 = function (itemA) {
|
|
1832
|
-
if (!Array.from(b).some(function (itemB) { return isEqual(itemA, itemB); })) {
|
|
1833
|
-
diff.add(itemA);
|
|
1834
|
-
}
|
|
1835
|
-
};
|
|
1836
|
-
try {
|
|
1837
|
-
for (var _b = __values(Array.from(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1838
|
-
var itemA = _c.value;
|
|
1839
|
-
_loop_1(itemA);
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1843
|
-
finally {
|
|
1844
|
-
try {
|
|
1845
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1846
|
-
}
|
|
1847
|
-
finally { if (e_1) throw e_1.error; }
|
|
1848
|
-
}
|
|
1849
|
-
return diff;
|
|
1850
|
-
}
|
|
1851
|
-
/**
|
|
1852
|
-
* TODO: [🧠][💯] Maybe also implement symmetricDifference
|
|
1853
|
-
*/
|
|
1854
|
-
|
|
1855
1828
|
/**
|
|
1856
1829
|
* Parses the template and returns the list of all parameter names
|
|
1857
1830
|
*
|
|
@@ -1985,46 +1958,6 @@ function extractParametersFromPromptTemplate(promptTemplate) {
|
|
|
1985
1958
|
* TODO: [🔣] If script require contentLanguage
|
|
1986
1959
|
*/
|
|
1987
1960
|
|
|
1988
|
-
/**
|
|
1989
|
-
* Creates a new set with all elements that are present in either set
|
|
1990
|
-
*
|
|
1991
|
-
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
1992
|
-
*/
|
|
1993
|
-
function union() {
|
|
1994
|
-
var e_1, _a, e_2, _b;
|
|
1995
|
-
var sets = [];
|
|
1996
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1997
|
-
sets[_i] = arguments[_i];
|
|
1998
|
-
}
|
|
1999
|
-
var union = new Set();
|
|
2000
|
-
try {
|
|
2001
|
-
for (var sets_1 = __values(sets), sets_1_1 = sets_1.next(); !sets_1_1.done; sets_1_1 = sets_1.next()) {
|
|
2002
|
-
var set = sets_1_1.value;
|
|
2003
|
-
try {
|
|
2004
|
-
for (var _c = (e_2 = void 0, __values(Array.from(set))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2005
|
-
var item = _d.value;
|
|
2006
|
-
union.add(item);
|
|
2007
|
-
}
|
|
2008
|
-
}
|
|
2009
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2010
|
-
finally {
|
|
2011
|
-
try {
|
|
2012
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
2013
|
-
}
|
|
2014
|
-
finally { if (e_2) throw e_2.error; }
|
|
2015
|
-
}
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2019
|
-
finally {
|
|
2020
|
-
try {
|
|
2021
|
-
if (sets_1_1 && !sets_1_1.done && (_a = sets_1.return)) _a.call(sets_1);
|
|
2022
|
-
}
|
|
2023
|
-
finally { if (e_1) throw e_1.error; }
|
|
2024
|
-
}
|
|
2025
|
-
return union;
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
1961
|
/**
|
|
2029
1962
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
2030
1963
|
*
|
|
@@ -2430,10 +2363,83 @@ function replaceParameters(template, parameters) {
|
|
|
2430
2363
|
return replacedTemplate;
|
|
2431
2364
|
}
|
|
2432
2365
|
|
|
2366
|
+
/**
|
|
2367
|
+
* Create difference set of two sets.
|
|
2368
|
+
*
|
|
2369
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
2370
|
+
*/
|
|
2371
|
+
function difference(a, b, isEqual) {
|
|
2372
|
+
var e_1, _a;
|
|
2373
|
+
if (isEqual === void 0) { isEqual = function (a, b) { return a === b; }; }
|
|
2374
|
+
var diff = new Set();
|
|
2375
|
+
var _loop_1 = function (itemA) {
|
|
2376
|
+
if (!Array.from(b).some(function (itemB) { return isEqual(itemA, itemB); })) {
|
|
2377
|
+
diff.add(itemA);
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
try {
|
|
2381
|
+
for (var _b = __values(Array.from(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2382
|
+
var itemA = _c.value;
|
|
2383
|
+
_loop_1(itemA);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2387
|
+
finally {
|
|
2388
|
+
try {
|
|
2389
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2390
|
+
}
|
|
2391
|
+
finally { if (e_1) throw e_1.error; }
|
|
2392
|
+
}
|
|
2393
|
+
return diff;
|
|
2394
|
+
}
|
|
2395
|
+
/**
|
|
2396
|
+
* TODO: [🧠][💯] Maybe also implement symmetricDifference
|
|
2397
|
+
*/
|
|
2398
|
+
|
|
2399
|
+
/**
|
|
2400
|
+
* Creates a new set with all elements that are present in either set
|
|
2401
|
+
*
|
|
2402
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
2403
|
+
*/
|
|
2404
|
+
function union() {
|
|
2405
|
+
var e_1, _a, e_2, _b;
|
|
2406
|
+
var sets = [];
|
|
2407
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2408
|
+
sets[_i] = arguments[_i];
|
|
2409
|
+
}
|
|
2410
|
+
var union = new Set();
|
|
2411
|
+
try {
|
|
2412
|
+
for (var sets_1 = __values(sets), sets_1_1 = sets_1.next(); !sets_1_1.done; sets_1_1 = sets_1.next()) {
|
|
2413
|
+
var set = sets_1_1.value;
|
|
2414
|
+
try {
|
|
2415
|
+
for (var _c = (e_2 = void 0, __values(Array.from(set))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2416
|
+
var item = _d.value;
|
|
2417
|
+
union.add(item);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2421
|
+
finally {
|
|
2422
|
+
try {
|
|
2423
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
2424
|
+
}
|
|
2425
|
+
finally { if (e_2) throw e_2.error; }
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2430
|
+
finally {
|
|
2431
|
+
try {
|
|
2432
|
+
if (sets_1_1 && !sets_1_1.done && (_a = sets_1.return)) _a.call(sets_1);
|
|
2433
|
+
}
|
|
2434
|
+
finally { if (e_1) throw e_1.error; }
|
|
2435
|
+
}
|
|
2436
|
+
return union;
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2433
2439
|
/**
|
|
2434
2440
|
* The version of the Promptbook library
|
|
2435
2441
|
*/
|
|
2436
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2442
|
+
var PROMPTBOOK_VERSION = '0.61.0-18';
|
|
2437
2443
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2438
2444
|
|
|
2439
2445
|
/**
|
|
@@ -2584,7 +2590,7 @@ function createPipelineExecutor(options) {
|
|
|
2584
2590
|
pipeline = rawPipeline;
|
|
2585
2591
|
}
|
|
2586
2592
|
else {
|
|
2587
|
-
console.warn(spaceTrim$1("\n Pipeline is not prepared\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 "));
|
|
2593
|
+
console.warn(spaceTrim$1("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\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 ")));
|
|
2588
2594
|
}
|
|
2589
2595
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2590
2596
|
function getContextForTemplate(// <- TODO: [🧠][🥜]
|