@promptbook/website-crawler 0.80.0-1 → 0.81.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/README.md +3 -0
- package/esm/index.es.js +149 -19
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +15 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -6
- package/esm/typings/src/_packages/editable.index.d.ts +10 -0
- package/esm/typings/src/_packages/templates.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +6 -0
- package/esm/typings/src/_packages/utils.index.d.ts +10 -2
- package/esm/typings/src/_packages/wizzard.index.d.ts +44 -0
- package/esm/typings/src/config.d.ts +26 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +7 -0
- package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -2
- package/esm/typings/src/execution/PromptbookFetch.d.ts +5 -0
- package/esm/typings/src/execution/PromptbookFetch.test-type.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -2
- package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +2 -1
- package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +2 -1
- package/esm/typings/src/high-level-abstractions/index.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/register/{$provideLlmToolsForCli.d.ts → $provideLlmToolsForWizzardOrCli.d.ts} +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +2 -0
- package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -0
- package/esm/typings/src/other/templates/getBookTemplate.d.ts +21 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +10 -0
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +10 -0
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +7 -0
- package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +8 -0
- package/esm/typings/src/utils/editable/types/PipelineEditableSerialized.d.ts +27 -0
- package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.d.ts +3 -3
- package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.d.ts +3 -3
- package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.d.ts +2 -2
- package/esm/typings/src/utils/parameters/numberToString.d.ts +7 -0
- package/esm/typings/src/utils/parameters/{replaceParameters.d.ts → templateParameters.d.ts} +6 -2
- package/esm/typings/src/utils/parameters/valueToString.d.ts +17 -0
- package/esm/typings/src/utils/parameters/valueToString.test.d.ts +1 -0
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +4 -0
- package/esm/typings/src/version.d.ts +7 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +51 -0
- package/package.json +2 -2
- package/umd/index.umd.js +149 -19
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/utils/formatNumber.d.ts +0 -6
- /package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.test.d.ts +0 -0
- /package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.test.d.ts +0 -0
- /package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.test.d.ts +0 -0
- /package/esm/typings/src/utils/{formatNumber.test.d.ts → parameters/numberToString.test.d.ts} +0 -0
- /package/esm/typings/src/utils/parameters/{replaceParameters.test.d.ts → templateParameters.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -231,6 +231,7 @@ Or you can install them separately:
|
|
|
231
231
|
|
|
232
232
|
- ⭐ **[ptbk](https://www.npmjs.com/package/ptbk)** - Bundle of all packages, when you want to install everything and you don't care about the size
|
|
233
233
|
- **[promptbook](https://www.npmjs.com/package/promptbook)** - Same as `ptbk`
|
|
234
|
+
- ⭐🧙♂️ **[@promptbook/wizzard](https://www.npmjs.com/package/@promptbook/wizzard)** - Wizzard to just run the books in node without any struggle
|
|
234
235
|
- **[@promptbook/core](https://www.npmjs.com/package/@promptbook/core)** - Core of the library, it contains the main logic for promptbooks
|
|
235
236
|
- **[@promptbook/node](https://www.npmjs.com/package/@promptbook/node)** - Core of the library for Node.js environment
|
|
236
237
|
- **[@promptbook/browser](https://www.npmjs.com/package/@promptbook/browser)** - Core of the library for browser environment
|
|
@@ -251,6 +252,8 @@ Or you can install them separately:
|
|
|
251
252
|
- **[@promptbook/documents](https://www.npmjs.com/package/@promptbook/documents)** - Read knowledge from documents like `.docx`, `.odt`,…
|
|
252
253
|
- **[@promptbook/legacy-documents](https://www.npmjs.com/package/@promptbook/legacy-documents)** - Read knowledge from legacy documents like `.doc`, `.rtf`,…
|
|
253
254
|
- **[@promptbook/website-crawler](https://www.npmjs.com/package/@promptbook/website-crawler)** - Crawl knowledge from the web
|
|
255
|
+
- **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API
|
|
256
|
+
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Usefull templates and examples of books which can be used as a starting point
|
|
254
257
|
- **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
|
|
255
258
|
- **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
256
259
|
|
package/esm/index.es.js
CHANGED
|
@@ -16,15 +16,17 @@ import { Converter } from 'showdown';
|
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Book language
|
|
18
18
|
*
|
|
19
|
+
* @generated
|
|
19
20
|
* @see https://github.com/webgptorg/book
|
|
20
21
|
*/
|
|
21
22
|
var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
22
23
|
/**
|
|
23
24
|
* The version of the Promptbook engine
|
|
24
25
|
*
|
|
26
|
+
* @generated
|
|
25
27
|
* @see https://github.com/webgptorg/promptbook
|
|
26
28
|
*/
|
|
27
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
29
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-10';
|
|
28
30
|
/**
|
|
29
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -234,6 +236,26 @@ var ADMIN_GITHUB_NAME = 'hejny';
|
|
|
234
236
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
235
237
|
*/
|
|
236
238
|
var LOOP_LIMIT = 1000;
|
|
239
|
+
/**
|
|
240
|
+
* Strings to represent various values in the context of parameter values
|
|
241
|
+
*
|
|
242
|
+
* @public exported from `@promptbook/utils`
|
|
243
|
+
*/
|
|
244
|
+
var VALUE_STRINGS = {
|
|
245
|
+
empty: '(nothing; empty string)',
|
|
246
|
+
null: '(no value; null)',
|
|
247
|
+
undefined: '(unknown value; undefined)',
|
|
248
|
+
nan: '(not a number; NaN)',
|
|
249
|
+
infinity: '(infinity; ∞)',
|
|
250
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
251
|
+
unserializable: '(unserializable value)',
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Small number limit
|
|
255
|
+
*
|
|
256
|
+
* @public exported from `@promptbook/utils`
|
|
257
|
+
*/
|
|
258
|
+
var SMALL_NUMBER = 0.001;
|
|
237
259
|
/**
|
|
238
260
|
* Short time interval to prevent race conditions in milliseconds
|
|
239
261
|
*
|
|
@@ -526,6 +548,7 @@ var websiteScraperMetadata = $deepFreeze({
|
|
|
526
548
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
527
549
|
*
|
|
528
550
|
* @public exported from `@promptbook/core`
|
|
551
|
+
* @public exported from `@promptbook/wizzard`
|
|
529
552
|
* @public exported from `@promptbook/cli`
|
|
530
553
|
*/
|
|
531
554
|
$scrapersMetadataRegister.register(websiteScraperMetadata);
|
|
@@ -1063,7 +1086,7 @@ function getScraperIntermediateSource(source, options) {
|
|
|
1063
1086
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1064
1087
|
*/
|
|
1065
1088
|
|
|
1066
|
-
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:[],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:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare 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- Title should be concise and clear\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:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",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:[],sourceFile:"./books/prepare-persona.book.md"}];
|
|
1089
|
+
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 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- Title should be concise and clear\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 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- Title should be concise and clear\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 Keywords",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 Keywords\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"}];
|
|
1067
1090
|
|
|
1068
1091
|
/**
|
|
1069
1092
|
* Prettify the html code
|
|
@@ -1515,6 +1538,7 @@ function exportJson(options) {
|
|
|
1515
1538
|
* @public exported from `@promptbook/core`
|
|
1516
1539
|
*/
|
|
1517
1540
|
var ORDER_OF_PIPELINE_JSON = [
|
|
1541
|
+
// Note: [🍙] In this order will be pipeline serialized
|
|
1518
1542
|
'title',
|
|
1519
1543
|
'pipelineUrl',
|
|
1520
1544
|
'bookVersion',
|
|
@@ -1526,6 +1550,7 @@ var ORDER_OF_PIPELINE_JSON = [
|
|
|
1526
1550
|
'preparations',
|
|
1527
1551
|
'knowledgeSources',
|
|
1528
1552
|
'knowledgePieces',
|
|
1553
|
+
'sources', // <- TODO: [🧠] Where should the `sources` be
|
|
1529
1554
|
];
|
|
1530
1555
|
/**
|
|
1531
1556
|
* Nonce which is used for replacing things in strings
|
|
@@ -1713,9 +1738,6 @@ function isValidPipelineUrl(url) {
|
|
|
1713
1738
|
if (!url.startsWith('https://')) {
|
|
1714
1739
|
return false;
|
|
1715
1740
|
}
|
|
1716
|
-
if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
|
|
1717
|
-
return false;
|
|
1718
|
-
}
|
|
1719
1741
|
if (url.includes('#')) {
|
|
1720
1742
|
// TODO: [🐠]
|
|
1721
1743
|
return false;
|
|
@@ -2461,6 +2483,81 @@ function isPipelinePrepared(pipeline) {
|
|
|
2461
2483
|
* - [♨] Are tasks prepared
|
|
2462
2484
|
*/
|
|
2463
2485
|
|
|
2486
|
+
/**
|
|
2487
|
+
* Format either small or big number
|
|
2488
|
+
*
|
|
2489
|
+
* @public exported from `@promptbook/utils`
|
|
2490
|
+
*/
|
|
2491
|
+
function numberToString(value) {
|
|
2492
|
+
if (value === 0) {
|
|
2493
|
+
return '0';
|
|
2494
|
+
}
|
|
2495
|
+
else if (Number.isNaN(value)) {
|
|
2496
|
+
return VALUE_STRINGS.nan;
|
|
2497
|
+
}
|
|
2498
|
+
else if (value === Infinity) {
|
|
2499
|
+
return VALUE_STRINGS.infinity;
|
|
2500
|
+
}
|
|
2501
|
+
else if (value === -Infinity) {
|
|
2502
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
2503
|
+
}
|
|
2504
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
2505
|
+
var factor = Math.pow(10, exponent);
|
|
2506
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
2507
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
2508
|
+
return valueRounded.toFixed(exponent);
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
return value.toString();
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2514
|
+
/**
|
|
2515
|
+
* Function `valueToString` will convert the given value to string
|
|
2516
|
+
* This is useful and used in the `templateParameters` function
|
|
2517
|
+
*
|
|
2518
|
+
* Note: This function is not just calling `toString` method
|
|
2519
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
2520
|
+
* See `VALUE_STRINGS`
|
|
2521
|
+
*
|
|
2522
|
+
* Note: There are 2 similar functions
|
|
2523
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
2524
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
2525
|
+
*
|
|
2526
|
+
* @public exported from `@promptbook/utils`
|
|
2527
|
+
*/
|
|
2528
|
+
function valueToString(value) {
|
|
2529
|
+
try {
|
|
2530
|
+
if (value === '') {
|
|
2531
|
+
return VALUE_STRINGS.empty;
|
|
2532
|
+
}
|
|
2533
|
+
else if (value === null) {
|
|
2534
|
+
return VALUE_STRINGS.null;
|
|
2535
|
+
}
|
|
2536
|
+
else if (value === undefined) {
|
|
2537
|
+
return VALUE_STRINGS.undefined;
|
|
2538
|
+
}
|
|
2539
|
+
else if (typeof value === 'string') {
|
|
2540
|
+
return value;
|
|
2541
|
+
}
|
|
2542
|
+
else if (typeof value === 'number') {
|
|
2543
|
+
return numberToString(value);
|
|
2544
|
+
}
|
|
2545
|
+
else if (value instanceof Date) {
|
|
2546
|
+
return value.toISOString();
|
|
2547
|
+
}
|
|
2548
|
+
else {
|
|
2549
|
+
return JSON.stringify(value);
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
catch (error) {
|
|
2553
|
+
if (!(error instanceof Error)) {
|
|
2554
|
+
throw error;
|
|
2555
|
+
}
|
|
2556
|
+
console.error(error);
|
|
2557
|
+
return VALUE_STRINGS.unserializable;
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2464
2561
|
/**
|
|
2465
2562
|
* Serializes an error into a [🚉] JSON-serializable object
|
|
2466
2563
|
*
|
|
@@ -3356,6 +3453,30 @@ function isFileExisting(filename, fs) {
|
|
|
3356
3453
|
* TODO: [🖇] What about symlinks?
|
|
3357
3454
|
*/
|
|
3358
3455
|
|
|
3456
|
+
/**
|
|
3457
|
+
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
3458
|
+
*
|
|
3459
|
+
* @private as default `fetch` function used in Promptbook scrapers
|
|
3460
|
+
*/
|
|
3461
|
+
var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3462
|
+
var error_1;
|
|
3463
|
+
return __generator(this, function (_a) {
|
|
3464
|
+
switch (_a.label) {
|
|
3465
|
+
case 0:
|
|
3466
|
+
_a.trys.push([0, 2, , 3]);
|
|
3467
|
+
return [4 /*yield*/, fetch(url, init)];
|
|
3468
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
3469
|
+
case 2:
|
|
3470
|
+
error_1 = _a.sent();
|
|
3471
|
+
if (!(error_1 instanceof Error)) {
|
|
3472
|
+
throw error_1;
|
|
3473
|
+
}
|
|
3474
|
+
throw new KnowledgeScrapeError(spaceTrim$1(function (block) { return "\n Can not fetch \"".concat(url, "\"\n\n Fetch error:\n ").concat(block(error_1.message), "\n\n "); }));
|
|
3475
|
+
case 3: return [2 /*return*/];
|
|
3476
|
+
}
|
|
3477
|
+
});
|
|
3478
|
+
}); };
|
|
3479
|
+
|
|
3359
3480
|
/**
|
|
3360
3481
|
* @@@
|
|
3361
3482
|
*
|
|
@@ -3364,13 +3485,14 @@ function isFileExisting(filename, fs) {
|
|
|
3364
3485
|
function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
3365
3486
|
var _a;
|
|
3366
3487
|
return __awaiter(this, void 0, void 0, function () {
|
|
3367
|
-
var sourceContent, name,
|
|
3368
|
-
return __generator(this, function (
|
|
3369
|
-
switch (
|
|
3488
|
+
var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
|
|
3489
|
+
return __generator(this, function (_f) {
|
|
3490
|
+
switch (_f.label) {
|
|
3370
3491
|
case 0:
|
|
3492
|
+
_b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
|
|
3371
3493
|
sourceContent = knowledgeSource.sourceContent;
|
|
3372
3494
|
name = knowledgeSource.name;
|
|
3373
|
-
|
|
3495
|
+
_c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
|
|
3374
3496
|
if (!name) {
|
|
3375
3497
|
name = sourceContentToName(sourceContent);
|
|
3376
3498
|
}
|
|
@@ -3378,7 +3500,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3378
3500
|
url = sourceContent;
|
|
3379
3501
|
return [4 /*yield*/, fetch(url)];
|
|
3380
3502
|
case 1:
|
|
3381
|
-
response_1 =
|
|
3503
|
+
response_1 = _f.sent();
|
|
3382
3504
|
mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
|
|
3383
3505
|
return [2 /*return*/, {
|
|
3384
3506
|
source: name,
|
|
@@ -3435,7 +3557,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
3435
3557
|
mimeType = extensionToMimeType(fileExtension || '');
|
|
3436
3558
|
return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
|
|
3437
3559
|
case 3:
|
|
3438
|
-
if (!(
|
|
3560
|
+
if (!(_f.sent())) {
|
|
3439
3561
|
throw new NotFoundError(spaceTrim$1(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
|
|
3440
3562
|
}
|
|
3441
3563
|
// TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
|
|
@@ -4466,13 +4588,16 @@ function extractJsonBlock(markdown) {
|
|
|
4466
4588
|
/**
|
|
4467
4589
|
* Replaces parameters in template with values from parameters object
|
|
4468
4590
|
*
|
|
4591
|
+
* Note: This function is not places strings into string,
|
|
4592
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
4593
|
+
*
|
|
4469
4594
|
* @param template the template with parameters in {curly} braces
|
|
4470
4595
|
* @param parameters the object with parameters
|
|
4471
4596
|
* @returns the template with replaced parameters
|
|
4472
4597
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
4473
4598
|
* @public exported from `@promptbook/utils`
|
|
4474
4599
|
*/
|
|
4475
|
-
function
|
|
4600
|
+
function templateParameters(template, parameters) {
|
|
4476
4601
|
var e_1, _a;
|
|
4477
4602
|
try {
|
|
4478
4603
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -4498,7 +4623,7 @@ function replaceParameters(template, parameters) {
|
|
|
4498
4623
|
var loopLimit = LOOP_LIMIT;
|
|
4499
4624
|
var _loop_1 = function () {
|
|
4500
4625
|
if (loopLimit-- < 0) {
|
|
4501
|
-
throw new LimitReachedError('Loop limit reached during parameters replacement in `
|
|
4626
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
|
|
4502
4627
|
}
|
|
4503
4628
|
var precol = match.groups.precol;
|
|
4504
4629
|
var parameterName = match.groups.parameterName;
|
|
@@ -4515,7 +4640,7 @@ function replaceParameters(template, parameters) {
|
|
|
4515
4640
|
if (parameterValue === undefined) {
|
|
4516
4641
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
4517
4642
|
}
|
|
4518
|
-
parameterValue = parameterValue
|
|
4643
|
+
parameterValue = valueToString(parameterValue);
|
|
4519
4644
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
4520
4645
|
parameterValue = parameterValue
|
|
4521
4646
|
.split('\n')
|
|
@@ -4750,7 +4875,7 @@ function executeAttempts(options) {
|
|
|
4750
4875
|
}
|
|
4751
4876
|
return [3 /*break*/, 24];
|
|
4752
4877
|
case 2:
|
|
4753
|
-
$ongoingTaskResult.$resultString =
|
|
4878
|
+
$ongoingTaskResult.$resultString = templateParameters(preparedContent, parameters);
|
|
4754
4879
|
return [3 /*break*/, 25];
|
|
4755
4880
|
case 3:
|
|
4756
4881
|
modelRequirements = __assign(__assign({ modelVariant: 'CHAT' }, (preparedPipeline.defaultModelRequirements || {})), (task.modelRequirements || {}));
|
|
@@ -4873,8 +4998,8 @@ function executeAttempts(options) {
|
|
|
4873
4998
|
_j = $ongoingTaskResult;
|
|
4874
4999
|
return [4 /*yield*/, tools.userInterface.promptDialog($deepFreeze({
|
|
4875
5000
|
promptTitle: task.title,
|
|
4876
|
-
promptMessage:
|
|
4877
|
-
defaultValue:
|
|
5001
|
+
promptMessage: templateParameters(task.description || '', parameters),
|
|
5002
|
+
defaultValue: templateParameters(preparedContent, parameters),
|
|
4878
5003
|
// TODO: [🧠] !! Figure out how to define placeholder in .book.md file
|
|
4879
5004
|
placeholder: undefined,
|
|
4880
5005
|
priority: priority,
|
|
@@ -4998,7 +5123,7 @@ function executeAttempts(options) {
|
|
|
4998
5123
|
if (!isJokerAttempt &&
|
|
4999
5124
|
task.taskType === 'PROMPT_TASK' &&
|
|
5000
5125
|
$ongoingTaskResult.$prompt
|
|
5001
|
-
// <- Note: [2] When some expected parameter is not defined, error will occur in
|
|
5126
|
+
// <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
5002
5127
|
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
5003
5128
|
) {
|
|
5004
5129
|
// TODO: [🧠] Maybe put other taskTypes into report
|
|
@@ -5575,7 +5700,10 @@ function executePipeline(options) {
|
|
|
5575
5700
|
finally { if (e_2) throw e_2.error; }
|
|
5576
5701
|
return [7 /*endfinally*/];
|
|
5577
5702
|
case 19:
|
|
5578
|
-
parametersToPass = inputParameters
|
|
5703
|
+
parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
|
|
5704
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
5705
|
+
return [key, valueToString(value)];
|
|
5706
|
+
}));
|
|
5579
5707
|
_g.label = 20;
|
|
5580
5708
|
case 20:
|
|
5581
5709
|
_g.trys.push([20, 25, , 28]);
|
|
@@ -5830,6 +5958,7 @@ var markdownScraperMetadata = $deepFreeze({
|
|
|
5830
5958
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
5831
5959
|
*
|
|
5832
5960
|
* @public exported from `@promptbook/core`
|
|
5961
|
+
* @public exported from `@promptbook/wizzard`
|
|
5833
5962
|
* @public exported from `@promptbook/cli`
|
|
5834
5963
|
*/
|
|
5835
5964
|
$scrapersMetadataRegister.register(markdownScraperMetadata);
|
|
@@ -6173,6 +6302,7 @@ var createWebsiteScraper = Object.assign(function (tools, options) {
|
|
|
6173
6302
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
6174
6303
|
*
|
|
6175
6304
|
* @public exported from `@promptbook/website-crawler`
|
|
6305
|
+
* @public exported from `@promptbook/wizzard`
|
|
6176
6306
|
* @public exported from `@promptbook/cli`
|
|
6177
6307
|
*/
|
|
6178
6308
|
var _WebsiteScraperRegistration = $scrapersRegister.register(createWebsiteScraper);
|