@promptbook/wizard 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 +99 -32
- 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 +2 -2
- package/umd/index.umd.js +99 -32
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -36,7 +36,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
36
36
|
* @generated
|
|
37
37
|
* @see https://github.com/webgptorg/promptbook
|
|
38
38
|
*/
|
|
39
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
39
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-13';
|
|
40
40
|
/**
|
|
41
41
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
42
42
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -5656,6 +5656,22 @@ resultContent, rawResponse) {
|
|
|
5656
5656
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
5657
5657
|
*/
|
|
5658
5658
|
|
|
5659
|
+
/**
|
|
5660
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
5661
|
+
*
|
|
5662
|
+
* @private
|
|
5663
|
+
*/
|
|
5664
|
+
function mapToolsToOpenAi(tools) {
|
|
5665
|
+
return tools.map((tool) => ({
|
|
5666
|
+
type: 'function',
|
|
5667
|
+
function: {
|
|
5668
|
+
name: tool.name,
|
|
5669
|
+
description: tool.description,
|
|
5670
|
+
parameters: tool.parameters,
|
|
5671
|
+
},
|
|
5672
|
+
}));
|
|
5673
|
+
}
|
|
5674
|
+
|
|
5659
5675
|
/**
|
|
5660
5676
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
5661
5677
|
*
|
|
@@ -5853,6 +5869,9 @@ class OpenAiCompatibleExecutionTools {
|
|
|
5853
5869
|
},
|
|
5854
5870
|
],
|
|
5855
5871
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
5872
|
+
tools: currentModelRequirements.tools === undefined
|
|
5873
|
+
? undefined
|
|
5874
|
+
: mapToolsToOpenAi(currentModelRequirements.tools),
|
|
5856
5875
|
};
|
|
5857
5876
|
const start = $getCurrentDate();
|
|
5858
5877
|
if (this.options.isVerbose) {
|
|
@@ -5997,6 +6016,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
5997
6016
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
5998
6017
|
const rawRequest = {
|
|
5999
6018
|
...modelSettings,
|
|
6019
|
+
model: modelName,
|
|
6000
6020
|
prompt: rawPromptContent,
|
|
6001
6021
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
6002
6022
|
};
|
|
@@ -6251,8 +6271,8 @@ class OpenAiCompatibleExecutionTools {
|
|
|
6251
6271
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
6252
6272
|
const rawRequest = {
|
|
6253
6273
|
...modelSettings,
|
|
6254
|
-
size: modelSettings.size || '1024x1024',
|
|
6255
6274
|
prompt: rawPromptContent,
|
|
6275
|
+
size: modelSettings.size || '1024x1024',
|
|
6256
6276
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
6257
6277
|
response_format: 'url', // TODO: [🧠] Maybe allow b64_json
|
|
6258
6278
|
};
|
|
@@ -7150,6 +7170,7 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
7150
7170
|
thread: {
|
|
7151
7171
|
messages: threadMessages,
|
|
7152
7172
|
},
|
|
7173
|
+
tools: modelRequirements.tools === undefined ? undefined : mapToolsToOpenAi(modelRequirements.tools),
|
|
7153
7174
|
// <- TODO: Add user identification here> user: this.options.user,
|
|
7154
7175
|
};
|
|
7155
7176
|
const start = $getCurrentDate();
|
|
@@ -9678,7 +9699,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
9678
9699
|
}
|
|
9679
9700
|
/**
|
|
9680
9701
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
9681
|
-
* TODO: [👷♂️]
|
|
9702
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
9682
9703
|
*/
|
|
9683
9704
|
|
|
9684
9705
|
/**
|
|
@@ -9695,7 +9716,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
9695
9716
|
}
|
|
9696
9717
|
/**
|
|
9697
9718
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
9698
|
-
* TODO: [👷♂️]
|
|
9719
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
9699
9720
|
*/
|
|
9700
9721
|
|
|
9701
9722
|
/**
|
|
@@ -14236,9 +14257,7 @@ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14236
14257
|
// Get existing dictionary entries from metadata
|
|
14237
14258
|
const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
|
|
14238
14259
|
// Merge the new dictionary entry with existing entries
|
|
14239
|
-
const mergedDictionary = existingDictionary
|
|
14240
|
-
? `${existingDictionary}\n${trimmedContent}`
|
|
14241
|
-
: trimmedContent;
|
|
14260
|
+
const mergedDictionary = existingDictionary ? `${existingDictionary}\n${trimmedContent}` : trimmedContent;
|
|
14242
14261
|
// Store the merged dictionary in metadata for debugging and inspection
|
|
14243
14262
|
const updatedMetadata = {
|
|
14244
14263
|
...requirements.metadata,
|
|
@@ -16767,19 +16786,37 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
16767
16786
|
`);
|
|
16768
16787
|
}
|
|
16769
16788
|
applyToAgentModelRequirements(requirements, content) {
|
|
16770
|
-
// We simply mark that browser capability is enabled in metadata
|
|
16771
|
-
// Get existing metadata
|
|
16772
|
-
const existingMetadata = requirements.metadata || {};
|
|
16773
16789
|
// Get existing tools array or create new one
|
|
16774
|
-
const existingTools =
|
|
16775
|
-
// Add '
|
|
16776
|
-
const updatedTools = existingTools.
|
|
16777
|
-
|
|
16790
|
+
const existingTools = requirements.tools || [];
|
|
16791
|
+
// Add 'web_browser' to tools if not already present
|
|
16792
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
|
|
16793
|
+
? existingTools
|
|
16794
|
+
: [
|
|
16795
|
+
...existingTools,
|
|
16796
|
+
{
|
|
16797
|
+
name: 'web_browser',
|
|
16798
|
+
description: spaceTrim$1(`
|
|
16799
|
+
A tool that can browse the web.
|
|
16800
|
+
Use this tool when you need to access specific websites or browse the internet.
|
|
16801
|
+
`),
|
|
16802
|
+
parameters: {
|
|
16803
|
+
type: 'object',
|
|
16804
|
+
properties: {
|
|
16805
|
+
url: {
|
|
16806
|
+
type: 'string',
|
|
16807
|
+
description: 'The URL to browse',
|
|
16808
|
+
},
|
|
16809
|
+
},
|
|
16810
|
+
required: ['url'],
|
|
16811
|
+
},
|
|
16812
|
+
},
|
|
16813
|
+
];
|
|
16814
|
+
// Return requirements with updated tools and metadata
|
|
16778
16815
|
return {
|
|
16779
16816
|
...requirements,
|
|
16817
|
+
tools: updatedTools,
|
|
16780
16818
|
metadata: {
|
|
16781
|
-
...
|
|
16782
|
-
tools: updatedTools,
|
|
16819
|
+
...requirements.metadata,
|
|
16783
16820
|
useBrowser: true,
|
|
16784
16821
|
},
|
|
16785
16822
|
};
|
|
@@ -16872,13 +16909,13 @@ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
16872
16909
|
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
16873
16910
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
16874
16911
|
*
|
|
16875
|
-
* The content following `USE SEARCH ENGINE` is
|
|
16912
|
+
* The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
16876
16913
|
*
|
|
16877
16914
|
* Example usage in agent source:
|
|
16878
16915
|
*
|
|
16879
16916
|
* ```book
|
|
16880
16917
|
* USE SEARCH ENGINE
|
|
16881
|
-
* USE SEARCH ENGINE
|
|
16918
|
+
* USE SEARCH ENGINE Hledej informace o Přemyslovcích
|
|
16882
16919
|
* ```
|
|
16883
16920
|
*
|
|
16884
16921
|
* @private [🪔] Maybe export the commitments through some package
|
|
@@ -16910,7 +16947,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
16910
16947
|
|
|
16911
16948
|
## Key aspects
|
|
16912
16949
|
|
|
16913
|
-
- The content following \`USE SEARCH ENGINE\` is
|
|
16950
|
+
- The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
16914
16951
|
- The actual search engine tool usage is handled by the agent runtime
|
|
16915
16952
|
- Allows the agent to search for current information from the web
|
|
16916
16953
|
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
@@ -16935,20 +16972,39 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
16935
16972
|
`);
|
|
16936
16973
|
}
|
|
16937
16974
|
applyToAgentModelRequirements(requirements, content) {
|
|
16938
|
-
// We simply mark that search engine capability is enabled in metadata
|
|
16939
|
-
// Get existing metadata
|
|
16940
|
-
const existingMetadata = requirements.metadata || {};
|
|
16941
16975
|
// Get existing tools array or create new one
|
|
16942
|
-
const existingTools =
|
|
16943
|
-
// Add '
|
|
16944
|
-
const updatedTools = existingTools.
|
|
16945
|
-
|
|
16976
|
+
const existingTools = requirements.tools || [];
|
|
16977
|
+
// Add 'web_search' to tools if not already present
|
|
16978
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
|
|
16979
|
+
? existingTools
|
|
16980
|
+
: [
|
|
16981
|
+
...existingTools,
|
|
16982
|
+
{
|
|
16983
|
+
name: 'web_search',
|
|
16984
|
+
description: spaceTrim$1(`
|
|
16985
|
+
Search the internet for information.
|
|
16986
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
16987
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
16988
|
+
`),
|
|
16989
|
+
parameters: {
|
|
16990
|
+
type: 'object',
|
|
16991
|
+
properties: {
|
|
16992
|
+
query: {
|
|
16993
|
+
type: 'string',
|
|
16994
|
+
description: 'The search query',
|
|
16995
|
+
},
|
|
16996
|
+
},
|
|
16997
|
+
required: ['query'],
|
|
16998
|
+
},
|
|
16999
|
+
},
|
|
17000
|
+
];
|
|
17001
|
+
// Return requirements with updated tools and metadata
|
|
16946
17002
|
return {
|
|
16947
17003
|
...requirements,
|
|
17004
|
+
tools: updatedTools,
|
|
16948
17005
|
metadata: {
|
|
16949
|
-
...
|
|
16950
|
-
|
|
16951
|
-
useSearchEngine: true,
|
|
17006
|
+
...requirements.metadata,
|
|
17007
|
+
useSearchEngine: content || true,
|
|
16952
17008
|
},
|
|
16953
17009
|
};
|
|
16954
17010
|
}
|
|
@@ -17994,6 +18050,10 @@ function parseAgentSource(agentSource) {
|
|
|
17994
18050
|
meta.image = spaceTrim$2(commitment.content);
|
|
17995
18051
|
continue;
|
|
17996
18052
|
}
|
|
18053
|
+
if (commitment.type === 'META DESCRIPTION') {
|
|
18054
|
+
meta.description = spaceTrim$2(commitment.content);
|
|
18055
|
+
continue;
|
|
18056
|
+
}
|
|
17997
18057
|
if (commitment.type === 'META COLOR') {
|
|
17998
18058
|
meta.color = normalizeSeparator(commitment.content);
|
|
17999
18059
|
continue;
|
|
@@ -19469,7 +19529,7 @@ async function $provideLlmToolsForWizardOrCli(options) {
|
|
|
19469
19529
|
}
|
|
19470
19530
|
/**
|
|
19471
19531
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
19472
|
-
* TODO: [👷♂️]
|
|
19532
|
+
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
19473
19533
|
* TODO: [🥃] Allow `ptbk make` without llm tools
|
|
19474
19534
|
* TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
|
|
19475
19535
|
* TODO: [®] DRY Register logic
|
|
@@ -21242,7 +21302,12 @@ const jokerCommandParser = {
|
|
|
21242
21302
|
* @see {@link ModelVariant}
|
|
21243
21303
|
* @public exported from `@promptbook/core`
|
|
21244
21304
|
*/
|
|
21245
|
-
const MODEL_VARIANTS = [
|
|
21305
|
+
const MODEL_VARIANTS = [
|
|
21306
|
+
'COMPLETION',
|
|
21307
|
+
'CHAT',
|
|
21308
|
+
'IMAGE_GENERATION',
|
|
21309
|
+
'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */,
|
|
21310
|
+
];
|
|
21246
21311
|
|
|
21247
21312
|
/**
|
|
21248
21313
|
* Parses the model command
|
|
@@ -23768,7 +23833,9 @@ class Wizard {
|
|
|
23768
23833
|
// ▶ Create executor - the function that will execute the Pipeline
|
|
23769
23834
|
const pipelineExecutor = createPipelineExecutor({ pipeline, tools });
|
|
23770
23835
|
// 🚀▶ Execute the Pipeline
|
|
23771
|
-
const result = await pipelineExecutor(inputParameters).asPromise({
|
|
23836
|
+
const result = await pipelineExecutor(inputParameters).asPromise({
|
|
23837
|
+
isCrashedOnError: true,
|
|
23838
|
+
});
|
|
23772
23839
|
const { outputParameters } = result;
|
|
23773
23840
|
const outputParametersLength = Object.keys(outputParameters).length;
|
|
23774
23841
|
let resultString;
|