@promptbook/core 0.63.4 → 0.65.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.
Files changed (24) hide show
  1. package/esm/index.es.js +53 -46
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/promptbook-collection/index.d.ts +9 -171
  4. package/esm/typings/src/_packages/node.index.d.ts +6 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +4 -2
  6. package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -2
  7. package/esm/typings/src/llm-providers/_common/LlmToolsConfiguration.d.ts +28 -0
  8. package/esm/typings/src/llm-providers/_common/config.d.ts +15 -0
  9. package/esm/typings/src/llm-providers/_common/createLlmToolsFromConfiguration.d.ts +32 -0
  10. package/esm/typings/src/llm-providers/_common/createLlmToolsFromConfigurationFromEnv.d.ts +23 -0
  11. package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +7 -22
  12. package/esm/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +1 -0
  13. package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +3 -2
  14. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -0
  15. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -0
  16. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -0
  17. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
  18. package/esm/typings/src/prepare/preparePipeline.d.ts +1 -0
  19. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +8 -2
  20. package/esm/typings/src/types/typeAliases.d.ts +2 -2
  21. package/esm/typings/src/utils/organization/TODO_string.d.ts +6 -0
  22. package/package.json +1 -1
  23. package/umd/index.umd.js +53 -46
  24. 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.3';
19
+ var PROMPTBOOK_VERSION = '0.64.0-0';
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",sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md",title:"Prepare Knowledge from Markdown",promptbookVersion:"0.63.3",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.3",usage:{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}}}}]},{pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md",title:"Prepare Keywords",promptbookVersion:"0.63.3",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.3",usage:{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}}}}]},{pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md",title:"Prepare Title",promptbookVersion:"0.63.3",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.3",usage:{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}}}}]},{pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",sourceFile:"./promptbook-collection/prepare-persona.ptbk.md",title:"Prepare Keywords",promptbookVersion:"0.63.3",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.63.3",usage:{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}}}}]}];
1634
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.64.0-0",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.64.0-0",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.64.0-0",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.64.0-0",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
  {
@@ -3777,7 +3777,7 @@
3777
3777
  var partialPieces, pieces;
3778
3778
  return __generator(this, function (_a) {
3779
3779
  switch (_a.label) {
3780
- case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.source, // <- TODO: [🐝] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
3780
+ case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.sourceContent, // <- TODO: [🐝] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
3781
3781
  options)];
3782
3782
  case 1:
3783
3783
  partialPieces = _a.sent();
@@ -3967,6 +3967,35 @@
3967
3967
  * TODO: [🏢] !! Check validity of `temperature` in pipeline
3968
3968
  */
3969
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
+
3970
3999
  /**
3971
4000
  * @@@
3972
4001
  *
@@ -4019,40 +4048,12 @@
4019
4048
  * TODO: [🧠][🥜]
4020
4049
  */
4021
4050
 
4022
- /**
4023
- * @@@
4024
- *
4025
- * Note: It is usefull @@@
4026
- *
4027
- * @param pipeline
4028
- * @public exported from `@promptbook/utils`
4029
- */
4030
- function clonePipeline(pipeline) {
4031
- // Note: Not using spread operator (...) because @@@
4032
- 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;
4033
- return {
4034
- pipelineUrl: pipelineUrl,
4035
- sourceFile: sourceFile,
4036
- title: title,
4037
- promptbookVersion: promptbookVersion,
4038
- description: description,
4039
- parameters: parameters,
4040
- promptTemplates: promptTemplates,
4041
- knowledgeSources: knowledgeSources,
4042
- knowledgePieces: knowledgePieces,
4043
- personas: personas,
4044
- preparations: preparations,
4045
- };
4046
- }
4047
- /**
4048
- * TODO: [🍙] Make some standart order of json properties
4049
- */
4050
-
4051
4051
  /**
4052
4052
  * Prepare pipeline from string (markdown) format to JSON format
4053
4053
  *
4054
4054
  * Note: This function does not validate logic of the pipeline
4055
4055
  * Note: This function acts as part of compilation process
4056
+ * Note: When the pipeline is already prepared, it returns the same pipeline
4056
4057
  * @public exported from `@promptbook/core`
4057
4058
  */
4058
4059
  function preparePipeline(pipeline, options) {
@@ -4067,6 +4068,9 @@
4067
4068
  return __generator(this, function (_c) {
4068
4069
  switch (_c.label) {
4069
4070
  case 0:
4071
+ if (isPipelinePrepared(pipeline)) {
4072
+ return [2 /*return*/, pipeline];
4073
+ }
4070
4074
  llmTools = options.llmTools, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? false : _b;
4071
4075
  parameters = pipeline.parameters, promptTemplates = pipeline.promptTemplates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
4072
4076
  llmToolsWithUsage = countTotalUsage(llmTools);
@@ -4200,34 +4204,37 @@
4200
4204
  */
4201
4205
  parse: function (input) {
4202
4206
  var args = input.args;
4203
- var source = args[0];
4204
- if (source === undefined) {
4207
+ var sourceContent = spaceTrim__default["default"](args[0] || '');
4208
+ if (sourceContent === '') {
4205
4209
  throw new ParsingError("Source is not defined");
4206
4210
  }
4207
- if (source.startsWith('http://')) {
4211
+ // TODO: !!!! Following checks should be applied every link in the `sourceContent`
4212
+ if (sourceContent.startsWith('http://')) {
4208
4213
  throw new ParsingError("Source is not secure");
4209
4214
  }
4210
- if (!(isValidFilePath(source) || isValidUrl(source))) {
4215
+ if (!(isValidFilePath(sourceContent) || isValidUrl(sourceContent))) {
4211
4216
  throw new ParsingError("Source not valid");
4212
4217
  }
4213
- if (source.startsWith('../') || source.startsWith('/') || /^[A-Z]:[\\/]+/i.test(source)) {
4218
+ if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
4214
4219
  throw new ParsingError("Source cannot be outside of the .ptbk.md folder");
4215
4220
  }
4216
4221
  return {
4217
4222
  type: 'KNOWLEDGE',
4218
- source: source,
4223
+ sourceContent: sourceContent,
4219
4224
  };
4220
4225
  },
4221
4226
  /**
4222
4227
  * Note: Prototype of [🍧] (remove this comment after full implementation)
4223
4228
  */
4224
4229
  applyToPipelineJson: function (personaCommand, subjects) {
4225
- var source = personaCommand.source;
4230
+ var sourceContent = personaCommand.sourceContent;
4226
4231
  var pipelineJson = subjects.pipelineJson;
4227
- var name = titleToName(source);
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)
4228
4235
  pipelineJson.knowledgeSources.push({
4229
4236
  name: name,
4230
- source: source,
4237
+ sourceContent: sourceContent,
4231
4238
  });
4232
4239
  },
4233
4240
  };
@@ -4429,7 +4436,7 @@
4429
4436
  'KNOWLEDGE',
4430
4437
  'INSTRUMENT',
4431
4438
  'ACTION',
4432
- // <- [🩻]
4439
+ // <- [🅱]
4433
4440
  ],
4434
4441
  /**
4435
4442
  * Aliases for the BLOCK command
@@ -5895,7 +5902,7 @@
5895
5902
  if (command.blockType === 'KNOWLEDGE') {
5896
5903
  knowledgeCommandParser.applyToPipelineJson({
5897
5904
  type: 'KNOWLEDGE',
5898
- source: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
5905
+ sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
5899
5906
  }, {
5900
5907
  pipelineJson: pipelineJson,
5901
5908
  templateJson: templateJson,