@promptbook/core 0.89.0 → 0.92.0-10

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 (27) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +309 -37
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +6 -0
  5. package/esm/typings/src/_packages/deepseek.index.d.ts +2 -0
  6. package/esm/typings/src/_packages/google.index.d.ts +2 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  8. package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +1 -1
  9. package/esm/typings/src/conversion/archive/loadArchive.d.ts +2 -2
  10. package/esm/typings/src/execution/CommonToolsOptions.d.ts +4 -0
  11. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +12 -0
  12. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +5 -0
  13. package/esm/typings/src/formats/csv/utils/csvParse.d.ts +12 -0
  14. package/esm/typings/src/formats/json/utils/jsonParse.d.ts +11 -0
  15. package/esm/typings/src/llm-providers/_common/filterModels.d.ts +15 -0
  16. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +43 -0
  17. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -0
  18. package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +23 -0
  19. package/esm/typings/src/llm-providers/google/google-models.d.ts +23 -0
  20. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +4 -0
  21. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  22. package/esm/typings/src/pipeline/PipelineJson/PersonaJson.d.ts +4 -2
  23. package/esm/typings/src/remote-server/openapi-types.d.ts +348 -6
  24. package/esm/typings/src/remote-server/openapi.d.ts +397 -3
  25. package/package.json +1 -1
  26. package/umd/index.umd.js +311 -36
  27. package/umd/index.umd.js.map +1 -1
package/README.md CHANGED
@@ -23,6 +23,10 @@
23
23
 
24
24
 
25
25
 
26
+ <blockquote style="color: #ff8811">
27
+ <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
28
+ </blockquote>
29
+
26
30
  ## 📦 Package `@promptbook/core`
27
31
 
