@promptbook/node 0.104.0-9 → 0.104.0
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/README.md +0 -4
- package/esm/index.es.js +40 -26
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +0 -6
- package/esm/typings/src/_packages/core.index.d.ts +8 -6
- package/esm/typings/src/_packages/types.index.d.ts +8 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -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 +12 -2
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +6 -3
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +5 -1
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +5 -1
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +6 -2
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +6 -2
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +5 -1
- package/esm/typings/src/book-components/icons/SaveIcon.d.ts +6 -2
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +1 -1
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +9 -7
- 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/config.d.ts +8 -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/countUsage.d.ts +8 -4
- 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 +12 -8
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
- package/esm/typings/src/remote-server/ui/ServerApp.d.ts +5 -1
- package/esm/typings/src/scrapers/_common/utils/promptbookFetch.test.d.ts +1 -0
- 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/types/typeAliasEmoji.d.ts +2 -2
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +7 -2
- 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/utils/validators/url/isValidAgentUrl.d.ts +16 -0
- package/esm/typings/src/utils/validators/url/isValidAgentUrl.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +4 -3
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +40 -26
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/servers.d.ts +0 -50
package/README.md
CHANGED
|
@@ -27,10 +27,6 @@ Turn your company's scattered knowledge into AI ready Books
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
<blockquote style="color: #ff8811">
|
|
31
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
32
|
-
</blockquote>
|
|
33
|
-
|
|
34
30
|
## 📦 Package `@promptbook/node`
|
|
35
31
|
|
|
36
32
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1707,9 +1707,10 @@ function isValidPromptbookVersion(version) {
|
|
|
1707
1707
|
*
|
|
1708
1708
|
* Note: [🔂] This function is idempotent.
|
|
1709
1709
|
* Note: Dataurl are considered perfectly valid.
|
|
1710
|
-
* Note: There are
|
|
1711
|
-
* - `isValidUrl` which tests any URL
|
|
1712
|
-
* - `
|
|
1710
|
+
* Note: There are few similar functions:
|
|
1711
|
+
* - `isValidUrl` *(this one)* which tests any URL
|
|
1712
|
+
* - `isValidAgentUrl` which tests just agent URL
|
|
1713
|
+
* - `isValidPipelineUrl` which tests just pipeline URL
|
|
1713
1714
|
*
|
|
1714
1715
|
* @public exported from `@promptbook/utils`
|
|
1715
1716
|
*/
|
|
@@ -1735,8 +1736,9 @@ function isValidUrl(url) {
|
|
|
1735
1736
|
/**
|
|
1736
1737
|
* Tests if given string is valid pipeline URL URL.
|
|
1737
1738
|
*
|
|
1738
|
-
* Note: There are
|
|
1739
|
+
* Note: There are few similar functions:
|
|
1739
1740
|
* - `isValidUrl` which tests any URL
|
|
1741
|
+
* - `isValidAgentUrl` which tests just agent URL
|
|
1740
1742
|
* - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
|
|
1741
1743
|
*
|
|
1742
1744
|
* @public exported from `@promptbook/utils`
|
|
@@ -4128,17 +4130,21 @@ class MultipleLlmExecutionTools {
|
|
|
4128
4130
|
*/
|
|
4129
4131
|
|
|
4130
4132
|
/**
|
|
4131
|
-
* Joins multiple LLM Execution Tools into one
|
|
4133
|
+
* Joins multiple LLM Execution Tools into one.
|
|
4132
4134
|
*
|
|
4133
|
-
*
|
|
4135
|
+
* This function takes a list of `LlmExecutionTools` and returns a single unified
|
|
4136
|
+
* `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
|
|
4134
4137
|
*
|
|
4135
|
-
*
|
|
4136
|
-
*
|
|
4137
|
-
* 2
|
|
4138
|
-
* 3
|
|
4138
|
+
* 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
|
|
4139
|
+
* If the first provider doesn't support the requested model or fails, it tries the next one.
|
|
4140
|
+
* 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
|
|
4141
|
+
* 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
|
|
4139
4142
|
*
|
|
4143
|
+
* @param title - A descriptive title for this collection of joined tools
|
|
4144
|
+
* @param llmExecutionTools - An array of execution tools to be joined
|
|
4145
|
+
* @returns A single unified execution tool wrapper
|
|
4140
4146
|
*
|
|
4141
|
-
* Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools
|
|
4147
|
+
* Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
|
|
4142
4148
|
*
|
|
4143
4149
|
* @public exported from `@promptbook/core`
|
|
4144
4150
|
*/
|
|
@@ -4178,7 +4184,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
4178
4184
|
}
|
|
4179
4185
|
/**
|
|
4180
4186
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4181
|
-
* TODO: [👷♂️]
|
|
4187
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
4182
4188
|
*/
|
|
4183
4189
|
|
|
4184
4190
|
/**
|
|
@@ -4195,7 +4201,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
4195
4201
|
}
|
|
4196
4202
|
/**
|
|
4197
4203
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4198
|
-
* TODO: [👷♂️]
|
|
4204
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
4199
4205
|
*/
|
|
4200
4206
|
|
|
4201
4207
|
/**
|
|
@@ -4749,8 +4755,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
4749
4755
|
*/
|
|
4750
4756
|
function removeDiacritics(input) {
|
|
4751
4757
|
/*eslint no-control-regex: "off"*/
|
|
4752
|
-
return input.replace(/[^\u0000-\u007E]/g, (
|
|
4753
|
-
return DIACRITIC_VARIANTS_LETTERS[
|
|
4758
|
+
return input.replace(/[^\u0000-\u007E]/g, (character) => {
|
|
4759
|
+
return DIACRITIC_VARIANTS_LETTERS[character] || character;
|
|
4754
4760
|
});
|
|
4755
4761
|
}
|
|
4756
4762
|
/**
|
|
@@ -5441,7 +5447,7 @@ async function getKnowledgeForTask(options) {
|
|
|
5441
5447
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
5442
5448
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
5443
5449
|
const { index } = knowledgePiece;
|
|
5444
|
-
const knowledgePieceIndex = index.find((
|
|
5450
|
+
const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
|
|
5445
5451
|
// <- TODO: Do not use just first knowledge piece and first index to determine embedding model
|
|
5446
5452
|
if (knowledgePieceIndex === undefined) {
|
|
5447
5453
|
return {
|
|
@@ -5889,7 +5895,7 @@ async function executePipeline(options) {
|
|
|
5889
5895
|
resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
|
|
5890
5896
|
})
|
|
5891
5897
|
.then(() => {
|
|
5892
|
-
resolving = resolving.filter((
|
|
5898
|
+
resolving = resolving.filter((workItem) => workItem !== work);
|
|
5893
5899
|
});
|
|
5894
5900
|
// <- Note: Errors are catched here [3]
|
|
5895
5901
|
// TODO: BUT if in multiple tasks are errors, only the first one is catched so maybe we should catch errors here and save them to errors array here
|
|
@@ -6055,7 +6061,7 @@ function createPipelineExecutor(options) {
|
|
|
6055
6061
|
// Calculate and update tldr based on pipeline progress
|
|
6056
6062
|
const cv = newOngoingResult;
|
|
6057
6063
|
// Calculate progress based on parameters resolved vs total parameters
|
|
6058
|
-
const totalParameters = pipeline.parameters.filter((
|
|
6064
|
+
const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
|
|
6059
6065
|
let resolvedParameters = 0;
|
|
6060
6066
|
let currentTaskTitle = '';
|
|
6061
6067
|
// Get the resolved parameters from output parameters
|
|
@@ -6135,7 +6141,7 @@ async function forEachAsync(array, options, callbackfunction) {
|
|
|
6135
6141
|
tasks.push(task);
|
|
6136
6142
|
runningTasks.push(task);
|
|
6137
6143
|
/* not await */ Promise.resolve(task).then(() => {
|
|
6138
|
-
runningTasks = runningTasks.filter((
|
|
6144
|
+
runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
|
|
6139
6145
|
});
|
|
6140
6146
|
if (maxParallelCount < runningTasks.length) {
|
|
6141
6147
|
await Promise.race(runningTasks);
|
|
@@ -6145,10 +6151,14 @@ async function forEachAsync(array, options, callbackfunction) {
|
|
|
6145
6151
|
}
|
|
6146
6152
|
|
|
6147
6153
|
/**
|
|
6148
|
-
* Intercepts LLM tools and counts total usage of the tools
|
|
6154
|
+
* Intercepts LLM tools and counts total usage of the tools.
|
|
6149
6155
|
*
|
|
6150
|
-
*
|
|
6151
|
-
*
|
|
6156
|
+
* This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
|
|
6157
|
+
* usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
|
|
6158
|
+
* in real-time through an observable.
|
|
6159
|
+
*
|
|
6160
|
+
* @param llmTools - The LLM tools to be intercepted and tracked
|
|
6161
|
+
* @returns An augmented version of the tools that includes usage tracking capabilities
|
|
6152
6162
|
* @public exported from `@promptbook/core`
|
|
6153
6163
|
*/
|
|
6154
6164
|
function countUsage(llmTools) {
|
|
@@ -6223,7 +6233,7 @@ function countUsage(llmTools) {
|
|
|
6223
6233
|
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
6224
6234
|
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
6225
6235
|
* > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
|
|
6226
|
-
* TODO: [👷♂️]
|
|
6236
|
+
* TODO: [👷♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
|
|
6227
6237
|
*/
|
|
6228
6238
|
|
|
6229
6239
|
/**
|
|
@@ -6760,7 +6770,6 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
6760
6770
|
* @public exported from `@promptbook/core`
|
|
6761
6771
|
*/
|
|
6762
6772
|
async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
6763
|
-
// console.log('!! makeKnowledgeSourceHandler', knowledgeSource);
|
|
6764
6773
|
var _a;
|
|
6765
6774
|
const { fetch = promptbookFetch } = tools;
|
|
6766
6775
|
const { knowledgeSourceContent } = knowledgeSource;
|
|
@@ -8815,7 +8824,12 @@ const jokerCommandParser = {
|
|
|
8815
8824
|
* @see {@link ModelVariant}
|
|
8816
8825
|
* @public exported from `@promptbook/core`
|
|
8817
8826
|
*/
|
|
8818
|
-
const MODEL_VARIANTS = [
|
|
8827
|
+
const MODEL_VARIANTS = [
|
|
8828
|
+
'COMPLETION',
|
|
8829
|
+
'CHAT',
|
|
8830
|
+
'IMAGE_GENERATION',
|
|
8831
|
+
'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */,
|
|
8832
|
+
];
|
|
8819
8833
|
|
|
8820
8834
|
/**
|
|
8821
8835
|
* Parses the model command
|