@promptbook/core 0.61.0-17 → 0.61.0-18
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 +46 -45
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
- package/package.json +1 -1
- package/umd/index.umd.js +46 -45
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
- package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
package/esm/index.es.js
CHANGED
|
@@ -918,79 +918,94 @@ var ReferenceError$1 = /** @class */ (function (_super) {
|
|
|
918
918
|
}(Error));
|
|
919
919
|
|
|
920
920
|
/**
|
|
921
|
-
*
|
|
922
|
-
|
|
921
|
+
* Unprepare just strips the preparation data of the pipeline
|
|
922
|
+
*/
|
|
923
|
+
function unpreparePipeline(pipeline) {
|
|
924
|
+
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources;
|
|
925
|
+
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
926
|
+
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
927
|
+
return __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* TODO: [🔼] !!! Export via `@promptbook/core`
|
|
931
|
+
* TODO: Write tests for `preparePipeline`
|
|
932
|
+
*/
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Library of pipelines that groups together pipelines for an application.
|
|
936
|
+
* This implementation is a very thin wrapper around the Array / Map of pipelines.
|
|
923
937
|
*
|
|
924
938
|
* @private use `createCollectionFromJson` instead
|
|
925
|
-
* @see https://github.com/webgptorg/
|
|
939
|
+
* @see https://github.com/webgptorg/pipeline#pipeline-collection
|
|
926
940
|
*/
|
|
927
941
|
var SimplePipelineCollection = /** @class */ (function () {
|
|
928
942
|
/**
|
|
929
|
-
* Constructs a pipeline collection from
|
|
943
|
+
* Constructs a pipeline collection from pipelines
|
|
930
944
|
*
|
|
931
|
-
* @param
|
|
945
|
+
* @param pipelines @@@
|
|
932
946
|
*
|
|
933
947
|
* @private Use instead `createCollectionFromJson`
|
|
934
|
-
* Note: During the construction logic of all
|
|
948
|
+
* Note: During the construction logic of all pipelines are validated
|
|
935
949
|
* Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
|
|
936
950
|
*/
|
|
937
951
|
function SimplePipelineCollection() {
|
|
938
952
|
var e_1, _a;
|
|
939
|
-
var
|
|
953
|
+
var pipelines = [];
|
|
940
954
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
941
|
-
|
|
955
|
+
pipelines[_i] = arguments[_i];
|
|
942
956
|
}
|
|
943
957
|
this.collection = new Map();
|
|
944
958
|
try {
|
|
945
|
-
for (var
|
|
946
|
-
var
|
|
947
|
-
if (
|
|
948
|
-
throw new ReferenceError$1(spaceTrim$1("\n
|
|
959
|
+
for (var pipelines_1 = __values(pipelines), pipelines_1_1 = pipelines_1.next(); !pipelines_1_1.done; pipelines_1_1 = pipelines_1.next()) {
|
|
960
|
+
var pipeline = pipelines_1_1.value;
|
|
961
|
+
if (pipeline.pipelineUrl === undefined) {
|
|
962
|
+
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 ")));
|
|
949
963
|
}
|
|
950
|
-
validatePipeline(
|
|
964
|
+
validatePipeline(pipeline);
|
|
951
965
|
// Note: [🦄]
|
|
952
|
-
if (this.collection.has(
|
|
953
|
-
pipelineJsonToString(
|
|
954
|
-
|
|
955
|
-
|
|
966
|
+
if (this.collection.has(pipeline.pipelineUrl) &&
|
|
967
|
+
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
968
|
+
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
969
|
+
var existing = this.collection.get(pipeline.pipelineUrl);
|
|
970
|
+
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 ")));
|
|
956
971
|
}
|
|
957
|
-
this.collection.set(
|
|
972
|
+
this.collection.set(pipeline.pipelineUrl, pipeline);
|
|
958
973
|
}
|
|
959
974
|
}
|
|
960
975
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
961
976
|
finally {
|
|
962
977
|
try {
|
|
963
|
-
if (
|
|
978
|
+
if (pipelines_1_1 && !pipelines_1_1.done && (_a = pipelines_1.return)) _a.call(pipelines_1);
|
|
964
979
|
}
|
|
965
980
|
finally { if (e_1) throw e_1.error; }
|
|
966
981
|
}
|
|
967
982
|
}
|
|
968
983
|
/**
|
|
969
|
-
* Gets all
|
|
984
|
+
* Gets all pipelines in the collection
|
|
970
985
|
*/
|
|
971
986
|
SimplePipelineCollection.prototype.listPipelines = function () {
|
|
972
987
|
return Array.from(this.collection.keys());
|
|
973
988
|
};
|
|
974
989
|
/**
|
|
975
|
-
* Gets
|
|
990
|
+
* Gets pipeline by its URL
|
|
976
991
|
*
|
|
977
992
|
* Note: This is not a direct fetching from the URL, but a lookup in the collection
|
|
978
993
|
*/
|
|
979
994
|
SimplePipelineCollection.prototype.getPipelineByUrl = function (url) {
|
|
980
995
|
var _this = this;
|
|
981
|
-
var
|
|
982
|
-
if (!
|
|
996
|
+
var pipeline = this.collection.get(url);
|
|
997
|
+
if (!pipeline) {
|
|
983
998
|
if (this.listPipelines().length === 0) {
|
|
984
|
-
throw new NotFoundError(spaceTrim$1("\n
|
|
999
|
+
throw new NotFoundError(spaceTrim$1("\n Pipeline with url \"".concat(url, "\" not found\n\n No pipelines available\n ")));
|
|
985
1000
|
}
|
|
986
|
-
throw new NotFoundError(spaceTrim$1(function (block) { return "\n
|
|
1001
|
+
throw new NotFoundError(spaceTrim$1(function (block) { return "\n Pipeline with url \"".concat(url, "\" not found\n\n Available pipelines:\n ").concat(block(_this.listPipelines()
|
|
987
1002
|
.map(function (pipelineUrl) { return "- ".concat(pipelineUrl); })
|
|
988
1003
|
.join('\n')), "\n\n "); }));
|
|
989
1004
|
}
|
|
990
|
-
return
|
|
1005
|
+
return pipeline;
|
|
991
1006
|
};
|
|
992
1007
|
/**
|
|
993
|
-
* Checks whether given prompt was defined in any
|
|
1008
|
+
* Checks whether given prompt was defined in any pipeline in the collection
|
|
994
1009
|
*/
|
|
995
1010
|
SimplePipelineCollection.prototype.isResponsibleForPrompt = function (prompt) {
|
|
996
1011
|
return true;
|
|
@@ -1424,7 +1439,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1424
1439
|
});
|
|
1425
1440
|
}
|
|
1426
1441
|
|
|
1427
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
1442
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-17",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-17",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-17",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-17",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-17",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-17",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-17",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-17",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"}];
|
|
1428
1443
|
|
|
1429
1444
|
var defaultDiacriticsRemovalMap = [
|
|
1430
1445
|
{
|
|
@@ -2176,7 +2191,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
2176
2191
|
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors.map(function (error) { return "- ".concat(error.name || 'Error', ": ").concat(error.message); }).join('\n')), "\n\n "); }));
|
|
2177
2192
|
}
|
|
2178
2193
|
else {
|
|
2179
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
2194
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.llmExecutionTools
|
|
2180
2195
|
.map(function (tools) { return "- ".concat(tools.title, " ").concat(tools.description || ''); })
|
|
2181
2196
|
.join('\n')), "\n\n "); }));
|
|
2182
2197
|
}
|
|
@@ -2255,7 +2270,7 @@ function joinLlmExecutionTools() {
|
|
|
2255
2270
|
llmExecutionTools[_i] = arguments[_i];
|
|
2256
2271
|
}
|
|
2257
2272
|
if (llmExecutionTools.length === 0) {
|
|
2258
|
-
var warningMessage = spaceTrim("\n You have provided
|
|
2273
|
+
var warningMessage = spaceTrim("\n You have not provided any `LlmExecutionTools`\n This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.\n\n Technically, it's not an error, but it's probably not what you want because it does not make sense to use Promptbook without language models.\n ");
|
|
2259
2274
|
// TODO: [🟥] Detect browser / node and make it colorfull
|
|
2260
2275
|
console.warn(warningMessage);
|
|
2261
2276
|
/*
|
|
@@ -2418,7 +2433,7 @@ function replaceParameters(template, parameters) {
|
|
|
2418
2433
|
/**
|
|
2419
2434
|
* The version of the Promptbook library
|
|
2420
2435
|
*/
|
|
2421
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2436
|
+
var PROMPTBOOK_VERSION = '0.61.0-17';
|
|
2422
2437
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2423
2438
|
|
|
2424
2439
|
/**
|
|
@@ -5844,20 +5859,6 @@ var SimplePromptInterfaceTools = /** @class */ (function () {
|
|
|
5844
5859
|
* Note: [🔵] This code should never be published outside of `@promptbook/browser`
|
|
5845
5860
|
*/
|
|
5846
5861
|
|
|
5847
|
-
/**
|
|
5848
|
-
* Unprepare just strips the preparation data of the pipeline
|
|
5849
|
-
*/
|
|
5850
|
-
function unpreparePipeline(pipeline) {
|
|
5851
|
-
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources;
|
|
5852
|
-
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
5853
|
-
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
5854
|
-
return __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
|
|
5855
|
-
}
|
|
5856
|
-
/**
|
|
5857
|
-
* TODO: [🔼] !!! Export via `@promptbook/core`
|
|
5858
|
-
* TODO: Write tests for `preparePipeline`
|
|
5859
|
-
*/
|
|
5860
|
-
|
|
5861
5862
|
/**
|
|
5862
5863
|
* Default options for generating an execution report string
|
|
5863
5864
|
*/
|