@promptbook/remote-server 0.112.0-30 → 0.112.0-31
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 +35 -2
- package/esm/index.es.js.map +1 -1
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +35 -2
- package/umd/index.umd.js.map +1 -1
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
40
40
|
* @generated
|
|
41
41
|
* @see https://github.com/webgptorg/promptbook
|
|
42
42
|
*/
|
|
43
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
43
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-31';
|
|
44
44
|
/**
|
|
45
45
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
46
46
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -31219,6 +31219,7 @@ class SelfLearningManager {
|
|
|
31219
31219
|
|
|
31220
31220
|
- Decide what the agent should learn from this interaction.
|
|
31221
31221
|
- Append new commitments at the end of the agent source.
|
|
31222
|
+
- Return only newly learned commitments, never repeat commitments that are already present.
|
|
31222
31223
|
- Do not modify the current agent source, just return new commitments (KNOWLEDGE, RULE, etc.).
|
|
31223
31224
|
- If there is nothing new to learn, return empty book code block
|
|
31224
31225
|
- Wrap the commitments in a book code block.
|
|
@@ -31271,10 +31272,42 @@ class SelfLearningManager {
|
|
|
31271
31272
|
*/
|
|
31272
31273
|
appendToAgentSource(section) {
|
|
31273
31274
|
const currentSource = this.options.getAgentSource();
|
|
31274
|
-
const
|
|
31275
|
+
const normalizedSection = normalizeBookSection(section);
|
|
31276
|
+
if (!normalizedSection) {
|
|
31277
|
+
return;
|
|
31278
|
+
}
|
|
31279
|
+
if (containsNormalizedBookSection(currentSource, normalizedSection)) {
|
|
31280
|
+
return;
|
|
31281
|
+
}
|
|
31282
|
+
const newSource = padBook(validateBook(`${normalizeBookSection(currentSource)}\n\n${normalizedSection}`));
|
|
31275
31283
|
this.options.updateAgentSource(newSource);
|
|
31276
31284
|
}
|
|
31277
31285
|
}
|
|
31286
|
+
/**
|
|
31287
|
+
* Normalizes one book fragment for deduplication and append composition.
|
|
31288
|
+
*
|
|
31289
|
+
* @param section Raw fragment from self-learning workflow.
|
|
31290
|
+
* @returns Trimmed fragment, or empty string when nothing remains.
|
|
31291
|
+
* @private function of Agent
|
|
31292
|
+
*/
|
|
31293
|
+
function normalizeBookSection(section) {
|
|
31294
|
+
return spaceTrim$1(section).replace(/\r\n/g, '\n');
|
|
31295
|
+
}
|
|
31296
|
+
/**
|
|
31297
|
+
* Checks whether one normalized fragment already exists inside the current source.
|
|
31298
|
+
*
|
|
31299
|
+
* @param agentSource Current source.
|
|
31300
|
+
* @param normalizedSection Candidate fragment expected to be normalized first.
|
|
31301
|
+
* @returns True when appending would duplicate an existing fragment.
|
|
31302
|
+
* @private function of Agent
|
|
31303
|
+
*/
|
|
31304
|
+
function containsNormalizedBookSection(agentSource, normalizedSection) {
|
|
31305
|
+
if (!normalizedSection) {
|
|
31306
|
+
return true;
|
|
31307
|
+
}
|
|
31308
|
+
const normalizedSource = normalizeBookSection(agentSource);
|
|
31309
|
+
return normalizedSource.includes(normalizedSection);
|
|
31310
|
+
}
|
|
31278
31311
|
/**
|
|
31279
31312
|
* Determines whether the interaction runs in OpenAI-compatible JSON schema mode.
|
|
31280
31313
|
*
|