@promptbook/components 0.104.0-11 β 0.104.0-13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +91 -29
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +5 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
- package/esm/typings/src/commitments/META/META_DESCRIPTION.d.ts +41 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +2 -2
- package/esm/typings/src/commitments/_base/BookCommitment.d.ts +1 -1
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
- package/esm/typings/src/search-engines/SearchResult.d.ts +4 -4
- package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +1 -1
- package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +1 -1
- package/esm/typings/src/types/LlmToolDefinition.d.ts +20 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +91 -29
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -35,7 +35,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
35
35
|
* @generated
|
|
36
36
|
* @see https://github.com/webgptorg/promptbook
|
|
37
37
|
*/
|
|
38
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
38
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-13';
|
|
39
39
|
/**
|
|
40
40
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
41
41
|
* Note: [π] Ignore a discrepancy between file name and entity name
|
|
@@ -4182,9 +4182,7 @@ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
4182
4182
|
// Get existing dictionary entries from metadata
|
|
4183
4183
|
const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
|
|
4184
4184
|
// Merge the new dictionary entry with existing entries
|
|
4185
|
-
const mergedDictionary = existingDictionary
|
|
4186
|
-
? `${existingDictionary}\n${trimmedContent}`
|
|
4187
|
-
: trimmedContent;
|
|
4185
|
+
const mergedDictionary = existingDictionary ? `${existingDictionary}\n${trimmedContent}` : trimmedContent;
|
|
4188
4186
|
// Store the merged dictionary in metadata for debugging and inspection
|
|
4189
4187
|
const updatedMetadata = {
|
|
4190
4188
|
...requirements.metadata,
|
|
@@ -6713,19 +6711,37 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6713
6711
|
`);
|
|
6714
6712
|
}
|
|
6715
6713
|
applyToAgentModelRequirements(requirements, content) {
|
|
6716
|
-
// We simply mark that browser capability is enabled in metadata
|
|
6717
|
-
// Get existing metadata
|
|
6718
|
-
const existingMetadata = requirements.metadata || {};
|
|
6719
6714
|
// Get existing tools array or create new one
|
|
6720
|
-
const existingTools =
|
|
6721
|
-
// Add '
|
|
6722
|
-
const updatedTools = existingTools.
|
|
6723
|
-
|
|
6715
|
+
const existingTools = requirements.tools || [];
|
|
6716
|
+
// Add 'web_browser' to tools if not already present
|
|
6717
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
|
|
6718
|
+
? existingTools
|
|
6719
|
+
: [
|
|
6720
|
+
...existingTools,
|
|
6721
|
+
{
|
|
6722
|
+
name: 'web_browser',
|
|
6723
|
+
description: spaceTrim$1(`
|
|
6724
|
+
A tool that can browse the web.
|
|
6725
|
+
Use this tool when you need to access specific websites or browse the internet.
|
|
6726
|
+
`),
|
|
6727
|
+
parameters: {
|
|
6728
|
+
type: 'object',
|
|
6729
|
+
properties: {
|
|
6730
|
+
url: {
|
|
6731
|
+
type: 'string',
|
|
6732
|
+
description: 'The URL to browse',
|
|
6733
|
+
},
|
|
6734
|
+
},
|
|
6735
|
+
required: ['url'],
|
|
6736
|
+
},
|
|
6737
|
+
},
|
|
6738
|
+
];
|
|
6739
|
+
// Return requirements with updated tools and metadata
|
|
6724
6740
|
return {
|
|
6725
6741
|
...requirements,
|
|
6742
|
+
tools: updatedTools,
|
|
6726
6743
|
metadata: {
|
|
6727
|
-
...
|
|
6728
|
-
tools: updatedTools,
|
|
6744
|
+
...requirements.metadata,
|
|
6729
6745
|
useBrowser: true,
|
|
6730
6746
|
},
|
|
6731
6747
|
};
|
|
@@ -6818,13 +6834,13 @@ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6818
6834
|
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
6819
6835
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
6820
6836
|
*
|
|
6821
|
-
* The content following `USE SEARCH ENGINE` is
|
|
6837
|
+
* The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
6822
6838
|
*
|
|
6823
6839
|
* Example usage in agent source:
|
|
6824
6840
|
*
|
|
6825
6841
|
* ```book
|
|
6826
6842
|
* USE SEARCH ENGINE
|
|
6827
|
-
* USE SEARCH ENGINE
|
|
6843
|
+
* USE SEARCH ENGINE Hledej informace o PΕemyslovcΓch
|
|
6828
6844
|
* ```
|
|
6829
6845
|
*
|
|
6830
6846
|
* @private [πͺ] Maybe export the commitments through some package
|
|
@@ -6856,7 +6872,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6856
6872
|
|
|
6857
6873
|
## Key aspects
|
|
6858
6874
|
|
|
6859
|
-
- The content following \`USE SEARCH ENGINE\` is
|
|
6875
|
+
- The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
6860
6876
|
- The actual search engine tool usage is handled by the agent runtime
|
|
6861
6877
|
- Allows the agent to search for current information from the web
|
|
6862
6878
|
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
@@ -6881,20 +6897,39 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6881
6897
|
`);
|
|
6882
6898
|
}
|
|
6883
6899
|
applyToAgentModelRequirements(requirements, content) {
|
|
6884
|
-
// We simply mark that search engine capability is enabled in metadata
|
|
6885
|
-
// Get existing metadata
|
|
6886
|
-
const existingMetadata = requirements.metadata || {};
|
|
6887
6900
|
// Get existing tools array or create new one
|
|
6888
|
-
const existingTools =
|
|
6889
|
-
// Add '
|
|
6890
|
-
const updatedTools = existingTools.
|
|
6891
|
-
|
|
6901
|
+
const existingTools = requirements.tools || [];
|
|
6902
|
+
// Add 'web_search' to tools if not already present
|
|
6903
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
|
|
6904
|
+
? existingTools
|
|
6905
|
+
: [
|
|
6906
|
+
...existingTools,
|
|
6907
|
+
{
|
|
6908
|
+
name: 'web_search',
|
|
6909
|
+
description: spaceTrim$1(`
|
|
6910
|
+
Search the internet for information.
|
|
6911
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
6912
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
6913
|
+
`),
|
|
6914
|
+
parameters: {
|
|
6915
|
+
type: 'object',
|
|
6916
|
+
properties: {
|
|
6917
|
+
query: {
|
|
6918
|
+
type: 'string',
|
|
6919
|
+
description: 'The search query',
|
|
6920
|
+
},
|
|
6921
|
+
},
|
|
6922
|
+
required: ['query'],
|
|
6923
|
+
},
|
|
6924
|
+
},
|
|
6925
|
+
];
|
|
6926
|
+
// Return requirements with updated tools and metadata
|
|
6892
6927
|
return {
|
|
6893
6928
|
...requirements,
|
|
6929
|
+
tools: updatedTools,
|
|
6894
6930
|
metadata: {
|
|
6895
|
-
...
|
|
6896
|
-
|
|
6897
|
-
useSearchEngine: true,
|
|
6931
|
+
...requirements.metadata,
|
|
6932
|
+
useSearchEngine: content || true,
|
|
6898
6933
|
},
|
|
6899
6934
|
};
|
|
6900
6935
|
}
|
|
@@ -7378,6 +7413,10 @@ function parseAgentSource(agentSource) {
|
|
|
7378
7413
|
meta.image = spaceTrim$2(commitment.content);
|
|
7379
7414
|
continue;
|
|
7380
7415
|
}
|
|
7416
|
+
if (commitment.type === 'META DESCRIPTION') {
|
|
7417
|
+
meta.description = spaceTrim$2(commitment.content);
|
|
7418
|
+
continue;
|
|
7419
|
+
}
|
|
7381
7420
|
if (commitment.type === 'META COLOR') {
|
|
7382
7421
|
meta.color = normalizeSeparator(commitment.content);
|
|
7383
7422
|
continue;
|
|
@@ -11438,7 +11477,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
11438
11477
|
}
|
|
11439
11478
|
/**
|
|
11440
11479
|
* TODO: [π] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
11441
|
-
* TODO: [π·ββοΈ]
|
|
11480
|
+
* TODO: [π·ββοΈ] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
11442
11481
|
*/
|
|
11443
11482
|
|
|
11444
11483
|
/**
|
|
@@ -11455,7 +11494,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
11455
11494
|
}
|
|
11456
11495
|
/**
|
|
11457
11496
|
* TODO: [π] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
11458
|
-
* TODO: [π·ββοΈ]
|
|
11497
|
+
* TODO: [π·ββοΈ] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
11459
11498
|
*/
|
|
11460
11499
|
|
|
11461
11500
|
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 helpful 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 helpful 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"}];
|
|
@@ -16225,6 +16264,22 @@ resultContent, rawResponse) {
|
|
|
16225
16264
|
* TODO: [π€] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
16226
16265
|
*/
|
|
16227
16266
|
|
|
16267
|
+
/**
|
|
16268
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
16269
|
+
*
|
|
16270
|
+
* @private
|
|
16271
|
+
*/
|
|
16272
|
+
function mapToolsToOpenAi(tools) {
|
|
16273
|
+
return tools.map((tool) => ({
|
|
16274
|
+
type: 'function',
|
|
16275
|
+
function: {
|
|
16276
|
+
name: tool.name,
|
|
16277
|
+
description: tool.description,
|
|
16278
|
+
parameters: tool.parameters,
|
|
16279
|
+
},
|
|
16280
|
+
}));
|
|
16281
|
+
}
|
|
16282
|
+
|
|
16228
16283
|
/**
|
|
16229
16284
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
16230
16285
|
*
|
|
@@ -16422,6 +16477,9 @@ class OpenAiCompatibleExecutionTools {
|
|
|
16422
16477
|
},
|
|
16423
16478
|
],
|
|
16424
16479
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16480
|
+
tools: currentModelRequirements.tools === undefined
|
|
16481
|
+
? undefined
|
|
16482
|
+
: mapToolsToOpenAi(currentModelRequirements.tools),
|
|
16425
16483
|
};
|
|
16426
16484
|
const start = $getCurrentDate();
|
|
16427
16485
|
if (this.options.isVerbose) {
|
|
@@ -16566,6 +16624,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
16566
16624
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
16567
16625
|
const rawRequest = {
|
|
16568
16626
|
...modelSettings,
|
|
16627
|
+
model: modelName,
|
|
16569
16628
|
prompt: rawPromptContent,
|
|
16570
16629
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16571
16630
|
};
|
|
@@ -16820,8 +16879,8 @@ class OpenAiCompatibleExecutionTools {
|
|
|
16820
16879
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
16821
16880
|
const rawRequest = {
|
|
16822
16881
|
...modelSettings,
|
|
16823
|
-
size: modelSettings.size || '1024x1024',
|
|
16824
16882
|
prompt: rawPromptContent,
|
|
16883
|
+
size: modelSettings.size || '1024x1024',
|
|
16825
16884
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16826
16885
|
response_format: 'url', // TODO: [π§ ] Maybe allow b64_json
|
|
16827
16886
|
};
|
|
@@ -17223,6 +17282,7 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
17223
17282
|
thread: {
|
|
17224
17283
|
messages: threadMessages,
|
|
17225
17284
|
},
|
|
17285
|
+
tools: modelRequirements.tools === undefined ? undefined : mapToolsToOpenAi(modelRequirements.tools),
|
|
17226
17286
|
// <- TODO: Add user identification here> user: this.options.user,
|
|
17227
17287
|
};
|
|
17228
17288
|
const start = $getCurrentDate();
|
|
@@ -17746,6 +17806,8 @@ class AgentLlmExecutionTools {
|
|
|
17746
17806
|
modelRequirements: {
|
|
17747
17807
|
...chatPrompt.modelRequirements,
|
|
17748
17808
|
...modelRequirements,
|
|
17809
|
+
// Spread tools to convert readonly array to mutable
|
|
17810
|
+
tools: modelRequirements.tools ? [...modelRequirements.tools] : chatPrompt.modelRequirements.tools,
|
|
17749
17811
|
// Prepend agent system message to existing system message
|
|
17750
17812
|
systemMessage: modelRequirements.systemMessage +
|
|
17751
17813
|
(chatPrompt.modelRequirements.systemMessage
|