@promptbook/wizard 0.104.0-10 → 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 +141 -28
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +24 -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/types/ChatMessage.d.ts +2 -2
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +1 -1
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +1 -1
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +1 -1
- package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +1 -1
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +1 -1
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +1 -1
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +1 -1
- package/esm/typings/src/book-components/icons/SaveIcon.d.ts +1 -1
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -2
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +0 -54
- 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/countUsage.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/agent/Agent.d.ts +6 -1
- package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
- package/esm/typings/src/remote-server/ui/ServerApp.d.ts +1 -1
- package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
- package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
- package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
- package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
- 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/$randomAgentPersona.d.ts +3 -2
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +141 -28
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
* @generated
|
|
49
49
|
* @see https://github.com/webgptorg/promptbook
|
|
50
50
|
*/
|
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-12';
|
|
52
52
|
/**
|
|
53
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
54
54
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -5668,6 +5668,22 @@
|
|
|
5668
5668
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
5669
5669
|
*/
|
|
5670
5670
|
|
|
5671
|
+
/**
|
|
5672
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
5673
|
+
*
|
|
5674
|
+
* @private
|
|
5675
|
+
*/
|
|
5676
|
+
function mapToolsToOpenAi(tools) {
|
|
5677
|
+
return tools.map((tool) => ({
|
|
5678
|
+
type: 'function',
|
|
5679
|
+
function: {
|
|
5680
|
+
name: tool.name,
|
|
5681
|
+
description: tool.description,
|
|
5682
|
+
parameters: tool.parameters,
|
|
5683
|
+
},
|
|
5684
|
+
}));
|
|
5685
|
+
}
|
|
5686
|
+
|
|
5671
5687
|
/**
|
|
5672
5688
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
5673
5689
|
*
|
|
@@ -5865,6 +5881,9 @@
|
|
|
5865
5881
|
},
|
|
5866
5882
|
],
|
|
5867
5883
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
5884
|
+
tools: currentModelRequirements.tools === undefined
|
|
5885
|
+
? undefined
|
|
5886
|
+
: mapToolsToOpenAi(currentModelRequirements.tools),
|
|
5868
5887
|
};
|
|
5869
5888
|
const start = $getCurrentDate();
|
|
5870
5889
|
if (this.options.isVerbose) {
|
|
@@ -6009,6 +6028,7 @@
|
|
|
6009
6028
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
6010
6029
|
const rawRequest = {
|
|
6011
6030
|
...modelSettings,
|
|
6031
|
+
model: modelName,
|
|
6012
6032
|
prompt: rawPromptContent,
|
|
6013
6033
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
6014
6034
|
};
|
|
@@ -6263,8 +6283,8 @@
|
|
|
6263
6283
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
6264
6284
|
const rawRequest = {
|
|
6265
6285
|
...modelSettings,
|
|
6266
|
-
size: modelSettings.size || '1024x1024',
|
|
6267
6286
|
prompt: rawPromptContent,
|
|
6287
|
+
size: modelSettings.size || '1024x1024',
|
|
6268
6288
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
6269
6289
|
response_format: 'url', // TODO: [🧠] Maybe allow b64_json
|
|
6270
6290
|
};
|
|
@@ -7162,6 +7182,7 @@
|
|
|
7162
7182
|
thread: {
|
|
7163
7183
|
messages: threadMessages,
|
|
7164
7184
|
},
|
|
7185
|
+
tools: modelRequirements.tools === undefined ? undefined : mapToolsToOpenAi(modelRequirements.tools),
|
|
7165
7186
|
// <- TODO: Add user identification here> user: this.options.user,
|
|
7166
7187
|
};
|
|
7167
7188
|
const start = $getCurrentDate();
|
|
@@ -9450,7 +9471,7 @@
|
|
|
9450
9471
|
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
9451
9472
|
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
9452
9473
|
* > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
|
|
9453
|
-
* TODO: [👷♂️]
|
|
9474
|
+
* TODO: [👷♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
|
|
9454
9475
|
*/
|
|
9455
9476
|
|
|
9456
9477
|
/**
|
|
@@ -9690,7 +9711,7 @@
|
|
|
9690
9711
|
}
|
|
9691
9712
|
/**
|
|
9692
9713
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
9693
|
-
* TODO: [👷♂️]
|
|
9714
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
9694
9715
|
*/
|
|
9695
9716
|
|
|
9696
9717
|
/**
|
|
@@ -9707,7 +9728,7 @@
|
|
|
9707
9728
|
}
|
|
9708
9729
|
/**
|
|
9709
9730
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
9710
|
-
* TODO: [👷♂️]
|
|
9731
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
9711
9732
|
*/
|
|
9712
9733
|
|
|
9713
9734
|
/**
|
|
@@ -16779,19 +16800,37 @@
|
|
|
16779
16800
|
`);
|
|
16780
16801
|
}
|
|
16781
16802
|
applyToAgentModelRequirements(requirements, content) {
|
|
16782
|
-
// We simply mark that browser capability is enabled in metadata
|
|
16783
|
-
// Get existing metadata
|
|
16784
|
-
const existingMetadata = requirements.metadata || {};
|
|
16785
16803
|
// Get existing tools array or create new one
|
|
16786
|
-
const existingTools =
|
|
16787
|
-
// Add '
|
|
16788
|
-
const updatedTools = existingTools.
|
|
16789
|
-
|
|
16804
|
+
const existingTools = requirements.tools || [];
|
|
16805
|
+
// Add 'web_browser' to tools if not already present
|
|
16806
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
|
|
16807
|
+
? existingTools
|
|
16808
|
+
: [
|
|
16809
|
+
...existingTools,
|
|
16810
|
+
{
|
|
16811
|
+
name: 'web_browser',
|
|
16812
|
+
description: spaceTrim$1.spaceTrim(`
|
|
16813
|
+
A tool that can browse the web.
|
|
16814
|
+
Use this tool when you need to access specific websites or browse the internet.
|
|
16815
|
+
`),
|
|
16816
|
+
parameters: {
|
|
16817
|
+
type: 'object',
|
|
16818
|
+
properties: {
|
|
16819
|
+
url: {
|
|
16820
|
+
type: 'string',
|
|
16821
|
+
description: 'The URL to browse',
|
|
16822
|
+
},
|
|
16823
|
+
},
|
|
16824
|
+
required: ['url'],
|
|
16825
|
+
},
|
|
16826
|
+
},
|
|
16827
|
+
];
|
|
16828
|
+
// Return requirements with updated tools and metadata
|
|
16790
16829
|
return {
|
|
16791
16830
|
...requirements,
|
|
16831
|
+
tools: updatedTools,
|
|
16792
16832
|
metadata: {
|
|
16793
|
-
...
|
|
16794
|
-
tools: updatedTools,
|
|
16833
|
+
...requirements.metadata,
|
|
16795
16834
|
useBrowser: true,
|
|
16796
16835
|
},
|
|
16797
16836
|
};
|
|
@@ -16884,13 +16923,13 @@
|
|
|
16884
16923
|
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
16885
16924
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
16886
16925
|
*
|
|
16887
|
-
* The content following `USE SEARCH ENGINE` is
|
|
16926
|
+
* The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
16888
16927
|
*
|
|
16889
16928
|
* Example usage in agent source:
|
|
16890
16929
|
*
|
|
16891
16930
|
* ```book
|
|
16892
16931
|
* USE SEARCH ENGINE
|
|
16893
|
-
* USE SEARCH ENGINE
|
|
16932
|
+
* USE SEARCH ENGINE Hledej informace o Přemyslovcích
|
|
16894
16933
|
* ```
|
|
16895
16934
|
*
|
|
16896
16935
|
* @private [🪔] Maybe export the commitments through some package
|
|
@@ -16922,7 +16961,7 @@
|
|
|
16922
16961
|
|
|
16923
16962
|
## Key aspects
|
|
16924
16963
|
|
|
16925
|
-
- The content following \`USE SEARCH ENGINE\` is
|
|
16964
|
+
- The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
16926
16965
|
- The actual search engine tool usage is handled by the agent runtime
|
|
16927
16966
|
- Allows the agent to search for current information from the web
|
|
16928
16967
|
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
@@ -16947,20 +16986,39 @@
|
|
|
16947
16986
|
`);
|
|
16948
16987
|
}
|
|
16949
16988
|
applyToAgentModelRequirements(requirements, content) {
|
|
16950
|
-
// We simply mark that search engine capability is enabled in metadata
|
|
16951
|
-
// Get existing metadata
|
|
16952
|
-
const existingMetadata = requirements.metadata || {};
|
|
16953
16989
|
// Get existing tools array or create new one
|
|
16954
|
-
const existingTools =
|
|
16955
|
-
// Add '
|
|
16956
|
-
const updatedTools = existingTools.
|
|
16957
|
-
|
|
16990
|
+
const existingTools = requirements.tools || [];
|
|
16991
|
+
// Add 'web_search' to tools if not already present
|
|
16992
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
|
|
16993
|
+
? existingTools
|
|
16994
|
+
: [
|
|
16995
|
+
...existingTools,
|
|
16996
|
+
{
|
|
16997
|
+
name: 'web_search',
|
|
16998
|
+
description: spaceTrim$1.spaceTrim(`
|
|
16999
|
+
Search the internet for information.
|
|
17000
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
17001
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
17002
|
+
`),
|
|
17003
|
+
parameters: {
|
|
17004
|
+
type: 'object',
|
|
17005
|
+
properties: {
|
|
17006
|
+
query: {
|
|
17007
|
+
type: 'string',
|
|
17008
|
+
description: 'The search query',
|
|
17009
|
+
},
|
|
17010
|
+
},
|
|
17011
|
+
required: ['query'],
|
|
17012
|
+
},
|
|
17013
|
+
},
|
|
17014
|
+
];
|
|
17015
|
+
// Return requirements with updated tools and metadata
|
|
16958
17016
|
return {
|
|
16959
17017
|
...requirements,
|
|
17018
|
+
tools: updatedTools,
|
|
16960
17019
|
metadata: {
|
|
16961
|
-
...
|
|
16962
|
-
|
|
16963
|
-
useSearchEngine: true,
|
|
17020
|
+
...requirements.metadata,
|
|
17021
|
+
useSearchEngine: content || true,
|
|
16964
17022
|
},
|
|
16965
17023
|
};
|
|
16966
17024
|
}
|
|
@@ -17945,7 +18003,57 @@
|
|
|
17945
18003
|
}
|
|
17946
18004
|
const meta = {};
|
|
17947
18005
|
const links = [];
|
|
18006
|
+
const capabilities = [];
|
|
17948
18007
|
for (const commitment of parseResult.commitments) {
|
|
18008
|
+
if (commitment.type === 'USE BROWSER') {
|
|
18009
|
+
capabilities.push({
|
|
18010
|
+
type: 'browser',
|
|
18011
|
+
label: 'Browser',
|
|
18012
|
+
iconName: 'Globe',
|
|
18013
|
+
});
|
|
18014
|
+
continue;
|
|
18015
|
+
}
|
|
18016
|
+
if (commitment.type === 'USE SEARCH ENGINE') {
|
|
18017
|
+
capabilities.push({
|
|
18018
|
+
type: 'search-engine',
|
|
18019
|
+
label: 'Search Internet',
|
|
18020
|
+
iconName: 'Search',
|
|
18021
|
+
});
|
|
18022
|
+
continue;
|
|
18023
|
+
}
|
|
18024
|
+
if (commitment.type === 'KNOWLEDGE') {
|
|
18025
|
+
const content = spaceTrim__default["default"](commitment.content).split('\n')[0] || '';
|
|
18026
|
+
let label = content;
|
|
18027
|
+
let iconName = 'Book';
|
|
18028
|
+
if (content.startsWith('http://') || content.startsWith('https://')) {
|
|
18029
|
+
try {
|
|
18030
|
+
const url = new URL(content);
|
|
18031
|
+
if (url.pathname.endsWith('.pdf')) {
|
|
18032
|
+
label = url.pathname.split('/').pop() || 'Document.pdf';
|
|
18033
|
+
iconName = 'FileText';
|
|
18034
|
+
}
|
|
18035
|
+
else {
|
|
18036
|
+
label = url.hostname.replace(/^www\./, '');
|
|
18037
|
+
}
|
|
18038
|
+
}
|
|
18039
|
+
catch (e) {
|
|
18040
|
+
// Invalid URL, treat as text
|
|
18041
|
+
}
|
|
18042
|
+
}
|
|
18043
|
+
else {
|
|
18044
|
+
// Text content - take first few words
|
|
18045
|
+
const words = content.split(/\s+/);
|
|
18046
|
+
if (words.length > 4) {
|
|
18047
|
+
label = words.slice(0, 4).join(' ') + '...';
|
|
18048
|
+
}
|
|
18049
|
+
}
|
|
18050
|
+
capabilities.push({
|
|
18051
|
+
type: 'knowledge',
|
|
18052
|
+
label,
|
|
18053
|
+
iconName,
|
|
18054
|
+
});
|
|
18055
|
+
continue;
|
|
18056
|
+
}
|
|
17949
18057
|
if (commitment.type === 'META LINK') {
|
|
17950
18058
|
const linkValue = spaceTrim__default["default"](commitment.content);
|
|
17951
18059
|
links.push(linkValue);
|
|
@@ -17956,6 +18064,10 @@
|
|
|
17956
18064
|
meta.image = spaceTrim__default["default"](commitment.content);
|
|
17957
18065
|
continue;
|
|
17958
18066
|
}
|
|
18067
|
+
if (commitment.type === 'META DESCRIPTION') {
|
|
18068
|
+
meta.description = spaceTrim__default["default"](commitment.content);
|
|
18069
|
+
continue;
|
|
18070
|
+
}
|
|
17959
18071
|
if (commitment.type === 'META COLOR') {
|
|
17960
18072
|
meta.color = normalizeSeparator(commitment.content);
|
|
17961
18073
|
continue;
|
|
@@ -17992,6 +18104,7 @@
|
|
|
17992
18104
|
meta,
|
|
17993
18105
|
links,
|
|
17994
18106
|
parameters,
|
|
18107
|
+
capabilities,
|
|
17995
18108
|
};
|
|
17996
18109
|
}
|
|
17997
18110
|
/**
|
|
@@ -19430,7 +19543,7 @@
|
|
|
19430
19543
|
}
|
|
19431
19544
|
/**
|
|
19432
19545
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
19433
|
-
* TODO: [👷♂️]
|
|
19546
|
+
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
19434
19547
|
* TODO: [🥃] Allow `ptbk make` without llm tools
|
|
19435
19548
|
* TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
|
|
19436
19549
|
* TODO: [®] DRY Register logic
|