@promptbook/markitdown 0.105.0-0 → 0.105.0-3
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 +80 -63
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +10 -3
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +11 -1
- package/esm/typings/src/book-2.0/agent-source/communication-samples.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.blocks.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.import.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSource.import.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.blocks.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_TIME/USE_TIME.d.ts +40 -0
- package/esm/typings/src/commitments/USE_TIME/USE_TIME.test.d.ts +1 -0
- package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +8 -0
- package/esm/typings/src/commitments/_base/CommitmentDefinition.d.ts +8 -0
- package/esm/typings/src/commitments/index.d.ts +11 -2
- package/esm/typings/src/config.d.ts +1 -0
- package/esm/typings/src/import-plugins/$fileImportPlugins.d.ts +7 -0
- package/esm/typings/src/import-plugins/AgentFileImportPlugin.d.ts +7 -0
- package/esm/typings/src/import-plugins/FileImportPlugin.d.ts +24 -0
- package/esm/typings/src/import-plugins/JsonFileImportPlugin.d.ts +7 -0
- package/esm/typings/src/import-plugins/TextFileImportPlugin.d.ts +7 -0
- package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +2 -2
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +9 -2
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +10 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +6 -1
- package/esm/typings/src/types/ModelRequirements.d.ts +6 -12
- package/esm/typings/src/utils/execCommand/$execCommandNormalizeOptions.d.ts +2 -3
- package/esm/typings/src/utils/execCommand/ExecCommandOptions.d.ts +7 -1
- package/esm/typings/src/utils/organization/keepImported.d.ts +9 -0
- package/esm/typings/src/utils/organization/keepTypeImported.d.ts +0 -1
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +4 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +2 -1
- package/esm/typings/src/utils/random/$randomAgentRule.d.ts +14 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +80 -63
- package/umd/index.umd.js.map +1 -1
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.105.0-
|
|
27
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-3';
|
|
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
|
|
@@ -986,6 +986,7 @@ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
|
986
986
|
SEPARATOR: Color.fromHex('#cccccc'),
|
|
987
987
|
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
988
988
|
PARAMETER: Color.fromHex('#8e44ad'),
|
|
989
|
+
CODE_BLOCK: Color.fromHex('#7700ffff'),
|
|
989
990
|
});
|
|
990
991
|
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
991
992
|
/**
|
|
@@ -3820,74 +3821,90 @@ function addUsage(...usageItems) {
|
|
|
3820
3821
|
* in real-time through an observable.
|
|
3821
3822
|
*
|
|
3822
3823
|
* @param llmTools - The LLM tools to be intercepted and tracked
|
|
3823
|
-
* @returns
|
|
3824
|
+
* @returns Full proxy of the tools with added usage tracking capabilities
|
|
3824
3825
|
* @public exported from `@promptbook/core`
|
|
3825
3826
|
*/
|
|
3826
3827
|
function countUsage(llmTools) {
|
|
3827
3828
|
let totalUsage = ZERO_USAGE;
|
|
3828
3829
|
const spending = new Subject();
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
//
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
//
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
//
|
|
3851
|
-
|
|
3830
|
+
// Create a Proxy to intercept all property access and ensure full proxying of all properties
|
|
3831
|
+
const proxyTools = new Proxy(llmTools, {
|
|
3832
|
+
get(target, prop, receiver) {
|
|
3833
|
+
// Handle title property
|
|
3834
|
+
if (prop === 'title') {
|
|
3835
|
+
return `${target.title} (+usage)`;
|
|
3836
|
+
// <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
|
|
3837
|
+
// <- TODO: [🧈][🧠] Does it make sense to suffix "(+usage)"?
|
|
3838
|
+
}
|
|
3839
|
+
// Handle description property
|
|
3840
|
+
if (prop === 'description') {
|
|
3841
|
+
return `${target.description} (+usage)`;
|
|
3842
|
+
// <- TODO: [🧈] Maybe standartize the suffix when wrapping `LlmExecutionTools` up
|
|
3843
|
+
// <- TODO: [🧈][🧠] Does it make sense to suffix "(+usage)"?
|
|
3844
|
+
}
|
|
3845
|
+
// Handle spending method (new method added by this wrapper)
|
|
3846
|
+
if (prop === 'spending') {
|
|
3847
|
+
return () => {
|
|
3848
|
+
return spending.asObservable();
|
|
3849
|
+
};
|
|
3850
|
+
}
|
|
3851
|
+
// Handle getTotalUsage method (new method added by this wrapper)
|
|
3852
|
+
if (prop === 'getTotalUsage') {
|
|
3853
|
+
// <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
|
|
3854
|
+
return () => {
|
|
3855
|
+
return totalUsage;
|
|
3856
|
+
};
|
|
3857
|
+
}
|
|
3858
|
+
// Handle callChatModel method with usage counting
|
|
3859
|
+
if (prop === 'callChatModel' && target.callChatModel !== undefined) {
|
|
3860
|
+
return async (prompt) => {
|
|
3861
|
+
// console.info('[🚕] callChatModel through countTotalUsage');
|
|
3862
|
+
const promptResult = await target.callChatModel(prompt);
|
|
3863
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3864
|
+
spending.next(promptResult.usage);
|
|
3865
|
+
return promptResult;
|
|
3866
|
+
};
|
|
3867
|
+
}
|
|
3868
|
+
// Handle callCompletionModel method with usage counting
|
|
3869
|
+
if (prop === 'callCompletionModel' && target.callCompletionModel !== undefined) {
|
|
3870
|
+
return async (prompt) => {
|
|
3871
|
+
// console.info('[🚕] callCompletionModel through countTotalUsage');
|
|
3872
|
+
const promptResult = await target.callCompletionModel(prompt);
|
|
3873
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3874
|
+
spending.next(promptResult.usage);
|
|
3875
|
+
return promptResult;
|
|
3876
|
+
};
|
|
3877
|
+
}
|
|
3878
|
+
// Handle callEmbeddingModel method with usage counting
|
|
3879
|
+
if (prop === 'callEmbeddingModel' && target.callEmbeddingModel !== undefined) {
|
|
3880
|
+
return async (prompt) => {
|
|
3881
|
+
// console.info('[🚕] callEmbeddingModel through countTotalUsage');
|
|
3882
|
+
const promptResult = await target.callEmbeddingModel(prompt);
|
|
3883
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3884
|
+
spending.next(promptResult.usage);
|
|
3885
|
+
return promptResult;
|
|
3886
|
+
};
|
|
3887
|
+
}
|
|
3888
|
+
// Handle callImageGenerationModel method with usage counting
|
|
3889
|
+
if (prop === 'callImageGenerationModel' && target.callImageGenerationModel !== undefined) {
|
|
3890
|
+
return async (prompt) => {
|
|
3891
|
+
// console.info('[🚕] callImageGenerationModel through countTotalUsage');
|
|
3892
|
+
const promptResult = await target.callImageGenerationModel(prompt);
|
|
3893
|
+
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3894
|
+
spending.next(promptResult.usage);
|
|
3895
|
+
return promptResult;
|
|
3896
|
+
};
|
|
3897
|
+
}
|
|
3898
|
+
// <- Note: [🤖]
|
|
3899
|
+
// For all other properties and methods, delegate to the original target
|
|
3900
|
+
const value = Reflect.get(target, prop, receiver);
|
|
3901
|
+
// If it's a function, bind it to the target to preserve context
|
|
3902
|
+
if (typeof value === 'function') {
|
|
3903
|
+
return value.bind(target);
|
|
3904
|
+
}
|
|
3905
|
+
return value;
|
|
3852
3906
|
},
|
|
3853
|
-
};
|
|
3854
|
-
if (llmTools.callChatModel !== undefined) {
|
|
3855
|
-
proxyTools.callChatModel = async (prompt) => {
|
|
3856
|
-
// console.info('[🚕] callChatModel through countTotalUsage');
|
|
3857
|
-
const promptResult = await llmTools.callChatModel(prompt);
|
|
3858
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3859
|
-
spending.next(promptResult.usage);
|
|
3860
|
-
return promptResult;
|
|
3861
|
-
};
|
|
3862
|
-
}
|
|
3863
|
-
if (llmTools.callCompletionModel !== undefined) {
|
|
3864
|
-
proxyTools.callCompletionModel = async (prompt) => {
|
|
3865
|
-
// console.info('[🚕] callCompletionModel through countTotalUsage');
|
|
3866
|
-
const promptResult = await llmTools.callCompletionModel(prompt);
|
|
3867
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3868
|
-
spending.next(promptResult.usage);
|
|
3869
|
-
return promptResult;
|
|
3870
|
-
};
|
|
3871
|
-
}
|
|
3872
|
-
if (llmTools.callEmbeddingModel !== undefined) {
|
|
3873
|
-
proxyTools.callEmbeddingModel = async (prompt) => {
|
|
3874
|
-
// console.info('[🚕] callEmbeddingModel through countTotalUsage');
|
|
3875
|
-
const promptResult = await llmTools.callEmbeddingModel(prompt);
|
|
3876
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3877
|
-
spending.next(promptResult.usage);
|
|
3878
|
-
return promptResult;
|
|
3879
|
-
};
|
|
3880
|
-
}
|
|
3881
|
-
if (llmTools.callImageGenerationModel !== undefined) {
|
|
3882
|
-
proxyTools.callImageGenerationModel = async (prompt) => {
|
|
3883
|
-
// console.info('[🚕] callImageGenerationModel through countTotalUsage');
|
|
3884
|
-
const promptResult = await llmTools.callImageGenerationModel(prompt);
|
|
3885
|
-
totalUsage = addUsage(totalUsage, promptResult.usage);
|
|
3886
|
-
spending.next(promptResult.usage);
|
|
3887
|
-
return promptResult;
|
|
3888
|
-
};
|
|
3889
|
-
}
|
|
3890
|
-
// <- Note: [🤖]
|
|
3907
|
+
});
|
|
3891
3908
|
return proxyTools;
|
|
3892
3909
|
}
|
|
3893
3910
|
/**
|