@promptbook/remote-server 0.84.0-10 → 0.84.0-11

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 CHANGED
@@ -27,7 +27,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-9';
30
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-10';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1757,6 +1757,99 @@ function createLlmToolsFromConfiguration(configuration, options) {
1757
1757
 
1758
1758
  var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book.md`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",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}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\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- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `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### Key `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}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book.md`\n- INPUT PARAMETER `{availableModelNames}` List of available model names separated by comma (,)\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\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- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `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### Key `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}\n```\n\n`-> {modelRequirements}`\n"}],sourceFile:"./books/prepare-persona.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book.md",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book.md`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book.md"}];
1759
1759
 
1760
+ /**
1761
+ * Checks if value is valid email
1762
+ *
1763
+ * @public exported from `@promptbook/utils`
1764
+ */
1765
+ function isValidEmail(email) {
1766
+ if (typeof email !== 'string') {
1767
+ return false;
1768
+ }
1769
+ if (email.split('\n').length > 1) {
1770
+ return false;
1771
+ }
1772
+ return /^.+@.+\..+$/.test(email);
1773
+ }
1774
+
1775
+ /**
1776
+ * Tests if given string is valid URL.
1777
+ *
1778
+ * Note: This does not check if the file exists only if the path is valid
1779
+ * @public exported from `@promptbook/utils`
1780
+ */
1781
+ function isValidFilePath(filename) {
1782
+ if (typeof filename !== 'string') {
1783
+ return false;
1784
+ }
1785
+ if (filename.split('\n').length > 1) {
1786
+ return false;
1787
+ }
1788
+ if (filename.split(' ').length >
1789
+ 5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
1790
+ return false;
1791
+ }
1792
+ var filenameSlashes = filename.split('\\').join('/');
1793
+ // Absolute Unix path: /hello.txt
1794
+ if (/^(\/)/i.test(filenameSlashes)) {
1795
+ // console.log(filename, 'Absolute Unix path: /hello.txt');
1796
+ return true;
1797
+ }
1798
+ // Absolute Windows path: /hello.txt
1799
+ if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
1800
+ // console.log(filename, 'Absolute Windows path: /hello.txt');
1801
+ return true;
1802
+ }
1803
+ // Relative path: ./hello.txt
1804
+ if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
1805
+ // console.log(filename, 'Relative path: ./hello.txt');
1806
+ return true;
1807
+ }
1808
+ // Allow paths like foo/hello
1809
+ if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
1810
+ // console.log(filename, 'Allow paths like foo/hello');
1811
+ return true;
1812
+ }
1813
+ // Allow paths like hello.book
1814
+ if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
1815
+ // console.log(filename, 'Allow paths like hello.book');
1816
+ return true;
1817
+ }
1818
+ return false;
1819
+ }
1820
+ /**
1821
+ * TODO: [🍏] Implement for MacOs
1822
+ */
1823
+
1824
+ /**
1825
+ * Tests if given string is valid URL.
1826
+ *
1827
+ * Note: Dataurl are considered perfectly valid.
1828
+ * Note: There are two simmilar functions:
1829
+ * - `isValidUrl` which tests any URL
1830
+ * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
1831
+ *
1832
+ * @public exported from `@promptbook/utils`
1833
+ */
1834
+ function isValidUrl(url) {
1835
+ if (typeof url !== 'string') {
1836
+ return false;
1837
+ }
1838
+ try {
1839
+ if (url.startsWith('blob:')) {
1840
+ url = url.replace(/^blob:/, '');
1841
+ }
1842
+ var urlObject = new URL(url /* because fail is handled */);
1843
+ if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
1844
+ return false;
1845
+ }
1846
+ return true;
1847
+ }
1848
+ catch (error) {
1849
+ return false;
1850
+ }
1851
+ }
1852
+
1760
1853
  /**
1761
1854
  * Function isValidJsonString will tell you if the string is valid JSON or not
1762
1855
  *
@@ -1791,6 +1884,15 @@ function validatePipelineString(pipelineString) {
1791
1884
  if (isValidJsonString(pipelineString)) {
1792
1885
  throw new ParseError('Expected a book, but got a JSON string');
1793
1886
  }
1887
+ else if (isValidUrl(pipelineString)) {
1888
+ throw new ParseError("Expected a book, but got just the URL \"".concat(pipelineString, "\""));
1889
+ }
1890
+ else if (isValidFilePath(pipelineString)) {
1891
+ throw new ParseError("Expected a book, but got just the file path \"".concat(pipelineString, "\""));
1892
+ }
1893
+ else if (isValidEmail(pipelineString)) {
1894
+ throw new ParseError("Expected a book, but got just the email \"".concat(pipelineString, "\""));
1895
+ }
1794
1896
  // <- TODO: Implement the validation + add tests when the pipeline logic considered as invalid
1795
1897
  return pipelineString;
1796
1898
  }
@@ -2434,35 +2536,6 @@ function isUrlOnPrivateNetwork(url) {
2434
2536
  return isHostnameOnPrivateNetwork(url.hostname);
2435
2537
  }
2436
2538
 
2437
- /**
2438
- * Tests if given string is valid URL.
2439
- *
2440
- * Note: Dataurl are considered perfectly valid.
2441
- * Note: There are two simmilar functions:
2442
- * - `isValidUrl` which tests any URL
2443
- * - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
2444
- *
2445
- * @public exported from `@promptbook/utils`
2446
- */
2447
- function isValidUrl(url) {
2448
- if (typeof url !== 'string') {
2449
- return false;
2450
- }
2451
- try {
2452
- if (url.startsWith('blob:')) {
2453
- url = url.replace(/^blob:/, '');
2454
- }
2455
- var urlObject = new URL(url /* because fail is handled */);
2456
- if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
2457
- return false;
2458
- }
2459
- return true;
2460
- }
2461
- catch (error) {
2462
- return false;
2463
- }
2464
- }
2465
-
2466
2539
  /**
2467
2540
  * Tests if given string is valid pipeline URL URL.
2468
2541
  *
@@ -2962,12 +3035,28 @@ function deserializeError(error) {
2962
3035
  /**
2963
3036
  * Asserts that the execution of a Promptbook is successful
2964
3037
  *
3038
+ * Note: If there are only warnings, the execution is still successful but the warnings are logged in the console
3039
+ *
2965
3040
  * @param executionResult - The partial result of the Promptbook execution
2966
3041
  * @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
2967
3042
  * @public exported from `@promptbook/core`
2968
3043
  */