28
32
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
package/esm/index.es.js CHANGED
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.89.0';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.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
@@ -1554,7 +1554,7 @@ function extractParameterNames(template) {
1554
1554
  */
1555
1555
  function unpreparePipeline(pipeline) {
1556
1556
  let { personas, knowledgeSources, tasks } = pipeline;
1557
- personas = personas.map((persona) => ({ ...persona, modelRequirements: undefined, preparationIds: undefined }));
1557
+ personas = personas.map((persona) => ({ ...persona, modelsRequirements: undefined, preparationIds: undefined }));
1558
1558
  knowledgeSources = knowledgeSources.map((knowledgeSource) => ({ ...knowledgeSource, preparationIds: undefined }));
1559
1559
  tasks = tasks.map((task) => {
1560
1560
  let { dependentParameterNames } = task;
@@ -1821,7 +1821,7 @@ function createSubcollection(collection, predicate) {
1821
1821
  };
1822
1822
  }
1823
1823
 
1824
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",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`\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"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",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`\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"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",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`\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"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",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`\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"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",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`\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"}];
1824
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",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`\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"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",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`\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"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",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`\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"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with 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\nHere are the available models:\n\n```json\n{availableModels}\n```\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:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with 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\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\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`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",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`\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"}];
1825
1825
 
1826
1826
  /**
1827
1827
  * This error type indicates that some tools are missing for pipeline execution or preparation
@@ -1854,7 +1854,7 @@ function isPipelinePrepared(pipeline) {
1854
1854
  if (pipeline.title === undefined || pipeline.title === '' || pipeline.title === DEFAULT_BOOK_TITLE) {
1855
1855
  return false;
1856
1856
  }
1857
- if (!pipeline.personas.every((persona) => persona.modelRequirements !== undefined)) {
1857
+ if (!pipeline.personas.every((persona) => persona.modelsRequirements !== undefined)) {
1858
1858
  return false;
1859
1859
  }
1860
1860
  if (!pipeline.knowledgeSources.every((knowledgeSource) => knowledgeSource.preparationIds !== undefined)) {
@@ -1893,6 +1893,45 @@ function $randomToken(randomness) {
1893
1893
  * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
1894
1894
  */
1895
1895
 
1896
+ /**
1897
+ * Converts a JavaScript Object Notation (JSON) string into an object.
1898
+ *
1899
+ * Note: This is wrapper around `JSON.parse()` with better error and type handling
1900
+ *
1901
+ * @public exported from `@promptbook/utils`
1902
+ */
1903
+ function jsonParse(value) {
1904
+ if (value === undefined) {
1905
+ throw new Error(`Can not parse JSON from undefined value.`);
1906
+ }
1907
+ else if (typeof value !== 'string') {
1908
+ console.error('Can not parse JSON from non-string value.', { text: value });
1909
+ throw new Error(spaceTrim(`
1910
+ Can not parse JSON from non-string value.
1911
+
1912
+ The value type: ${typeof value}
1913
+ See more in console.
1914
+ `));
1915
+ }
1916
+ try {
1917
+ return JSON.parse(value);
1918
+ }
1919
+ catch (error) {
1920
+ if (!(error instanceof Error)) {
1921
+ throw error;
1922
+ }
1923
+ throw new Error(spaceTrim((block) => `
1924
+ ${block(error.message)}
1925
+
1926
+ The JSON text:
1927
+ ${block(value)}
1928
+ `));
1929
+ }
1930
+ }
1931
+ /**
1932
+ * TODO: !!!! Use in Promptbook.studio
1933
+ */
1934
+
1896
1935
  /**
1897
1936
  * Recursively converts JSON strings to JSON objects
1898
1937
 
@@ -1911,7 +1950,7 @@ function jsonStringsToJsons(object) {
1911
1950
  const newObject = { ...object };
1912
1951
  for (const [key, value] of Object.entries(object)) {
1913
1952
  if (typeof value === 'string' && isValidJsonString(value)) {
1914
- newObject[key] = JSON.parse(value);
1953
+ newObject[key] = jsonParse(value);
1915
1954
  }
1916
1955
  else {
1917
1956
  newObject[key] = jsonStringsToJsons(value);
@@ -2733,6 +2772,24 @@ function isValidCsvString(value) {
2733
2772
  }
2734
2773
  }
2735
2774
 
2775
+ /**
2776
+ * Converts a CSV string into an object
2777
+ *
2778
+ * Note: This is wrapper around `papaparse.parse()` with better autohealing
2779
+ *
2780
+ * @private - for now until `@promptbook/csv` is released
2781
+ */
2782
+ function csvParse(value /* <- TODO: string_csv */, settings, schema /* <- TODO: Make CSV Schemas */) {
2783
+ settings = { ...settings, ...MANDATORY_CSV_SETTINGS };
2784
+ // Note: Autoheal invalid '\n' characters
2785
+ if (settings.newline && !settings.newline.includes('\r') && value.includes('\r')) {
2786
+ console.warn('CSV string contains carriage return characters, but in the CSV settings the `newline` setting does not include them. Autohealing the CSV string.');
2787
+ value = value.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
2788
+ }
2789
+ const csv = parse(value, settings);
2790
+ return csv;
2791
+ }
2792
+
2736
2793
  /**
2737
2794
  * Definition for CSV spreadsheet
2738
2795
  *
@@ -2755,8 +2812,7 @@ const CsvFormatDefinition = {
2755
2812
  {
2756
2813
  subvalueName: 'ROW',
2757
2814
  async mapValues(value, outputParameterName, settings, mapCallback) {
2758
- // TODO: [👨🏾‍🤝‍👨🏼] DRY csv parsing
2759
- const csv = parse(value, { ...settings, ...MANDATORY_CSV_SETTINGS });
2815
+ const csv = csvParse(value, settings);
2760
2816
  if (csv.errors.length !== 0) {
2761
2817
  throw new CsvFormatError(spaceTrim((block) => `
2762
2818
  CSV parsing error
@@ -2786,8 +2842,7 @@ const CsvFormatDefinition = {
2786
2842
  {
2787
2843
  subvalueName: 'CELL',
2788
2844
  async mapValues(value, outputParameterName, settings, mapCallback) {
2789
- // TODO: [👨🏾‍🤝‍👨🏼] DRY csv parsing
2790
- const csv = parse(value, { ...settings, ...MANDATORY_CSV_SETTINGS });
2845
+ const csv = csvParse(value, settings);
2791
2846
  if (csv.errors.length !== 0) {
2792
2847
  throw new CsvFormatError(spaceTrim((block) => `
2793
2848
  CSV parsing error
@@ -4327,13 +4382,79 @@ async function getExamplesForTask(task) {
4327
4382
  /**
4328
4383
  * @@@
4329
4384
  *
4385
+ * Here is the place where RAG (retrieval-augmented generation) happens
4386
+ *
4330
4387
  * @private internal utility of `createPipelineExecutor`
4331
4388
  */
4332
4389
  async function getKnowledgeForTask(options) {
4333
- const { preparedPipeline, task } = options;
4334
- return preparedPipeline.knowledgePieces.map(({ content }) => `- ${content}`).join('\n');
4390
+ const { tools, preparedPipeline, task } = options;
4391
+ const firstKnowlegePiece = preparedPipeline.knowledgePieces[0];
4392
+ const firstKnowlegeIndex = firstKnowlegePiece === null || firstKnowlegePiece === void 0 ? void 0 : firstKnowlegePiece.index[0];
4393
+ // <- TODO: Do not use just first knowledge piece and first index to determine embedding model, use also keyword search
4394
+ if (firstKnowlegePiece === undefined || firstKnowlegeIndex === undefined) {
4395
+ return 'No knowledge pieces found';
4396
+ }
4397
+ // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
4398
+ const _llms = arrayableToArray(tools.llm);
4399
+ const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
4400
+ const taskEmbeddingPrompt = {
4401
+ title: 'Knowledge Search',
4402
+ modelRequirements: {
4403
+ modelVariant: 'EMBEDDING',
4404
+ modelName: firstKnowlegeIndex.modelName,
4405
+ },
4406
+ content: task.content,
4407
+ parameters: {
4408
+ /* !!!!!!!! */
4409
+ },
4410
+ };
4411
+ const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
4412
+ const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
4413
+ const { index } = knowledgePiece;
4414
+ const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowlegeIndex.modelName);
4415
+ // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
4416
+ if (knowledgePieceIndex === undefined) {
4417
+ return {
4418
+ content: knowledgePiece.content,
4419
+ relevance: 0,
4420
+ };
4421
+ }
4422
+ const relevance = computeCosineSimilarity(knowledgePieceIndex.position, taskEmbeddingResult.content);
4423
+ return {
4424
+ content: knowledgePiece.content,
4425
+ relevance,
4426
+ };
4427
+ });
4428
+ const knowledgePiecesSorted = knowledgePiecesWithRelevance.sort((a, b) => a.relevance - b.relevance);
4429
+ const knowledgePiecesLimited = knowledgePiecesSorted.slice(0, 5);
4430
+ console.log('!!! Embedding', {
4431
+ task,
4432
+ taskEmbeddingPrompt,
4433
+ taskEmbeddingResult,
4434
+ firstKnowlegePiece,
4435
+ firstKnowlegeIndex,
4436
+ knowledgePiecesWithRelevance,
4437
+ knowledgePiecesSorted,
4438
+ knowledgePiecesLimited,
4439
+ });
4440
+ return knowledgePiecesLimited.map(({ content }) => `- ${content}`).join('\n');
4335
4441
  // <- TODO: [🧠] Some smart aggregation of knowledge pieces, single-line vs multi-line vs mixed
