@promptbook/core 0.63.3 → 0.64.0-0
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 +55 -46
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +9 -171
- package/esm/typings/src/_packages/node.index.d.ts +6 -0
- package/esm/typings/src/_packages/types.index.d.ts +5 -2
- package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/LlmConfiguration.d.ts +28 -0
- package/esm/typings/src/llm-providers/_common/LlmToolsConfiguration.d.ts +22 -0
- package/esm/typings/src/llm-providers/_common/config.d.ts +15 -0
- package/esm/typings/src/llm-providers/_common/createLlmToolsFromConfiguration.d.ts +32 -0
- package/esm/typings/src/llm-providers/_common/createLlmToolsFromConfigurationFromEnv.d.ts +23 -0
- package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +7 -22
- package/esm/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +1 -0
- package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +3 -2
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/prepare/preparePipeline.d.ts +1 -0
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +8 -2
- package/esm/typings/src/types/typeAliases.d.ts +2 -2
- package/esm/typings/src/utils/organization/TODO_string.d.ts +6 -0
- package/package.json +1 -1
- package/umd/index.umd.js +55 -46
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Promptbook library
|
|
18
18
|
*/
|
|
19
|
-
var PROMPTBOOK_VERSION = '0.63.
|
|
19
|
+
var PROMPTBOOK_VERSION = '0.63.4';
|
|
20
20
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
21
21
|
|
|
22
22
|
/*! *****************************************************************************
|
|
@@ -308,7 +308,7 @@
|
|
|
308
308
|
else if (blockType === 'PROMPT_DIALOG') {
|
|
309
309
|
commands_1.push("PROMPT DIALOG");
|
|
310
310
|
// Note: Nothing special here
|
|
311
|
-
} // <- }else if([
|
|
311
|
+
} // <- }else if([🅱]
|
|
312
312
|
if (jokers) {
|
|
313
313
|
try {
|
|
314
314
|
for (var jokers_1 = (e_4 = void 0, __values(jokers)), jokers_1_1 = jokers_1.next(); !jokers_1_1.done; jokers_1_1 = jokers_1.next()) {
|
|
@@ -1150,7 +1150,7 @@
|
|
|
1150
1150
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
1151
1151
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
1152
1152
|
var existing = this.collection.get(pipeline.pipelineUrl);
|
|
1153
|
-
throw new ReferenceError$1(spaceTrim.spaceTrim("\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 ")));
|
|
1153
|
+
throw new ReferenceError$1(spaceTrim.spaceTrim("\n Pipeline with URL \"".concat(pipeline.pipelineUrl, "\" is already in the collection \uD83C\uDF4E\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: You have probably forgotten to run \"ptbk make\" to update the collection\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
|
|
1154
1154
|
}
|
|
1155
1155
|
// Note: [🧠] Overwrite existing pipeline with the same URL
|
|
1156
1156
|
this.collection.set(pipeline.pipelineUrl, pipeline);
|
|
@@ -1432,7 +1432,7 @@
|
|
|
1432
1432
|
'KNOWLEDGE',
|
|
1433
1433
|
'INSTRUMENT',
|
|
1434
1434
|
'ACTION',
|
|
1435
|
-
// <- [
|
|
1435
|
+
// <- [🅱]
|
|
1436
1436
|
];
|
|
1437
1437
|
|
|
1438
1438
|
/**
|
|
@@ -1631,7 +1631,7 @@
|
|
|
1631
1631
|
});
|
|
1632
1632
|
}
|
|
1633
1633
|
|
|
1634
|
-
var PipelineCollection = [{pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",
|
|
1634
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.63.4",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.63.4",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.63.4",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.63.4",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1635
1635
|
|
|
1636
1636
|
var defaultDiacriticsRemovalMap = [
|
|
1637
1637
|
{
|
|
@@ -2245,6 +2245,8 @@
|
|
|
2245
2245
|
// <- Note: [🤖]
|
|
2246
2246
|
/**
|
|
2247
2247
|
* Calls the best available model
|
|
2248
|
+
*
|
|
2249
|
+
* Note: This should be private or protected but is public to be usable with duck typing
|
|
2248
2250
|
*/
|
|
2249
2251
|
MultipleLlmExecutionTools.prototype.callCommonModel = function (prompt) {
|
|
2250
2252
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3775,7 +3777,7 @@
|
|
|
3775
3777
|
var partialPieces, pieces;
|
|
3776
3778
|
return __generator(this, function (_a) {
|
|
3777
3779
|
switch (_a.label) {
|
|
3778
|
-
case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.
|
|
3780
|
+
case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.sourceContent, // <- TODO: [🐝] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
|
|
3779
3781
|
options)];
|
|
3780
3782
|
case 1:
|
|
3781
3783
|
partialPieces = _a.sent();
|
|
@@ -3965,6 +3967,35 @@
|
|
|
3965
3967
|
* TODO: [🏢] !! Check validity of `temperature` in pipeline
|
|
3966
3968
|
*/
|
|
3967
3969
|
|
|
3970
|
+
/**
|
|
3971
|
+
* @@@
|
|
3972
|
+
*
|
|
3973
|
+
* Note: It is usefull @@@
|
|
3974
|
+
*
|
|
3975
|
+
* @param pipeline
|
|
3976
|
+
* @public exported from `@promptbook/utils`
|
|
3977
|
+
*/
|
|
3978
|
+
function clonePipeline(pipeline) {
|
|
3979
|
+
// Note: Not using spread operator (...) because @@@
|
|
3980
|
+
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, promptbookVersion = pipeline.promptbookVersion, description = pipeline.description, parameters = pipeline.parameters, promptTemplates = pipeline.promptTemplates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
|
|
3981
|
+
return {
|
|
3982
|
+
pipelineUrl: pipelineUrl,
|
|
3983
|
+
sourceFile: sourceFile,
|
|
3984
|
+
title: title,
|
|
3985
|
+
promptbookVersion: promptbookVersion,
|
|
3986
|
+
description: description,
|
|
3987
|
+
parameters: parameters,
|
|
3988
|
+
promptTemplates: promptTemplates,
|
|
3989
|
+
knowledgeSources: knowledgeSources,
|
|
3990
|
+
knowledgePieces: knowledgePieces,
|
|
3991
|
+
personas: personas,
|
|
3992
|
+
preparations: preparations,
|
|
3993
|
+
};
|
|
3994
|
+
}
|
|
3995
|
+
/**
|
|
3996
|
+
* TODO: [🍙] Make some standart order of json properties
|
|
3997
|
+
*/
|
|
3998
|
+
|
|
3968
3999
|
/**
|
|
3969
4000
|
* @@@
|
|
3970
4001
|
*
|
|
@@ -4017,40 +4048,12 @@
|
|
|
4017
4048
|
* TODO: [🧠][🥜]
|
|
4018
4049
|
*/
|
|
4019
4050
|
|
|
4020
|
-
/**
|
|
4021
|
-
* @@@
|
|
4022
|
-
*
|
|
4023
|
-
* Note: It is usefull @@@
|
|
4024
|
-
*
|
|
4025
|
-
* @param pipeline
|
|
4026
|
-
* @public exported from `@promptbook/utils`
|
|
4027
|
-
*/
|
|
4028
|
-
function clonePipeline(pipeline) {
|
|
4029
|
-
// Note: Not using spread operator (...) because @@@
|
|
4030
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, promptbookVersion = pipeline.promptbookVersion, description = pipeline.description, parameters = pipeline.parameters, promptTemplates = pipeline.promptTemplates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
|
|
4031
|
-
return {
|
|
4032
|
-
pipelineUrl: pipelineUrl,
|
|
4033
|
-
sourceFile: sourceFile,
|
|
4034
|
-
title: title,
|
|
4035
|
-
promptbookVersion: promptbookVersion,
|
|
4036
|
-
description: description,
|
|
4037
|
-
parameters: parameters,
|
|
4038
|
-
promptTemplates: promptTemplates,
|
|
4039
|
-
knowledgeSources: knowledgeSources,
|
|
4040
|
-
knowledgePieces: knowledgePieces,
|
|
4041
|
-
personas: personas,
|
|
4042
|
-
preparations: preparations,
|
|
4043
|
-
};
|
|
4044
|
-
}
|
|
4045
|
-
/**
|
|
4046
|
-
* TODO: [🍙] Make some standart order of json properties
|
|
4047
|
-
*/
|
|
4048
|
-
|
|
4049
4051
|
/**
|
|
4050
4052
|
* Prepare pipeline from string (markdown) format to JSON format
|
|
4051
4053
|
*
|
|
4052
4054
|
* Note: This function does not validate logic of the pipeline
|
|
4053
4055
|
* Note: This function acts as part of compilation process
|
|
4056
|
+
* Note: When the pipeline is already prepared, it returns the same pipeline
|
|
4054
4057
|
* @public exported from `@promptbook/core`
|
|
4055
4058
|
*/
|
|
4056
4059
|
function preparePipeline(pipeline, options) {
|
|
@@ -4065,6 +4068,9 @@
|
|
|
4065
4068
|
return __generator(this, function (_c) {
|
|
4066
4069
|
switch (_c.label) {
|
|
4067
4070
|
case 0:
|
|
4071
|
+
if (isPipelinePrepared(pipeline)) {
|
|
4072
|
+
return [2 /*return*/, pipeline];
|
|
4073
|
+
}
|
|
4068
4074
|
llmTools = options.llmTools, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? false : _b;
|
|
4069
4075
|
parameters = pipeline.parameters, promptTemplates = pipeline.promptTemplates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
|
|
4070
4076
|
llmToolsWithUsage = countTotalUsage(llmTools);
|
|
@@ -4198,34 +4204,37 @@
|
|
|
4198
4204
|
*/
|
|
4199
4205
|
parse: function (input) {
|
|
4200
4206
|
var args = input.args;
|
|
4201
|
-
var
|
|
4202
|
-
if (
|
|
4207
|
+
var sourceContent = spaceTrim__default["default"](args[0] || '');
|
|
4208
|
+
if (sourceContent === '') {
|
|
4203
4209
|
throw new ParsingError("Source is not defined");
|
|
4204
4210
|
}
|
|
4205
|
-
|
|
4211
|
+
// TODO: !!!! Following checks should be applied every link in the `sourceContent`
|
|
4212
|
+
if (sourceContent.startsWith('http://')) {
|
|
4206
4213
|
throw new ParsingError("Source is not secure");
|
|
4207
4214
|
}
|
|
4208
|
-
if (!(isValidFilePath(
|
|
4215
|
+
if (!(isValidFilePath(sourceContent) || isValidUrl(sourceContent))) {
|
|
4209
4216
|
throw new ParsingError("Source not valid");
|
|
4210
4217
|
}
|
|
4211
|
-
if (
|
|
4218
|
+
if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
|
|
4212
4219
|
throw new ParsingError("Source cannot be outside of the .ptbk.md folder");
|
|
4213
4220
|
}
|
|
4214
4221
|
return {
|
|
4215
4222
|
type: 'KNOWLEDGE',
|
|
4216
|
-
|
|
4223
|
+
sourceContent: sourceContent,
|
|
4217
4224
|
};
|
|
4218
4225
|
},
|
|
4219
4226
|
/**
|
|
4220
4227
|
* Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
4221
4228
|
*/
|
|
4222
4229
|
applyToPipelineJson: function (personaCommand, subjects) {
|
|
4223
|
-
var
|
|
4230
|
+
var sourceContent = personaCommand.sourceContent;
|
|
4224
4231
|
var pipelineJson = subjects.pipelineJson;
|
|
4225
|
-
var name =
|
|
4232
|
+
var name = 'source-' + sha256__default["default"](hexEncoder__default["default"].parse(JSON.stringify(sourceContent))).toString( /* hex */);
|
|
4233
|
+
// <- TODO: [🥬] Encapsulate sha256 to some private utility function
|
|
4234
|
+
// <- TODO: This should be replaced with a better name later in preparation (done with some propper LLM summarization)
|
|
4226
4235
|
pipelineJson.knowledgeSources.push({
|
|
4227
4236
|
name: name,
|
|
4228
|
-
|
|
4237
|
+
sourceContent: sourceContent,
|
|
4229
4238
|
});
|
|
4230
4239
|
},
|
|
4231
4240
|
};
|
|
@@ -4427,7 +4436,7 @@
|
|
|
4427
4436
|
'KNOWLEDGE',
|
|
4428
4437
|
'INSTRUMENT',
|
|
4429
4438
|
'ACTION',
|
|
4430
|
-
// <- [
|
|
4439
|
+
// <- [🅱]
|
|
4431
4440
|
],
|
|
4432
4441
|
/**
|
|
4433
4442
|
* Aliases for the BLOCK command
|
|
@@ -5893,7 +5902,7 @@
|
|
|
5893
5902
|
if (command.blockType === 'KNOWLEDGE') {
|
|
5894
5903
|
knowledgeCommandParser.applyToPipelineJson({
|
|
5895
5904
|
type: 'KNOWLEDGE',
|
|
5896
|
-
|
|
5905
|
+
sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
|
|
5897
5906
|
}, {
|
|
5898
5907
|
pipelineJson: pipelineJson,
|
|
5899
5908
|
templateJson: templateJson,
|