@promptbook/core 0.104.0-15 → 0.104.0-16
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 +67 -37
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +1 -0
- package/esm/typings/src/scrapers/_common/utils/promptbookFetch.test.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +67 -37
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-16';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -12292,7 +12292,7 @@ function $randomBase58(length) {
|
|
|
12292
12292
|
* @public exported from `@promptbook/core`
|
|
12293
12293
|
* <- TODO: [🐱🚀] Move to `@promptbook/supabase` package
|
|
12294
12294
|
*/
|
|
12295
|
-
class AgentCollectionInSupabase /* TODO: [🐱🚀] implements
|
|
12295
|
+
class AgentCollectionInSupabase /* TODO: [🌈][🐱🚀] implements AgentCollection */ {
|
|
12296
12296
|
/**
|
|
12297
12297
|
* @param supabaseClient - The initialized Supabase client
|
|
12298
12298
|
* @param options - Configuration options for the collection (e.g., table prefix, verbosity)
|
|
@@ -17198,6 +17198,27 @@ function limitTotalUsage(llmTools, options = {}) {
|
|
|
17198
17198
|
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
17199
17199
|
*/
|
|
17200
17200
|
|
|
17201
|
+
/*! *****************************************************************************
|
|
17202
|
+
Copyright (c) Microsoft Corporation.
|
|
17203
|
+
|
|
17204
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
17205
|
+
purpose with or without fee is hereby granted.
|
|
17206
|
+
|
|
17207
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17208
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
17209
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17210
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17211
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17212
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17213
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
17214
|
+
***************************************************************************** */
|
|
17215
|
+
|
|
17216
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
17217
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
17218
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
17219
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
17220
|
+
}
|
|
17221
|
+
|
|
17201
17222
|
/**
|
|
17202
17223
|
* Restricts an Updatable to a (2) BehaviorSubject variant
|
|
17203
17224
|
*
|
|
@@ -19667,6 +19688,7 @@ AgentLlmExecutionTools.assistantCache = new Map();
|
|
|
19667
19688
|
* TODO: [🧠] Adding parameter substitution support (here or should be responsibility of the underlying LLM Tools)
|
|
19668
19689
|
*/
|
|
19669
19690
|
|
|
19691
|
+
var _Agent_instances, _Agent_selfLearn;
|
|
19670
19692
|
/**
|
|
19671
19693
|
* Represents one AI Agent
|
|
19672
19694
|
*
|
|
@@ -19707,6 +19729,7 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
19707
19729
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
19708
19730
|
agentSource: agentSource.value, // <- TODO: [🐱🚀] Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
|
|
19709
19731
|
});
|
|
19732
|
+
_Agent_instances.add(this);
|
|
19710
19733
|
this._agentName = undefined;
|
|
19711
19734
|
/**
|
|
19712
19735
|
* Description of the agent
|
|
@@ -19800,9 +19823,18 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
19800
19823
|
if ((_a = modelRequirements.metadata) === null || _a === void 0 ? void 0 : _a.isClosed) {
|
|
19801
19824
|
return result;
|
|
19802
19825
|
}
|
|
19803
|
-
|
|
19804
|
-
//
|
|
19805
|
-
|
|
19826
|
+
await __classPrivateFieldGet(this, _Agent_instances, "m", _Agent_selfLearn).call(this, prompt, result);
|
|
19827
|
+
// <- TODO: !!!! Do not await self-learn, run in background with error handling
|
|
19828
|
+
return result;
|
|
19829
|
+
}
|
|
19830
|
+
}
|
|
19831
|
+
_Agent_instances = new WeakSet(), _Agent_selfLearn =
|
|
19832
|
+
/**
|
|
19833
|
+
* Self-learning: Appends the conversation and extracted knowledge to the agent source
|
|
19834
|
+
*/
|
|
19835
|
+
async function _Agent_selfLearn(prompt, result) {
|
|
19836
|
+
// Learning: Append the conversation sample to the agent source
|
|
19837
|
+
const learningExample = spaceTrim$2((block) => `
|
|
19806
19838
|
|
|
19807
19839
|
---
|
|
19808
19840
|
|
|
@@ -19813,15 +19845,15 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
19813
19845
|
${block(result.content)}
|
|
19814
19846
|
|
|
19815
19847
|
`);
|
|
19816
|
-
|
|
19817
|
-
|
|
19818
|
-
|
|
19819
|
-
|
|
19820
|
-
|
|
19821
|
-
|
|
19822
|
-
|
|
19823
|
-
|
|
19824
|
-
|
|
19848
|
+
// Extract knowledge
|
|
19849
|
+
let knowledgeBlock = '';
|
|
19850
|
+
try {
|
|
19851
|
+
const extractionPrompt = {
|
|
19852
|
+
title: 'Knowledge Extraction',
|
|
19853
|
+
modelRequirements: {
|
|
19854
|
+
modelVariant: 'CHAT',
|
|
19855
|
+
},
|
|
19856
|
+
content: spaceTrim$2((block) => `
|
|
19825
19857
|
You are an AI agent that is learning from a conversation.
|
|
19826
19858
|
|
|
19827
19859
|
Here is the conversation so far:
|
|
@@ -19837,33 +19869,31 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
19837
19869
|
KNOWLEDGE The user's name is Alice.
|
|
19838
19870
|
KNOWLEDGE The project deadline is next Friday.
|
|
19839
19871
|
`),
|
|
19840
|
-
|
|
19841
|
-
|
|
19842
|
-
|
|
19843
|
-
|
|
19844
|
-
|
|
19845
|
-
|
|
19846
|
-
|
|
19847
|
-
|
|
19848
|
-
}
|
|
19849
|
-
}
|
|
19850
|
-
else {
|
|
19851
|
-
// TODO: [🧠] Fallback to callChatModelStream if callChatModel is not available
|
|
19872
|
+
pipelineUrl: 'https://github.com/webgptorg/promptbook/blob/main/prompts/knowledge-extraction.ptbk.md',
|
|
19873
|
+
parameters: {},
|
|
19874
|
+
};
|
|
19875
|
+
if (this.options.llmTools.callChatModel) {
|
|
19876
|
+
const extractionResult = await this.options.llmTools.callChatModel(extractionPrompt);
|
|
19877
|
+
const extractedContent = extractionResult.content;
|
|
19878
|
+
if (extractedContent.includes('KNOWLEDGE')) {
|
|
19879
|
+
knowledgeBlock = '\n\n' + spaceTrim$2(extractedContent);
|
|
19852
19880
|
}
|
|
19853
19881
|
}
|
|
19854
|
-
|
|
19855
|
-
if
|
|
19856
|
-
console.warn('Failed to extract knowledge', error);
|
|
19857
|
-
}
|
|
19882
|
+
else {
|
|
19883
|
+
// TODO: [🧠] Fallback to callChatModelStream if callChatModel is not available
|
|
19858
19884
|
}
|
|
19859
|
-
// Append to the current source
|
|
19860
|
-
const currentSource = this.agentSource.value;
|
|
19861
|
-
const newSource = padBook(validateBook(spaceTrim$2(currentSource) + '\n\n' + learningExample + knowledgeBlock));
|
|
19862
|
-
// Update the source (which will trigger the subscription and update the underlying tools)
|
|
19863
|
-
this.agentSource.next(newSource);
|
|
19864
|
-
return result;
|
|
19865
19885
|
}
|
|
19866
|
-
|
|
19886
|
+
catch (error) {
|
|
19887
|
+
if (this.options.isVerbose) {
|
|
19888
|
+
console.warn('Failed to extract knowledge', error);
|
|
19889
|
+
}
|
|
19890
|
+
}
|
|
19891
|
+
// Append to the current source
|
|
19892
|
+
const currentSource = this.agentSource.value;
|
|
19893
|
+
const newSource = padBook(validateBook(spaceTrim$2(currentSource) + '\n\n' + learningExample + knowledgeBlock));
|
|
19894
|
+
// Update the source (which will trigger the subscription and update the underlying tools)
|
|
19895
|
+
this.agentSource.next(newSource);
|
|
19896
|
+
};
|
|
19867
19897
|
/**
|
|
19868
19898
|
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
19869
19899
|
*/
|