2969
3044
  function assertsExecutionSuccessful(executionResult) {
2970
- var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
3045
+ var e_1, _a;
3046
+ var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors, warnings = executionResult.warnings;
3047
+ try {
3048
+ for (var warnings_1 = __values(warnings), warnings_1_1 = warnings_1.next(); !warnings_1_1.done; warnings_1_1 = warnings_1.next()) {
3049
+ var warning = warnings_1_1.value;
3050
+ console.warn(warning.message);
3051
+ }
3052
+ }
3053
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3054
+ finally {
3055
+ try {
3056
+ if (warnings_1_1 && !warnings_1_1.done && (_a = warnings_1.return)) _a.call(warnings_1);
3057
+ }
3058
+ finally { if (e_1) throw e_1.error; }
3059
+ }
2971
3060
  if (isSuccessful === true) {
2972
3061
  return;
2973
3062
  }
@@ -6031,55 +6120,6 @@ function isFileExisting(filename, fs) {
6031
6120
  * TODO: [🖇] What about symlinks?
6032
6121
  */
6033
6122
 
6034
- /**
6035
- * Tests if given string is valid URL.
6036
- *
6037
- * Note: This does not check if the file exists only if the path is valid
6038
- * @public exported from `@promptbook/utils`
6039
- */
6040
- function isValidFilePath(filename) {
6041
- if (typeof filename !== 'string') {
6042
- return false;
6043
- }
6044
- if (filename.split('\n').length > 1) {
6045
- return false;
6046
- }
6047
- if (filename.split(' ').length >
6048
- 5 /* <- TODO: [🧠][🈷] Make some better non-arbitrary way how to distinct filenames from informational texts */) {
6049
- return false;
6050
- }
6051
- var filenameSlashes = filename.split('\\').join('/');
6052
- // Absolute Unix path: /hello.txt
6053
- if (/^(\/)/i.test(filenameSlashes)) {
6054
- // console.log(filename, 'Absolute Unix path: /hello.txt');
6055
- return true;
6056
- }
6057
- // Absolute Windows path: /hello.txt
6058
- if (/^([A-Z]{1,2}:\/?)\//i.test(filenameSlashes)) {
6059
- // console.log(filename, 'Absolute Windows path: /hello.txt');
6060
- return true;
6061
- }
6062
- // Relative path: ./hello.txt
6063
- if (/^(\.\.?\/)+/i.test(filenameSlashes)) {
6064
- // console.log(filename, 'Relative path: ./hello.txt');
6065
- return true;
6066
- }
6067
- // Allow paths like foo/hello
6068
- if (/^[^/]+\/[^/]+/i.test(filenameSlashes)) {
6069
- // console.log(filename, 'Allow paths like foo/hello');
6070
- return true;
6071
- }
6072
- // Allow paths like hello.book
6073
- if (/^[^/]+\.[^/]+$/i.test(filenameSlashes)) {
6074
- // console.log(filename, 'Allow paths like hello.book');
6075
- return true;
6076
- }
6077
- return false;
6078
- }
6079
- /**
6080
- * TODO: [🍏] Implement for MacOs
6081
- */
6082
-
6083
6123
  /**
6084
6124
  * The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
6085
6125
  *