@promptbook/components 0.104.0-11 β 0.104.0-12
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 +90 -26
- 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/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/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/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +90 -26
- 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-12';
|
|
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
|
|
@@ -6713,19 +6713,37 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6713
6713
|
`);
|
|
6714
6714
|
}
|
|
6715
6715
|
applyToAgentModelRequirements(requirements, content) {
|
|
6716
|
-
// We simply mark that browser capability is enabled in metadata
|
|
6717
|
-
// Get existing metadata
|
|
6718
|
-
const existingMetadata = requirements.metadata || {};
|
|
6719
6716
|
// Get existing tools array or create new one
|
|
6720
|
-
const existingTools =
|
|
6721
|
-
// Add '
|
|
6722
|
-
const updatedTools = existingTools.
|
|
6723
|
-
|
|
6717
|
+
const existingTools = requirements.tools || [];
|
|
6718
|
+
// Add 'web_browser' to tools if not already present
|
|
6719
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
|
|
6720
|
+
? existingTools
|
|
6721
|
+
: [
|
|
6722
|
+
...existingTools,
|
|
6723
|
+
{
|
|
6724
|
+
name: 'web_browser',
|
|
6725
|
+
description: spaceTrim$1(`
|
|
6726
|
+
A tool that can browse the web.
|
|
6727
|
+
Use this tool when you need to access specific websites or browse the internet.
|
|
6728
|
+
`),
|
|
6729
|
+
parameters: {
|
|
6730
|
+
type: 'object',
|
|
6731
|
+
properties: {
|
|
6732
|
+
url: {
|
|
6733
|
+
type: 'string',
|
|
6734
|
+
description: 'The URL to browse',
|
|
6735
|
+
},
|
|
6736
|
+
},
|
|
6737
|
+
required: ['url'],
|
|
6738
|
+
},
|
|
6739
|
+
},
|
|
6740
|
+
];
|
|
6741
|
+
// Return requirements with updated tools and metadata
|
|
6724
6742
|
return {
|
|
6725
6743
|
...requirements,
|
|
6744
|
+
tools: updatedTools,
|
|
6726
6745
|
metadata: {
|
|
6727
|
-
...
|
|
6728
|
-
tools: updatedTools,
|
|
6746
|
+
...requirements.metadata,
|
|
6729
6747
|
useBrowser: true,
|
|
6730
6748
|
},
|
|
6731
6749
|
};
|
|
@@ -6818,13 +6836,13 @@ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6818
6836
|
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
6819
6837
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
6820
6838
|
*
|
|
6821
|
-
* The content following `USE SEARCH ENGINE` is
|
|
6839
|
+
* The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
6822
6840
|
*
|
|
6823
6841
|
* Example usage in agent source:
|
|
6824
6842
|
*
|
|
6825
6843
|
* ```book
|
|
6826
6844
|
* USE SEARCH ENGINE
|
|
6827
|
-
* USE SEARCH ENGINE
|
|
6845
|
+
* USE SEARCH ENGINE Hledej informace o PΕemyslovcΓch
|
|
6828
6846
|
* ```
|
|
6829
6847
|
*
|
|
6830
6848
|
* @private [πͺ] Maybe export the commitments through some package
|
|
@@ -6856,7 +6874,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6856
6874
|
|
|
6857
6875
|
## Key aspects
|
|
6858
6876
|
|
|
6859
|
-
- The content following \`USE SEARCH ENGINE\` is
|
|
6877
|
+
- The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
6860
6878
|
- The actual search engine tool usage is handled by the agent runtime
|
|
6861
6879
|
- Allows the agent to search for current information from the web
|
|
6862
6880
|
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
@@ -6881,20 +6899,39 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6881
6899
|
`);
|
|
6882
6900
|
}
|
|
6883
6901
|
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
6902
|
// Get existing tools array or create new one
|
|
6888
|
-
const existingTools =
|
|
6889
|
-
// Add '
|
|
6890
|
-
const updatedTools = existingTools.
|
|
6891
|
-
|
|
6903
|
+
const existingTools = requirements.tools || [];
|
|
6904
|
+
// Add 'web_search' to tools if not already present
|
|
6905
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
|
|
6906
|
+
? existingTools
|
|
6907
|
+
: [
|
|
6908
|
+
...existingTools,
|
|
6909
|
+
{
|
|
6910
|
+
name: 'web_search',
|
|
6911
|
+
description: spaceTrim$1(`
|
|
6912
|
+
Search the internet for information.
|
|
6913
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
6914
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
6915
|
+
`),
|
|
6916
|
+
parameters: {
|
|
6917
|
+
type: 'object',
|
|
6918
|
+
properties: {
|
|
6919
|
+
query: {
|
|
6920
|
+
type: 'string',
|
|
6921
|
+
description: 'The search query',
|
|
6922
|
+
},
|
|
6923
|
+
},
|
|
6924
|
+
required: ['query'],
|
|
6925
|
+
},
|
|
6926
|
+
},
|
|
6927
|
+
];
|
|
6928
|
+
// Return requirements with updated tools and metadata
|
|
6892
6929
|
return {
|
|
6893
6930
|
...requirements,
|
|
6931
|
+
tools: updatedTools,
|
|
6894
6932
|
metadata: {
|
|
6895
|
-
...
|
|
6896
|
-
|
|
6897
|
-
useSearchEngine: true,
|
|
6933
|
+
...requirements.metadata,
|
|
6934
|
+
useSearchEngine: content || true,
|
|
6898
6935
|
},
|
|
6899
6936
|
};
|
|
6900
6937
|
}
|
|
@@ -7378,6 +7415,10 @@ function parseAgentSource(agentSource) {
|
|
|
7378
7415
|
meta.image = spaceTrim$2(commitment.content);
|
|
7379
7416
|
continue;
|
|
7380
7417
|
}
|
|
7418
|
+
if (commitment.type === 'META DESCRIPTION') {
|
|
7419
|
+
meta.description = spaceTrim$2(commitment.content);
|
|
7420
|
+
continue;
|
|
7421
|
+
}
|
|
7381
7422
|
if (commitment.type === 'META COLOR') {
|
|
7382
7423
|
meta.color = normalizeSeparator(commitment.content);
|
|
7383
7424
|
continue;
|
|
@@ -11438,7 +11479,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
11438
11479
|
}
|
|
11439
11480
|
/**
|
|
11440
11481
|
* TODO: [π] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
11441
|
-
* TODO: [π·ββοΈ]
|
|
11482
|
+
* TODO: [π·ββοΈ] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
11442
11483
|
*/
|
|
11443
11484
|
|
|
11444
11485
|
/**
|
|
@@ -11455,7 +11496,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
11455
11496
|
}
|
|
11456
11497
|
/**
|
|
11457
11498
|
* TODO: [π] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
11458
|
-
* TODO: [π·ββοΈ]
|
|
11499
|
+
* TODO: [π·ββοΈ] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
11459
11500
|
*/
|
|
11460
11501
|
|
|
11461
11502
|
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 +16266,22 @@ resultContent, rawResponse) {
|
|
|
16225
16266
|
* TODO: [π€] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
16226
16267
|
*/
|
|
16227
16268
|
|
|
16269
|
+
/**
|
|
16270
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
16271
|
+
*
|
|
16272
|
+
* @private
|
|
16273
|
+
*/
|
|
16274
|
+
function mapToolsToOpenAi(tools) {
|
|
16275
|
+
return tools.map((tool) => ({
|
|
16276
|
+
type: 'function',
|
|
16277
|
+
function: {
|
|
16278
|
+
name: tool.name,
|
|
16279
|
+
description: tool.description,
|
|
16280
|
+
parameters: tool.parameters,
|
|
16281
|
+
},
|
|
16282
|
+
}));
|
|
16283
|
+
}
|
|
16284
|
+
|
|
16228
16285
|
/**
|
|
16229
16286
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
16230
16287
|
*
|
|
@@ -16422,6 +16479,9 @@ class OpenAiCompatibleExecutionTools {
|
|
|
16422
16479
|
},
|
|
16423
16480
|
],
|
|
16424
16481
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16482
|
+
tools: currentModelRequirements.tools === undefined
|
|
16483
|
+
? undefined
|
|
16484
|
+
: mapToolsToOpenAi(currentModelRequirements.tools),
|
|
16425
16485
|
};
|
|
16426
16486
|
const start = $getCurrentDate();
|
|
16427
16487
|
if (this.options.isVerbose) {
|
|
@@ -16566,6 +16626,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
16566
16626
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
16567
16627
|
const rawRequest = {
|
|
16568
16628
|
...modelSettings,
|
|
16629
|
+
model: modelName,
|
|
16569
16630
|
prompt: rawPromptContent,
|
|
16570
16631
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16571
16632
|
};
|
|
@@ -16820,8 +16881,8 @@ class OpenAiCompatibleExecutionTools {
|
|
|
16820
16881
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
16821
16882
|
const rawRequest = {
|
|
16822
16883
|
...modelSettings,
|
|
16823
|
-
size: modelSettings.size || '1024x1024',
|
|
16824
16884
|
prompt: rawPromptContent,
|
|
16885
|
+
size: modelSettings.size || '1024x1024',
|
|
16825
16886
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16826
16887
|
response_format: 'url', // TODO: [π§ ] Maybe allow b64_json
|
|
16827
16888
|
};
|
|
@@ -17223,6 +17284,7 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
17223
17284
|
thread: {
|
|
17224
17285
|
messages: threadMessages,
|
|
17225
17286
|
},
|
|
17287
|
+
tools: modelRequirements.tools === undefined ? undefined : mapToolsToOpenAi(modelRequirements.tools),
|
|
17226
17288
|
// <- TODO: Add user identification here> user: this.options.user,
|
|
17227
17289
|
};
|
|
17228
17290
|
const start = $getCurrentDate();
|
|
@@ -17746,6 +17808,8 @@ class AgentLlmExecutionTools {
|
|
|
17746
17808
|
modelRequirements: {
|
|
17747
17809
|
...chatPrompt.modelRequirements,
|
|
17748
17810
|
...modelRequirements,
|
|
17811
|
+
// Spread tools to convert readonly array to mutable
|
|
17812
|
+
tools: modelRequirements.tools ? [...modelRequirements.tools] : chatPrompt.modelRequirements.tools,
|
|
17749
17813
|
// Prepend agent system message to existing system message
|
|
17750
17814
|
systemMessage: modelRequirements.systemMessage +
|
|
17751
17815
|
(chatPrompt.modelRequirements.systemMessage
|