@promptbook/wizard 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 +89 -27
- 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 +2 -2
- package/umd/index.umd.js +89 -27
- 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-12';
|
|
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
|
/**
|
|
@@ -16767,19 +16788,37 @@ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
16767
16788
|
`);
|
|
16768
16789
|
}
|
|
16769
16790
|
applyToAgentModelRequirements(requirements, content) {
|
|
16770
|
-
// We simply mark that browser capability is enabled in metadata
|
|
16771
|
-
// Get existing metadata
|
|
16772
|
-
const existingMetadata = requirements.metadata || {};
|
|
16773
16791
|
// Get existing tools array or create new one
|
|
16774
|
-
const existingTools =
|
|
16775
|
-
// Add '
|
|
16776
|
-
const updatedTools = existingTools.
|
|
16777
|
-
|
|
16792
|
+
const existingTools = requirements.tools || [];
|
|
16793
|
+
// Add 'web_browser' to tools if not already present
|
|
16794
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
|
|
16795
|
+
? existingTools
|
|
16796
|
+
: [
|
|
16797
|
+
...existingTools,
|
|
16798
|
+
{
|
|
16799
|
+
name: 'web_browser',
|
|
16800
|
+
description: spaceTrim$1(`
|
|
16801
|
+
A tool that can browse the web.
|
|
16802
|
+
Use this tool when you need to access specific websites or browse the internet.
|
|
16803
|
+
`),
|
|
16804
|
+
parameters: {
|
|
16805
|
+
type: 'object',
|
|
16806
|
+
properties: {
|
|
16807
|
+
url: {
|
|
16808
|
+
type: 'string',
|
|
16809
|
+
description: 'The URL to browse',
|
|
16810
|
+
},
|
|
16811
|
+
},
|
|
16812
|
+
required: ['url'],
|
|
16813
|
+
},
|
|
16814
|
+
},
|
|
16815
|
+
];
|
|
16816
|
+
// Return requirements with updated tools and metadata
|
|
16778
16817
|
return {
|
|
16779
16818
|
...requirements,
|
|
16819
|
+
tools: updatedTools,
|
|
16780
16820
|
metadata: {
|
|
16781
|
-
...
|
|
16782
|
-
tools: updatedTools,
|
|
16821
|
+
...requirements.metadata,
|
|
16783
16822
|
useBrowser: true,
|
|
16784
16823
|
},
|
|
16785
16824
|
};
|
|
@@ -16872,13 +16911,13 @@ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
16872
16911
|
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
16873
16912
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
16874
16913
|
*
|
|
16875
|
-
* The content following `USE SEARCH ENGINE` is
|
|
16914
|
+
* The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
16876
16915
|
*
|
|
16877
16916
|
* Example usage in agent source:
|
|
16878
16917
|
*
|
|
16879
16918
|
* ```book
|
|
16880
16919
|
* USE SEARCH ENGINE
|
|
16881
|
-
* USE SEARCH ENGINE
|
|
16920
|
+
* USE SEARCH ENGINE Hledej informace o Přemyslovcích
|
|
16882
16921
|
* ```
|
|
16883
16922
|
*
|
|
16884
16923
|
* @private [🪔] Maybe export the commitments through some package
|
|
@@ -16910,7 +16949,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
16910
16949
|
|
|
16911
16950
|
## Key aspects
|
|
16912
16951
|
|
|
16913
|
-
- The content following \`USE SEARCH ENGINE\` is
|
|
16952
|
+
- The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
16914
16953
|
- The actual search engine tool usage is handled by the agent runtime
|
|
16915
16954
|
- Allows the agent to search for current information from the web
|
|
16916
16955
|
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
@@ -16935,20 +16974,39 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
16935
16974
|
`);
|
|
16936
16975
|
}
|
|
16937
16976
|
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
16977
|
// Get existing tools array or create new one
|
|
16942
|
-
const existingTools =
|
|
16943
|
-
// Add '
|
|
16944
|
-
const updatedTools = existingTools.
|
|
16945
|
-
|
|
16978
|
+
const existingTools = requirements.tools || [];
|
|
16979
|
+
// Add 'web_search' to tools if not already present
|
|
16980
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
|
|
16981
|
+
? existingTools
|
|
16982
|
+
: [
|
|
16983
|
+
...existingTools,
|
|
16984
|
+
{
|
|
16985
|
+
name: 'web_search',
|
|
16986
|
+
description: spaceTrim$1(`
|
|
16987
|
+
Search the internet for information.
|
|
16988
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
16989
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
16990
|
+
`),
|
|
16991
|
+
parameters: {
|
|
16992
|
+
type: 'object',
|
|
16993
|
+
properties: {
|
|
16994
|
+
query: {
|
|
16995
|
+
type: 'string',
|
|
16996
|
+
description: 'The search query',
|
|
16997
|
+
},
|
|
16998
|
+
},
|
|
16999
|
+
required: ['query'],
|
|
17000
|
+
},
|
|
17001
|
+
},
|
|
17002
|
+
];
|
|
17003
|
+
// Return requirements with updated tools and metadata
|
|
16946
17004
|
return {
|
|
16947
17005
|
...requirements,
|
|
17006
|
+
tools: updatedTools,
|
|
16948
17007
|
metadata: {
|
|
16949
|
-
...
|
|
16950
|
-
|
|
16951
|
-
useSearchEngine: true,
|
|
17008
|
+
...requirements.metadata,
|
|
17009
|
+
useSearchEngine: content || true,
|
|
16952
17010
|
},
|
|
16953
17011
|
};
|
|
16954
17012
|
}
|
|
@@ -17994,6 +18052,10 @@ function parseAgentSource(agentSource) {
|
|
|
17994
18052
|
meta.image = spaceTrim$2(commitment.content);
|
|
17995
18053
|
continue;
|
|
17996
18054
|
}
|
|
18055
|
+
if (commitment.type === 'META DESCRIPTION') {
|
|
18056
|
+
meta.description = spaceTrim$2(commitment.content);
|
|
18057
|
+
continue;
|
|
18058
|
+
}
|
|
17997
18059
|
if (commitment.type === 'META COLOR') {
|
|
17998
18060
|
meta.color = normalizeSeparator(commitment.content);
|
|
17999
18061
|
continue;
|
|
@@ -19469,7 +19531,7 @@ async function $provideLlmToolsForWizardOrCli(options) {
|
|
|
19469
19531
|
}
|
|
19470
19532
|
/**
|
|
19471
19533
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
19472
|
-
* TODO: [👷♂️]
|
|
19534
|
+
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
19473
19535
|
* TODO: [🥃] Allow `ptbk make` without llm tools
|
|
19474
19536
|
* TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
|
|
19475
19537
|
* TODO: [®] DRY Register logic
|