@promptbook/components 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 +66 -36
- 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 +66 -36
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -35,7 +35,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
35
35
|
* @generated
|
|
36
36
|
* @see https://github.com/webgptorg/promptbook
|
|
37
37
|
*/
|
|
38
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
38
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-16';
|
|
39
39
|
/**
|
|
40
40
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
41
41
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -11268,6 +11268,27 @@ function book(strings, ...values) {
|
|
|
11268
11268
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
11269
11269
|
*/
|
|
11270
11270
|
|
|
11271
|
+
/*! *****************************************************************************
|
|
11272
|
+
Copyright (c) Microsoft Corporation.
|
|
11273
|
+
|
|
11274
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11275
|
+
purpose with or without fee is hereby granted.
|
|
11276
|
+
|
|
11277
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
11278
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11279
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11280
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11281
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
11282
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
11283
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
11284
|
+
***************************************************************************** */
|
|
11285
|
+
|
|
11286
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
11287
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
11288
|
+
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");
|
|
11289
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11290
|
+
}
|
|
11291
|
+
|
|
11271
11292
|
/**
|
|
11272
11293
|
* Takes an item or an array of items and returns an array of items
|
|
11273
11294
|
*
|
|
@@ -17884,6 +17905,7 @@ AgentLlmExecutionTools.assistantCache = new Map();
|
|
|
17884
17905
|
* TODO: [🧠] Adding parameter substitution support (here or should be responsibility of the underlying LLM Tools)
|
|
17885
17906
|
*/
|
|
17886
17907
|
|
|
17908
|
+
var _Agent_instances, _Agent_selfLearn;
|
|
17887
17909
|
/**
|
|
17888
17910
|
* Represents one AI Agent
|
|
17889
17911
|
*
|
|
@@ -17924,6 +17946,7 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
17924
17946
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
17925
17947
|
agentSource: agentSource.value, // <- TODO: [🐱🚀] Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
|
|
17926
17948
|
});
|
|
17949
|
+
_Agent_instances.add(this);
|
|
17927
17950
|
this._agentName = undefined;
|
|
17928
17951
|
/**
|
|
17929
17952
|
* Description of the agent
|
|
@@ -18017,9 +18040,18 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
18017
18040
|
if ((_a = modelRequirements.metadata) === null || _a === void 0 ? void 0 : _a.isClosed) {
|
|
18018
18041
|
return result;
|
|
18019
18042
|
}
|
|
18020
|
-
|
|
18021
|
-
//
|
|
18022
|
-
|
|
18043
|
+
await __classPrivateFieldGet(this, _Agent_instances, "m", _Agent_selfLearn).call(this, prompt, result);
|
|
18044
|
+
// <- TODO: !!!! Do not await self-learn, run in background with error handling
|
|
18045
|
+
return result;
|
|
18046
|
+
}
|
|
18047
|
+
}
|
|
18048
|
+
_Agent_instances = new WeakSet(), _Agent_selfLearn =
|
|
18049
|
+
/**
|
|
18050
|
+
* Self-learning: Appends the conversation and extracted knowledge to the agent source
|
|
18051
|
+
*/
|
|
18052
|
+
async function _Agent_selfLearn(prompt, result) {
|
|
18053
|
+
// Learning: Append the conversation sample to the agent source
|
|
18054
|
+
const learningExample = spaceTrim$2((block) => `
|
|
18023
18055
|
|
|
18024
18056
|
---
|
|
18025
18057
|
|
|
@@ -18030,15 +18062,15 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
18030
18062
|
${block(result.content)}
|
|
18031
18063
|
|
|
18032
18064
|
`);
|
|
18033
|
-
|
|
18034
|
-
|
|
18035
|
-
|
|
18036
|
-
|
|
18037
|
-
|
|
18038
|
-
|
|
18039
|
-
|
|
18040
|
-
|
|
18041
|
-
|
|
18065
|
+
// Extract knowledge
|
|
18066
|
+
let knowledgeBlock = '';
|
|
18067
|
+
try {
|
|
18068
|
+
const extractionPrompt = {
|
|
18069
|
+
title: 'Knowledge Extraction',
|
|
18070
|
+
modelRequirements: {
|
|
18071
|
+
modelVariant: 'CHAT',
|
|
18072
|
+
},
|
|
18073
|
+
content: spaceTrim$2((block) => `
|
|
18042
18074
|
You are an AI agent that is learning from a conversation.
|
|
18043
18075
|
|
|
18044
18076
|
Here is the conversation so far:
|
|
@@ -18054,33 +18086,31 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
18054
18086
|
KNOWLEDGE The user's name is Alice.
|
|
18055
18087
|
KNOWLEDGE The project deadline is next Friday.
|
|
18056
18088
|
`),
|
|
18057
|
-
|
|
18058
|
-
|
|
18059
|
-
|
|
18060
|
-
|
|
18061
|
-
|
|
18062
|
-
|
|
18063
|
-
|
|
18064
|
-
|
|
18065
|
-
}
|
|
18066
|
-
}
|
|
18067
|
-
else {
|
|
18068
|
-
// TODO: [🧠] Fallback to callChatModelStream if callChatModel is not available
|
|
18089
|
+
pipelineUrl: 'https://github.com/webgptorg/promptbook/blob/main/prompts/knowledge-extraction.ptbk.md',
|
|
18090
|
+
parameters: {},
|
|
18091
|
+
};
|
|
18092
|
+
if (this.options.llmTools.callChatModel) {
|
|
18093
|
+
const extractionResult = await this.options.llmTools.callChatModel(extractionPrompt);
|
|
18094
|
+
const extractedContent = extractionResult.content;
|
|
18095
|
+
if (extractedContent.includes('KNOWLEDGE')) {
|
|
18096
|
+
knowledgeBlock = '\n\n' + spaceTrim$2(extractedContent);
|
|
18069
18097
|
}
|
|
18070
18098
|
}
|
|
18071
|
-
|
|
18072
|
-
if
|
|
18073
|
-
console.warn('Failed to extract knowledge', error);
|
|
18074
|
-
}
|
|
18099
|
+
else {
|
|
18100
|
+
// TODO: [🧠] Fallback to callChatModelStream if callChatModel is not available
|
|
18075
18101
|
}
|
|
18076
|
-
// Append to the current source
|
|
18077
|
-
const currentSource = this.agentSource.value;
|
|
18078
|
-
const newSource = padBook(validateBook(spaceTrim$2(currentSource) + '\n\n' + learningExample + knowledgeBlock));
|
|
18079
|
-
// Update the source (which will trigger the subscription and update the underlying tools)
|
|
18080
|
-
this.agentSource.next(newSource);
|
|
18081
|
-
return result;
|
|
18082
18102
|
}
|
|
18083
|
-
|
|
18103
|
+
catch (error) {
|
|
18104
|
+
if (this.options.isVerbose) {
|
|
18105
|
+
console.warn('Failed to extract knowledge', error);
|
|
18106
|
+
}
|
|
18107
|
+
}
|
|
18108
|
+
// Append to the current source
|
|
18109
|
+
const currentSource = this.agentSource.value;
|
|
18110
|
+
const newSource = padBook(validateBook(spaceTrim$2(currentSource) + '\n\n' + learningExample + knowledgeBlock));
|
|
18111
|
+
// Update the source (which will trigger the subscription and update the underlying tools)
|
|
18112
|
+
this.agentSource.next(newSource);
|
|
18113
|
+
};
|
|
18084
18114
|
/**
|
|
18085
18115
|
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
18086
18116
|
*/
|