@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/esm/index.es.js CHANGED
@@ -9,7 +9,7 @@ import moment from 'moment';
9
9
  /**
10
10
  * The version of the Promptbook library
11
11
  */
12
- var PROMPTBOOK_VERSION = '0.63.3';
12
+ var PROMPTBOOK_VERSION = '0.64.0-0';
13
13
  // TODO: !!!! List here all the versions and annotate + put into script
14
14
 
15
15
  /*! *****************************************************************************
@@ -301,7 +301,7 @@ function pipelineJsonToString(pipelineJson) {
301
301
  else if (blockType === 'PROMPT_DIALOG') {
302
302
  commands_1.push("PROMPT DIALOG");
303
303
  // Note: Nothing special here
304
- } // <- }else if([🩻]
304
+ } // <- }else if([🅱]
305
305
  if (jokers) {
306
306
  try {
307
307
  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()) {
@@ -1143,7 +1143,7 @@ var SimplePipelineCollection = /** @class */ (function () {
1143
1143
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
1144
1144
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
1145
1145
  var existing = this.collection.get(pipeline.pipelineUrl);
1146
- 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 ")));
1146
+ throw new ReferenceError$1(spaceTrim$1("\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 ")));
1147
1147
  }
1148
1148
  // Note: [🧠] Overwrite existing pipeline with the same URL
1149
1149
  this.collection.set(pipeline.pipelineUrl, pipeline);
@@ -1425,7 +1425,7 @@ var BlockTypes = [
1425
1425
  'KNOWLEDGE',
1426
1426
  'INSTRUMENT',
1427
1427
  'ACTION',
1428
- // <- [🩻]
1428
+ // <- [🅱]
1429
1429
  ];
1430
1430
 
1431
1431
  /**
@@ -1624,7 +1624,7 @@ function forEachAsync(array, options, callbackfunction) {
1624
1624
  });
1625
1625
  }
1626
1626
 
1627
- 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}}}}]}];
1627
+ 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"}];
1628
1628
 
1629
1629
  var defaultDiacriticsRemovalMap = [
1630
1630
  {
@@ -3770,7 +3770,7 @@ function prepareKnowledgePieces(knowledgeSources, options) {
3770
3770
  var partialPieces, pieces;
3771
3771
  return __generator(this, function (_a) {
3772
3772
  switch (_a.label) {
3773
- case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.source, // <- TODO: [🐝] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
3773
+ case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.sourceContent, // <- TODO: [🐝] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
3774
3774
  options)];
3775
3775
  case 1:
3776
3776
  partialPieces = _a.sent();
@@ -3960,6 +3960,35 @@ function preparePersona(personaDescription, options) {
3960
3960
  * TODO: [🏢] !! Check validity of `temperature` in pipeline
3961
3961
  */
3962
3962
 
3963
+ /**
3964
+ * @@@
3965
+ *
3966
+ * Note: It is usefull @@@
3967
+ *
3968
+ * @param pipeline
3969
+ * @public exported from `@promptbook/utils`
3970
+ */
3971
+ function clonePipeline(pipeline) {
3972
+ // Note: Not using spread operator (...) because @@@
3973
+ 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;
3974
+ return {
3975
+ pipelineUrl: pipelineUrl,
3976
+ sourceFile: sourceFile,
3977
+ title: title,
3978
+ promptbookVersion: promptbookVersion,
3979
+ description: description,
3980
+ parameters: parameters,
3981
+ promptTemplates: promptTemplates,
3982
+ knowledgeSources: knowledgeSources,
3983
+ knowledgePieces: knowledgePieces,
3984
+ personas: personas,
3985
+ preparations: preparations,
3986
+ };
3987
+ }
3988
+ /**
3989
+ * TODO: [🍙] Make some standart order of json properties
3990
+ */
3991
+
3963
3992
  /**
3964
3993
  * @@@
3965
3994
  *
@@ -4012,40 +4041,12 @@ function prepareTemplates(pipeline, options) {
4012
4041
  * TODO: [🧠][🥜]
4013
4042
  */
4014
4043
 