4336
4442
  }
4443
+ // TODO: !!!!!! Annotate + to new file
4444
+ function computeCosineSimilarity(embeddingVector1, embeddingVector2) {
4445
+ if (embeddingVector1.length !== embeddingVector2.length) {
4446
+ throw new TypeError('Embedding vectors must have the same length');
4447
+ }
4448
+ const dotProduct = embeddingVector1.reduce((sum, value, index) => sum + value * embeddingVector2[index], 0);
4449
+ const magnitude1 = Math.sqrt(embeddingVector1.reduce((sum, value) => sum + value * value, 0));
4450
+ const magnitude2 = Math.sqrt(embeddingVector2.reduce((sum, value) => sum + value * value, 0));
4451
+ return 1 - dotProduct / (magnitude1 * magnitude2);
4452
+ }
4453
+ /**
4454
+ * TODO: !!!! Verify if this is working
4455
+ * TODO: [♨] Implement Better - use keyword search
4456
+ * TODO: [♨] Examples of values
4457
+ */
4337
4458
 
4338
4459
  /**
4339
4460
  * @@@
@@ -4341,9 +4462,9 @@ async function getKnowledgeForTask(options) {
4341
4462
  * @private internal utility of `createPipelineExecutor`
4342
4463
  */
4343
4464
  async function getReservedParametersForTask(options) {
4344
- const { preparedPipeline, task, pipelineIdentification } = options;
4465
+ const { tools, preparedPipeline, task, pipelineIdentification } = options;
4345
4466
  const context = await getContextForTask(); // <- [🏍]
4346
- const knowledge = await getKnowledgeForTask({ preparedPipeline, task });
4467
+ const knowledge = await getKnowledgeForTask({ tools, preparedPipeline, task });
4347
4468
  const examples = await getExamplesForTask();
4348
4469
  const currentDate = new Date().toISOString(); // <- TODO: [🧠][💩] Better
4349
4470
  const modelName = RESERVED_PARAMETER_MISSING_VALUE;
@@ -4405,6 +4526,7 @@ async function executeTask(options) {
4405
4526
  }
4406
4527
  const definedParameters = Object.freeze({
4407
4528
  ...(await getReservedParametersForTask({
4529
+ tools,
4408
4530
  preparedPipeline,
4409
4531
  task: currentTask,
4410
4532
  pipelineIdentification,
@@ -4961,27 +5083,48 @@ async function preparePersona(personaDescription, tools, options) {
4961
5083
  pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
4962
5084
  tools,
4963
5085
  });
4964
- // TODO: [🚐] Make arrayable LLMs -> single LLM DRY
4965
5086
  const _llms = arrayableToArray(tools.llm);
4966
5087
  const llmTools = _llms.length === 1 ? _llms[0] : joinLlmExecutionTools(..._llms);
4967
- const availableModels = await llmTools.listModels();
4968
- const availableModelNames = availableModels
5088
+ const availableModels = (await llmTools.listModels())
4969
5089
  .filter(({ modelVariant }) => modelVariant === 'CHAT')
4970
- .map(({ modelName }) => modelName)
4971
- .join(',');
4972
- const result = await preparePersonaExecutor({ availableModelNames, personaDescription }).asPromise();
5090
+ .map(({ modelName, modelDescription }) => ({
5091
+ modelName,
5092
+ modelDescription,
5093
+ // <- Note: `modelTitle` and `modelVariant` is not relevant for this task
5094
+ }));
5095
+ const result = await preparePersonaExecutor({
5096
+ availableModels /* <- Note: Passing as JSON */,
5097
+ personaDescription,
5098
+ }).asPromise();
4973
5099
  const { outputParameters } = result;
4974
- const { modelRequirements: modelRequirementsRaw } = outputParameters;
4975
- const modelRequirements = JSON.parse(modelRequirementsRaw);
5100
+ const { modelsRequirements: modelsRequirementsJson } = outputParameters;
5101
+ let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
4976
5102
  if (isVerbose) {
4977
- console.info(`PERSONA ${personaDescription}`, modelRequirements);
5103
+ console.info(`PERSONA ${personaDescription}`, modelsRequirementsUnchecked);
4978
5104
  }
4979
- const { modelName, systemMessage, temperature } = modelRequirements;
4980
- return {
5105
+ if (!Array.isArray(modelsRequirementsUnchecked)) {
5106
+ // <- TODO: Book should have syntax and system to enforce shape of JSON
5107
+ modelsRequirementsUnchecked = [modelsRequirementsUnchecked];
5108
+ /*
5109
+ throw new UnexpectedError(
5110
+ spaceTrim(
5111
+ (block) => `
5112
+ Invalid \`modelsRequirements\`:
5113
+
5114
+ \`\`\`json
5115
+ ${block(JSON.stringify(modelsRequirementsUnchecked, null, 4))}
5116
+ \`\`\`
5117
+ `,
5118
+ ),
5119
+ );
5120
+ */
5121
+ }
5122
+ const modelsRequirements = modelsRequirementsUnchecked.map((modelRequirements) => ({
4981
5123
  modelVariant: 'CHAT',
4982
- modelName,
4983
- systemMessage,
4984
- temperature,
5124
+ ...modelRequirements,
5125
+ }));
5126
+ return {
5127
+ modelsRequirements,
4985
5128
  };
4986
5129
  }
4987
5130
  /**
@@ -5550,7 +5693,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5550
5693
  > },
5551
5694
  */
5552
5695
  async asJson() {
5553
- return JSON.parse(await tools.fs.readFile(filename, 'utf-8'));
5696
+ return jsonParse(await tools.fs.readFile(filename, 'utf-8'));
5554
5697
  },
5555
5698
  async asText() {
5556
5699
  return await tools.fs.readFile(filename, 'utf-8');
@@ -5808,14 +5951,14 @@ async function preparePipeline(pipeline, tools, options) {
5808
5951
  // TODO: [🖌][🧠] Implement some `mapAsync` function
5809
5952
  const preparedPersonas = new Array(personas.length);
5810
5953
  await forEachAsync(personas, { maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, async (persona, index) => {
5811
- const modelRequirements = await preparePersona(persona.description, { ...tools, llm: llmToolsWithUsage }, {
5954
+ const { modelsRequirements } = await preparePersona(persona.description, { ...tools, llm: llmToolsWithUsage }, {
5812
5955
  rootDirname,
5813
5956
  maxParallelCount /* <- TODO: [🪂] */,
5814
5957
  isVerbose,
5815
5958
  });
5816
5959
  const preparedPersona = {
5817
5960
  ...persona,
5818
- modelRequirements,
5961
+ modelsRequirements,
5819
5962
  preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id],
5820
5963
  // <- TODO: [🍙] Make some standard order of json properties
5821
5964
  };
@@ -9904,6 +10047,81 @@ const BoilerplateFormfactorDefinition = {
9904
10047
  },
9905
10048
  };
9906
10049
 
10050
+ /**
10051
+ * Creates a wrapper around LlmExecutionTools that only exposes models matching the filter function
10052
+ *
10053
+ * @param llmTools The original LLM execution tools to wrap
10054
+ * @param modelFilter Function that determines whether a model should be included
10055
+ * @returns A new LlmExecutionTools instance with filtered models
10056
+ *
10057
+ * @public exported from `@promptbook/core`
10058
+ */
10059
+ function filterModels(llmTools, modelFilter) {
10060
+ const filteredTools = {
10061
+ // Keep all properties from the original llmTools
10062
+ ...llmTools,
10063
+ get description() {
10064
+ return `${llmTools.description} (filtered)`;
10065
+ },
10066
+ // Override listModels to filter the models
10067
+ async listModels() {
10068
+ const originalModels = await llmTools.listModels();
10069
+ // Handle both synchronous and Promise return types
10070
+ if (originalModels instanceof Promise) {
10071
+ return originalModels.then((models) => models.filter(modelFilter));
10072
+ }
10073
+ else {
10074
+ return originalModels.filter(modelFilter);
10075
+ }
10076
+ },
10077
+ };
10078
+ // Helper function to validate if a model is allowed
10079
+ async function isModelAllowed(modelName) {
10080
+ const models = await filteredTools.listModels();
10081
+ return models.some((model) => model.modelName === modelName);
10082
+ }
10083
+ // Override callChatModel if it exists in the original tools
10084
+ if (llmTools.callChatModel) {
10085
+ filteredTools.callChatModel = async (prompt) => {
10086
+ var _a;
10087
+ const modelName = (_a = prompt.modelRequirements) === null || _a === void 0 ? void 0 : _a.modelName;
10088
+ // If a specific model is requested, check if it's allowed
10089
+ if (modelName && !(await isModelAllowed(modelName))) {
10090
+ throw new PipelineExecutionError(`Model ${modelName} is not allowed by the filter for chat calls`);
10091
+ }
10092
+ return llmTools.callChatModel(prompt);
10093
+ };
10094
+ }
10095
+ // Override callCompletionModel if it exists in the original tools
10096
+ if (llmTools.callCompletionModel) {
10097
+ filteredTools.callCompletionModel = async (prompt) => {
10098
+ var _a;
10099
+ const modelName = (_a = prompt.modelRequirements) === null || _a === void 0 ? void 0 : _a.modelName;
10100
+ // If a specific model is requested, check if it's allowed
10101
+ if (modelName && !(await isModelAllowed(modelName))) {
10102
+ throw new PipelineExecutionError(`Model ${modelName} is not allowed by the filter for completion calls`);
10103
+ }
10104
+ return llmTools.callCompletionModel(prompt);
10105
+ };
10106
+ }
10107
+ // Override callEmbeddingModel if it exists in the original tools
10108
+ if (llmTools.callEmbeddingModel) {
10109
+ filteredTools.callEmbeddingModel = async (prompt) => {
10110
+ var _a;
10111
+ const modelName = (_a = prompt.modelRequirements) === null || _a === void 0 ? void 0 : _a.modelName;
10112
+ // If a specific model is requested, check if it's allowed
10113
+ if (modelName && !(await isModelAllowed(modelName))) {
10114
+ throw new PipelineExecutionError(`Model ${modelName} is not allowed by the filter for embedding calls`);
10115
+ }
10116
+ return llmTools.callEmbeddingModel(prompt);
10117
+ };
10118
+ }
10119
+ return filteredTools;
10120
+ }
10121
+ /**
10122
+ * TODO: !!! [models] Test that this is working
10123
+ */
10124
+
9907
10125
  /**
9908
10126
  * @@@
9909
10127
  *
@@ -10121,6 +10339,48 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
10121
10339
  * TODO: [®] DRY Register logic
10122
10340
  */
10123
10341
 
10342
+ /**
10343
+ * How is the model provider trusted?
10344
+ *
10345
+ * @public exported from `@promptbook/core`
10346
+ */
10347
+ const MODEL_TRUST_LEVEL = {
10348
+ FULL: `Model is running on the local machine, training data and model weights are known, data are ethically sourced`,
10349
+ OPEN: `Model is open source, training data and model weights are known`,
10350
+ PARTIALLY_OPEN: `Model is open source, but training data and model weights are not (fully) known`,
10351
+ CLOSED_LOCAL: `Model can be run locally, but it is not open source`,
10352
+ CLOSED_FREE: `Model is behind API gateway but free to use`,
10353
+ CLOSED_BUSINESS: `Model is behind API gateway and paid but has good SLA, TOS, privacy policy and in general is a good to use in business applications`,
10354
+ CLOSED: `Model is behind API gateway and paid`,
10355
+ UNTRUSTED: `Model has questions about the training data and ethics, but it is not known if it is a problem or not`,
10356
+ VURNABLE: `Model has some known serious vulnerabilities, leaks, ethical problems, etc.`,
10357
+ };
10358
+ // <- TODO: Maybe do better levels of trust
10359
+ /**
10360
+ * How is the model provider important?
10361
+ *
10362
+ * @public exported from `@promptbook/core`
10363
+ */
10364
+ const MODEL_ORDER = {
10365
+ /**
10366
+ * Top-tier models, e.g. OpenAI, Anthropic,...
10367
+ */
10368
+ TOP_TIER: 333,
10369
+ /**
10370
+ * Mid-tier models, e.g. Llama, Mistral, etc.
10371
+ */
10372
+ NORMAL: 100,
10373
+ /**
10374
+ * Low-tier models, e.g. Phi, Tiny, etc.
10375
+ */
10376
+ LOW_TIER: 0,
10377
+ };
10378
+ /**
10379
+ * TODO: Add configuration schema and maybe some documentation link
10380
+ * TODO: Maybe constrain LlmToolsConfiguration[number] by generic to ensure that `createConfigurationFromEnv` and `getBoilerplateConfiguration` always create same `packageName` and `className`
10381
+ * TODO: [®] DRY Register logic
10382
+ */
10383
+
10124
10384
  /**
10125
10385
  * Stores data in memory (HEAP)
10126
10386
  *
@@ -10320,9 +10580,11 @@ const _AnthropicClaudeMetadataRegistration = $llmToolsMetadataRegister.register(
10320
10580
  packageName: '@promptbook/anthropic-claude',
10321
10581
  className: 'AnthropicClaudeExecutionTools',
10322
10582
  envVariables: ['ANTHROPIC_CLAUDE_API_KEY'],
10583
+ trustLevel: 'CLOSED',
10584
+ order: MODEL_ORDER.TOP_TIER,
10323
10585
  getBoilerplateConfiguration() {
10324
10586
  return {
10325
- title: 'Anthropic Claude (boilerplate)',
10587
+ title: 'Anthropic Claude',
10326
10588
  packageName: '@promptbook/anthropic-claude',
10327
10589
  className: 'AnthropicClaudeExecutionTools',
10328
10590
  options: {
@@ -10365,9 +10627,11 @@ const _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
10365
10627
  packageName: '@promptbook/azure-openai',
10366
10628
  className: 'AzureOpenAiExecutionTools',
10367
10629
  envVariables: ['AZUREOPENAI_RESOURCE_NAME', 'AZUREOPENAI_DEPLOYMENT_NAME', 'AZUREOPENAI_API_KEY'],
10630
+ trustLevel: 'CLOSED_BUSINESS',
10631
+ order: MODEL_ORDER.NORMAL,
10368
10632
  getBoilerplateConfiguration() {
10369
10633
  return {
10370
- title: 'Azure Open AI (boilerplate)',
10634
+ title: 'Azure Open AI',
10371
10635
  packageName: '@promptbook/azure-openai',
10372
10636
  className: 'AzureOpenAiExecutionTools',
10373
10637
  options: {
@@ -10451,9 +10715,11 @@ const _DeepseekMetadataRegistration = $llmToolsMetadataRegister.register({
10451
10715
  packageName: '@promptbook/deepseek',
10452
10716
  className: 'DeepseekExecutionTools',
10453
10717
  envVariables: ['DEEPSEEK_GENERATIVE_AI_API_KEY'],
10718
+ trustLevel: 'UNTRUSTED',
10719
+ order: MODEL_ORDER.NORMAL,
10454
10720
  getBoilerplateConfiguration() {
10455
10721
  return {
10456
- title: 'Deepseek (boilerplate)',
10722
+ title: 'Deepseek',
10457
10723
  packageName: '@promptbook/deepseek',
10458
10724
  className: 'DeepseekExecutionTools',
10459
10725
  options: {
@@ -10500,9 +10766,11 @@ const _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
10500
10766
  packageName: '@promptbook/google',
10501
10767
  className: 'GoogleExecutionTools',
10502
10768
  envVariables: ['GOOGLE_GENERATIVE_AI_API_KEY'],
10769
+ trustLevel: 'CLOSED',
10770
+ order: MODEL_ORDER.NORMAL,
10503
10771
  getBoilerplateConfiguration() {
10504
10772
  return {
10505
- title: 'Google Gemini (boilerplate)',
10773
+ title: 'Google Gemini',
10506
10774
  packageName: '@promptbook/google',
10507
10775
  className: 'GoogleExecutionTools',
10508
10776
  options: {
@@ -10549,9 +10817,11 @@ const _OpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
10549
10817
  packageName: '@promptbook/openai',
10550
10818
  className: 'OpenAiExecutionTools',
10551
10819
  envVariables: ['OPENAI_API_KEY'],
10820
+ trustLevel: 'CLOSED',
10821
+ order: MODEL_ORDER.TOP_TIER,
10552
10822
  getBoilerplateConfiguration() {
10553
10823
  return {
10554
- title: 'Open AI (boilerplate)',
10824
+ title: 'Open AI',
10555
10825
  packageName: '@promptbook/openai',
10556
10826
  className: 'OpenAiExecutionTools',
10557
10827
  options: {
@@ -10589,9 +10859,11 @@ const _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register(
10589
10859
  className: 'OpenAiAssistantExecutionTools',
10590
10860
  envVariables: null,
10591
10861
  // <- TODO: ['OPENAI_API_KEY', 'OPENAI_ASSISTANT_ID']
10862
+ trustLevel: 'CLOSED',
10863
+ order: MODEL_ORDER.NORMAL,
10592
10864
  getBoilerplateConfiguration() {
10593
10865
  return {
10594
- title: 'Open AI Assistant (boilerplate)',
10866
+ title: 'Open AI Assistant',
10595
10867
  packageName: '@promptbook/openai',
10596
10868
  className: 'OpenAiAssistantExecutionTools',
10597
10869
  options: {
@@ -11055,5 +11327,5 @@ class PrefixStorage {
11055
11327
  }
11056
11328
  }
11057
11329
 
11058
- export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, AuthenticationError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PLAYGROUND_APP_ID, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, REMOTE_SERVER_URLS, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, UnexpectedError, WrappedError, ZERO_USAGE, ZERO_VALUE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, countUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, identificationToPromptbookToken, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline, validatePipelineString };
11330
+ export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, AuthenticationError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_ORDER, MODEL_TRUST_LEVEL, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PLAYGROUND_APP_ID, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, REMOTE_SERVER_URLS, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, UnexpectedError, WrappedError, ZERO_USAGE, ZERO_VALUE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, countUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, getPipelineInterface, identificationToPromptbookToken, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline, validatePipelineString };
11059
11331
  //# sourceMappingURL=index.es.js.map