@promptbook/pdf 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 +34 -27
- 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 +34 -27
- 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/pdf`
|
|
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
|
@@ -24,7 +24,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
24
24
|
* @generated
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0
|
|
27
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1577,8 +1577,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
1577
1577
|
*/
|
|
1578
1578
|
function removeDiacritics(input) {
|
|
1579
1579
|
/*eslint no-control-regex: "off"*/
|
|
1580
|
-
return input.replace(/[^\u0000-\u007E]/g, (
|
|
1581
|
-
return DIACRITIC_VARIANTS_LETTERS[
|
|
1580
|
+
return input.replace(/[^\u0000-\u007E]/g, (character) => {
|
|
1581
|
+
return DIACRITIC_VARIANTS_LETTERS[character] || character;
|
|
1582
1582
|
});
|
|
1583
1583
|
}
|
|
1584
1584
|
/**
|
|
@@ -1699,9 +1699,10 @@ function isValidFilePath(filename) {
|
|
|
1699
1699
|
*
|
|
1700
1700
|
* Note: [🔂] This function is idempotent.
|
|
1701
1701
|
* Note: Dataurl are considered perfectly valid.
|
|
1702
|
-
* Note: There are
|
|
1703
|
-
* - `isValidUrl` which tests any URL
|
|
1704
|
-
* - `
|
|
1702
|
+
* Note: There are few similar functions:
|
|
1703
|
+
* - `isValidUrl` *(this one)* which tests any URL
|
|
1704
|
+
* - `isValidAgentUrl` which tests just agent URL
|
|
1705
|
+
* - `isValidPipelineUrl` which tests just pipeline URL
|
|
1705
1706
|
*
|
|
1706
1707
|
* @public exported from `@promptbook/utils`
|
|
1707
1708
|
*/
|
|
@@ -2497,8 +2498,9 @@ function isValidPromptbookVersion(version) {
|
|
|
2497
2498
|
/**
|
|
2498
2499
|
* Tests if given string is valid pipeline URL URL.
|
|
2499
2500
|
*
|
|
2500
|
-
* Note: There are
|
|
2501
|
+
* Note: There are few similar functions:
|
|
2501
2502
|
* - `isValidUrl` which tests any URL
|
|
2503
|
+
* - `isValidAgentUrl` which tests just agent URL
|
|
2502
2504
|
* - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
|
|
2503
2505
|
*
|
|
2504
2506
|
* @public exported from `@promptbook/utils`
|
|
@@ -3767,7 +3769,7 @@ async function forEachAsync(array, options, callbackfunction) {
|
|
|
3767
3769
|
tasks.push(task);
|
|
3768
3770
|
runningTasks.push(task);
|
|
3769
3771
|
/* not await */ Promise.resolve(task).then(() => {
|
|
3770
|
-
runningTasks = runningTasks.filter((
|
|
3772
|
+
runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
|
|
3771
3773
|
});
|
|
3772
3774
|
if (maxParallelCount < runningTasks.length) {
|
|
3773
3775
|
await Promise.race(runningTasks);
|
|
@@ -3824,10 +3826,14 @@ function addUsage(...usageItems) {
|
|
|
3824
3826
|
}
|
|
3825
3827
|
|
|
3826
3828
|
/**
|
|
3827
|
-
* Intercepts LLM tools and counts total usage of the tools
|
|
3829
|
+
* Intercepts LLM tools and counts total usage of the tools.
|
|
3830
|
+
*
|
|
3831
|
+
* This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
|
|
3832
|
+
* usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
|
|
3833
|
+
* in real-time through an observable.
|
|
3828
3834
|
*
|
|
3829
|
-
* @param llmTools LLM tools to be intercepted
|
|
3830
|
-
* @returns
|
|
3835
|
+
* @param llmTools - The LLM tools to be intercepted and tracked
|
|
3836
|
+
* @returns An augmented version of the tools that includes usage tracking capabilities
|
|
3831
3837
|
* @public exported from `@promptbook/core`
|
|
3832
3838
|
*/
|
|
3833
3839
|
function countUsage(llmTools) {
|
|
@@ -3902,7 +3908,7 @@ function countUsage(llmTools) {
|
|
|
3902
3908
|
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
3903
3909
|
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
3904
3910
|
* > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
|
|
3905
|
-
* TODO: [👷♂️]
|
|
3911
|
+
* TODO: [👷♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
|
|
3906
3912
|
*/
|
|
3907
3913
|
|
|
3908
3914
|
/**
|
|
@@ -4092,17 +4098,21 @@ class MultipleLlmExecutionTools {
|
|
|
4092
4098
|
*/
|
|
4093
4099
|
|
|
4094
4100
|
/**
|
|
4095
|
-
* Joins multiple LLM Execution Tools into one
|
|
4101
|
+
* Joins multiple LLM Execution Tools into one.
|
|
4096
4102
|
*
|
|
4097
|
-
*
|
|
4103
|
+
* This function takes a list of `LlmExecutionTools` and returns a single unified
|
|
4104
|
+
* `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
|
|
4098
4105
|
*
|
|
4099
|
-
*
|
|
4100
|
-
*
|
|
4101
|
-
* 2
|
|
4102
|
-
* 3
|
|
4106
|
+
* 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
|
|
4107
|
+
* If the first provider doesn't support the requested model or fails, it tries the next one.
|
|
4108
|
+
* 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
|
|
4109
|
+
* 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
|
|
4103
4110
|
*
|
|
4111
|
+
* @param title - A descriptive title for this collection of joined tools
|
|
4112
|
+
* @param llmExecutionTools - An array of execution tools to be joined
|
|
4113
|
+
* @returns A single unified execution tool wrapper
|
|
4104
4114
|
*
|
|
4105
|
-
* Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools
|
|
4115
|
+
* Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
|
|
4106
4116
|
*
|
|
4107
4117
|
* @public exported from `@promptbook/core`
|
|
4108
4118
|
*/
|
|
@@ -4142,7 +4152,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
4142
4152
|
}
|
|
4143
4153
|
/**
|
|
4144
4154
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4145
|
-
* TODO: [👷♂️]
|
|
4155
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
4146
4156
|
*/
|
|
4147
4157
|
|
|
4148
4158
|
/**
|
|
@@ -4159,7 +4169,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
4159
4169
|
}
|
|
4160
4170
|
/**
|
|
4161
4171
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4162
|
-
* TODO: [👷♂️]
|
|
4172
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
4163
4173
|
*/
|
|
4164
4174
|
|
|
4165
4175
|
/**
|
|
@@ -4564,7 +4574,6 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
4564
4574
|
* @public exported from `@promptbook/core`
|
|
4565
4575
|
*/
|
|
4566
4576
|
async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
4567
|
-
// console.log('!! makeKnowledgeSourceHandler', knowledgeSource);
|
|
4568
4577
|
var _a;
|
|
4569
4578
|
const { fetch = promptbookFetch } = tools;
|
|
4570
4579
|
const { knowledgeSourceContent } = knowledgeSource;
|
|
@@ -6636,7 +6645,7 @@ async function getKnowledgeForTask(options) {
|
|
|
6636
6645
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6637
6646
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6638
6647
|
const { index } = knowledgePiece;
|
|
6639
|
-
const knowledgePieceIndex = index.find((
|
|
6648
|
+
const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
|
|
6640
6649
|
// <- TODO: Do not use just first knowledge piece and first index to determine embedding model
|
|
6641
6650
|
if (knowledgePieceIndex === undefined) {
|
|
6642
6651
|
return {
|
|
@@ -7084,7 +7093,7 @@ async function executePipeline(options) {
|
|
|
7084
7093
|
resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
|
|
7085
7094
|
})
|
|
7086
7095
|
.then(() => {
|
|
7087
|
-
resolving = resolving.filter((
|
|
7096
|
+
resolving = resolving.filter((workItem) => workItem !== work);
|
|
7088
7097
|
});
|
|
7089
7098
|
// <- Note: Errors are catched here [3]
|
|
7090
7099
|
// 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
|
|
@@ -7250,7 +7259,7 @@ function createPipelineExecutor(options) {
|
|
|
7250
7259
|
// Calculate and update tldr based on pipeline progress
|
|
7251
7260
|
const cv = newOngoingResult;
|
|
7252
7261
|
// Calculate progress based on parameters resolved vs total parameters
|
|
7253
|
-
const totalParameters = pipeline.parameters.filter((
|
|
7262
|
+
const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
|
|
7254
7263
|
let resolvedParameters = 0;
|
|
7255
7264
|
let currentTaskTitle = '';
|
|
7256
7265
|
// Get the resolved parameters from output parameters
|
|
@@ -7564,7 +7573,6 @@ class MarkitdownScraper {
|
|
|
7564
7573
|
// Note: Running Markitdown conversion ONLY if the file in the cache does not exist
|
|
7565
7574
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
7566
7575
|
const src = source.filename || source.url || null;
|
|
7567
|
-
// console.log('!!', { src, source, cacheFilehandler });
|
|
7568
7576
|
if (src === null) {
|
|
7569
7577
|
throw new UnexpectedError('Source has no filename or url');
|
|
7570
7578
|
}
|
|
@@ -7577,7 +7585,6 @@ class MarkitdownScraper {
|
|
|
7577
7585
|
throw new Error(`Markitdown could not convert the "${source.source}"`);
|
|
7578
7586
|
// <- TODO: [🍀] Make MarkitdownError
|
|
7579
7587
|
}
|
|
7580
|
-
// console.log('!!', { result, cacheFilehandler });
|
|
7581
7588
|
// Note: Try to cache the converted content, but don't fail if the filesystem is read-only
|
|
7582
7589
|
try {
|
|
7583
7590
|
await this.tools.fs.writeFile(cacheFilehandler.filename, result.text_content);
|