4015
- /**
4016
- * @@@
4017
- *
4018
- * Note: It is usefull @@@
4019
- *
4020
- * @param pipeline
4021
- * @public exported from `@promptbook/utils`
4022
- */
4023
- function clonePipeline(pipeline) {
4024
- // Note: Not using spread operator (...) because @@@
4025
- 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;
4026
- return {
4027
- pipelineUrl: pipelineUrl,
4028
- sourceFile: sourceFile,
4029
- title: title,
4030
- promptbookVersion: promptbookVersion,
4031
- description: description,
4032
- parameters: parameters,
4033
- promptTemplates: promptTemplates,
4034
- knowledgeSources: knowledgeSources,
4035
- knowledgePieces: knowledgePieces,
4036
- personas: personas,
4037
- preparations: preparations,
4038
- };
4039
- }
4040
- /**
4041
- * TODO: [🍙] Make some standart order of json properties
4042
- */
4043
-
4044
4044
  /**
4045
4045
  * Prepare pipeline from string (markdown) format to JSON format
4046
4046
  *
4047
4047
  * Note: This function does not validate logic of the pipeline
4048
4048
  * Note: This function acts as part of compilation process
4049
+ * Note: When the pipeline is already prepared, it returns the same pipeline
4049
4050
  * @public exported from `@promptbook/core`
4050
4051
  */
4051
4052
  function preparePipeline(pipeline, options) {
@@ -4060,6 +4061,9 @@ function preparePipeline(pipeline, options) {
4060
4061
  return __generator(this, function (_c) {
4061
4062
  switch (_c.label) {
4062
4063
  case 0:
4064
+ if (isPipelinePrepared(pipeline)) {
4065
+ return [2 /*return*/, pipeline];
4066
+ }
4063
4067
  llmTools = options.llmTools, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? false : _b;
4064
4068
  parameters = pipeline.parameters, promptTemplates = pipeline.promptTemplates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
4065
4069
  llmToolsWithUsage = countTotalUsage(llmTools);
@@ -4193,34 +4197,37 @@ var knowledgeCommandParser = {
4193
4197
  */
4194
4198
  parse: function (input) {
4195
4199
  var args = input.args;
4196
- var source = args[0];
4197
- if (source === undefined) {
4200
+ var sourceContent = spaceTrim(args[0] || '');
4201
+ if (sourceContent === '') {
4198
4202
  throw new ParsingError("Source is not defined");
4199
4203
  }
4200
- if (source.startsWith('http://')) {
4204
+ // TODO: !!!! Following checks should be applied every link in the `sourceContent`
4205
+ if (sourceContent.startsWith('http://')) {
4201
4206
  throw new ParsingError("Source is not secure");
4202
4207
  }
4203
- if (!(isValidFilePath(source) || isValidUrl(source))) {
4208
+ if (!(isValidFilePath(sourceContent) || isValidUrl(sourceContent))) {
4204
4209
  throw new ParsingError("Source not valid");
4205
4210
  }
4206
- if (source.startsWith('../') || source.startsWith('/') || /^[A-Z]:[\\/]+/i.test(source)) {
4211
+ if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
4207
4212
  throw new ParsingError("Source cannot be outside of the .ptbk.md folder");
4208
4213
  }
4209
4214
  return {
4210
4215
  type: 'KNOWLEDGE',
4211
- source: source,
4216
+ sourceContent: sourceContent,
4212
4217
  };
4213
4218
  },
4214
4219
  /**
4215
4220
  * Note: Prototype of [🍧] (remove this comment after full implementation)
4216
4221
  */
4217
4222
  applyToPipelineJson: function (personaCommand, subjects) {
4218
- var source = personaCommand.source;
4223
+ var sourceContent = personaCommand.sourceContent;
4219
4224
  var pipelineJson = subjects.pipelineJson;
4220
- var name = titleToName(source);
4225
+ var name = 'source-' + sha256(hexEncoder.parse(JSON.stringify(sourceContent))).toString( /* hex */);
4226
+ // <- TODO: [🥬] Encapsulate sha256 to some private utility function
4227
+ // <- TODO: This should be replaced with a better name later in preparation (done with some propper LLM summarization)
4221
4228
  pipelineJson.knowledgeSources.push({
4222
4229
  name: name,
4223
- source: source,
4230
+ sourceContent: sourceContent,
4224
4231
  });
4225
4232
  },
4226
4233
  };
@@ -4422,7 +4429,7 @@ var blockCommandParser = {
4422
4429
  'KNOWLEDGE',
4423
4430
  'INSTRUMENT',
4424
4431
  'ACTION',
4425
- // <- [🩻]
4432
+ // <- [🅱]
4426
4433
  ],
4427
4434
  /**
4428
4435
  * Aliases for the BLOCK command
@@ -5888,7 +5895,7 @@ function pipelineStringToJsonSync(pipelineString) {
5888
5895
  if (command.blockType === 'KNOWLEDGE') {
5889
5896
  knowledgeCommandParser.applyToPipelineJson({
5890
5897
  type: 'KNOWLEDGE',
5891
- source: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
5898
+ sourceContent: content, // <- TODO: [🐝] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
5892
5899
  }, {
5893
5900
  pipelineJson: pipelineJson,
5894
5901
  templateJson: templateJson,