@promptbook/components 0.103.0-54 โ 0.103.0-56
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 +1306 -281
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +35 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +6 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/commitments/index.d.ts +12 -1
- package/esm/typings/src/playground/playground.d.ts +3 -0
- package/esm/typings/src/utils/color/Color.d.ts +8 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +1152 -127
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/playground/playground1.d.ts +0 -2
package/umd/index.umd.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('crypto'), require('react-dom'), require('@monaco-editor/react'), require('destroyable'), require('highlight.js'), require('katex'), require('showdown'), require('rxjs'), require('waitasecond'), require('crypto-js/sha256'), require('mime-types'), require('papaparse'), require('colors'), require('bottleneck'), require('openai'), require('qrcode')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'path', 'crypto', 'react-dom', '@monaco-editor/react', 'destroyable', 'highlight.js', 'katex', 'showdown', 'rxjs', 'waitasecond', 'crypto-js/sha256', 'mime-types', 'papaparse', 'colors', 'bottleneck', 'openai', 'qrcode'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.react, global.spaceTrim, global.cryptoJs, global.hexEncoder, global.path, global.crypto, global.reactDom, global.Editor, global.destroyable, global.hljs, global.katex, global.showdown, global.rxjs, global.waitasecond, global.sha256, global.mimeTypes, global.papaparse, global.colors, global.Bottleneck, global.OpenAI, global.QRCode));
|
|
5
|
-
})(this, (function (exports, jsxRuntime, react, spaceTrim, cryptoJs, hexEncoder, path, crypto, reactDom, Editor, destroyable, hljs, katex, showdown, rxjs, waitasecond, sha256, mimeTypes, papaparse, colors, Bottleneck, OpenAI, QRCode) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.react, global.spaceTrim$1, global.cryptoJs, global.hexEncoder, global.path, global.crypto, global.reactDom, global.Editor, global.destroyable, global.hljs, global.katex, global.showdown, global.rxjs, global.waitasecond, global.sha256, global.mimeTypes, global.papaparse, global.colors, global.Bottleneck, global.OpenAI, global.QRCode));
|
|
5
|
+
})(this, (function (exports, jsxRuntime, react, spaceTrim$1, cryptoJs, hexEncoder, path, crypto, reactDom, Editor, destroyable, hljs, katex, showdown, rxjs, waitasecond, sha256, mimeTypes, papaparse, colors, Bottleneck, OpenAI, QRCode) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
9
|
+
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
|
|
10
10
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
11
11
|
var Editor__default = /*#__PURE__*/_interopDefaultLegacy(Editor);
|
|
12
12
|
var hljs__default = /*#__PURE__*/_interopDefaultLegacy(hljs);
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* @generated
|
|
32
32
|
* @see https://github.com/webgptorg/promptbook
|
|
33
33
|
*/
|
|
34
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
34
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
|
|
35
35
|
/**
|
|
36
36
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
37
37
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -243,6 +243,17 @@
|
|
|
243
243
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
244
244
|
*/
|
|
245
245
|
|
|
246
|
+
/**
|
|
247
|
+
* Trims string from all 4 sides
|
|
248
|
+
*
|
|
249
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
250
|
+
* Developed by same author @hejny as this package
|
|
251
|
+
*
|
|
252
|
+
* @public exported from `@promptbook/utils`
|
|
253
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
254
|
+
*/
|
|
255
|
+
const spaceTrim = spaceTrim$1.spaceTrim;
|
|
256
|
+
|
|
246
257
|
/**
|
|
247
258
|
* @private util of `@promptbook/color`
|
|
248
259
|
* @de
|
|
@@ -291,6 +302,7 @@
|
|
|
291
302
|
* @public exported from `@promptbook/color`
|
|
292
303
|
*/
|
|
293
304
|
const CSS_COLORS = {
|
|
305
|
+
promptbook: '#79EAFD',
|
|
294
306
|
transparent: 'rgba(0,0,0,0)',
|
|
295
307
|
aliceblue: '#f0f8ff',
|
|
296
308
|
antiquewhite: '#faebd7',
|
|
@@ -506,6 +518,28 @@
|
|
|
506
518
|
throw new Error(`Can not create color from given object`);
|
|
507
519
|
}
|
|
508
520
|
}
|
|
521
|
+
/**
|
|
522
|
+
* Creates a new Color instance from miscellaneous formats
|
|
523
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
524
|
+
*
|
|
525
|
+
* @param color
|
|
526
|
+
* @returns Color object
|
|
527
|
+
*/
|
|
528
|
+
static fromSafe(color) {
|
|
529
|
+
try {
|
|
530
|
+
return Color.from(color);
|
|
531
|
+
}
|
|
532
|
+
catch (error) {
|
|
533
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
534
|
+
console.warn(spaceTrim((block) => `
|
|
535
|
+
Color.fromSafe error:
|
|
536
|
+
${block(error.message)}
|
|
537
|
+
|
|
538
|
+
Returning default PROMPTBOOK_COLOR.
|
|
539
|
+
`));
|
|
540
|
+
return Color.fromString('promptbook');
|
|
541
|
+
}
|
|
542
|
+
}
|
|
509
543
|
/**
|
|
510
544
|
* Creates a new Color instance from miscellaneous string formats
|
|
511
545
|
*
|
|
@@ -1123,7 +1157,7 @@
|
|
|
1123
1157
|
*
|
|
1124
1158
|
* @public exported from `@promptbook/core`
|
|
1125
1159
|
*/
|
|
1126
|
-
const PROMPTBOOK_COLOR = Color.
|
|
1160
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
1127
1161
|
// <- TODO: [๐ง ][๐ต] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1128
1162
|
/**
|
|
1129
1163
|
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
@@ -1398,7 +1432,7 @@
|
|
|
1398
1432
|
*/
|
|
1399
1433
|
class UnexpectedError extends Error {
|
|
1400
1434
|
constructor(message) {
|
|
1401
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
1435
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
1402
1436
|
${block(message)}
|
|
1403
1437
|
|
|
1404
1438
|
Note: This error should not happen.
|
|
@@ -1424,7 +1458,7 @@
|
|
|
1424
1458
|
constructor(whatWasThrown) {
|
|
1425
1459
|
const tag = `[๐คฎ]`;
|
|
1426
1460
|
console.error(tag, whatWasThrown);
|
|
1427
|
-
super(spaceTrim.spaceTrim(`
|
|
1461
|
+
super(spaceTrim$1.spaceTrim(`
|
|
1428
1462
|
Non-Error object was thrown
|
|
1429
1463
|
|
|
1430
1464
|
Note: Look for ${tag} in the console for more details
|
|
@@ -2455,7 +2489,7 @@
|
|
|
2455
2489
|
*/
|
|
2456
2490
|
class MissingToolsError extends Error {
|
|
2457
2491
|
constructor(message) {
|
|
2458
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
2492
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
2459
2493
|
${block(message)}
|
|
2460
2494
|
|
|
2461
2495
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -2499,7 +2533,7 @@
|
|
|
2499
2533
|
*/
|
|
2500
2534
|
class NotYetImplementedError extends Error {
|
|
2501
2535
|
constructor(message) {
|
|
2502
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
2536
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
2503
2537
|
${block(message)}
|
|
2504
2538
|
|
|
2505
2539
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -3310,7 +3344,7 @@
|
|
|
3310
3344
|
* @public exported from `@promptbook/utils`
|
|
3311
3345
|
*/
|
|
3312
3346
|
function normalizeMessageText(text) {
|
|
3313
|
-
return spaceTrim.spaceTrim(text);
|
|
3347
|
+
return spaceTrim$1.spaceTrim(text);
|
|
3314
3348
|
}
|
|
3315
3349
|
|
|
3316
3350
|
/**
|
|
@@ -3587,6 +3621,16 @@
|
|
|
3587
3621
|
return titleToName(spaceTrim__default["default"](rawAgentName));
|
|
3588
3622
|
}
|
|
3589
3623
|
|
|
3624
|
+
/**
|
|
3625
|
+
* Creates temporary default agent name based on agent source hash
|
|
3626
|
+
*
|
|
3627
|
+
* @public exported from `@promptbook/core`
|
|
3628
|
+
*/
|
|
3629
|
+
function createDefaultAgentName(agentSource) {
|
|
3630
|
+
const agentHash = computeAgentHash(agentSource);
|
|
3631
|
+
return normalizeAgentName(`Agent ${agentHash.substring(0, 6)}`);
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3590
3634
|
/**
|
|
3591
3635
|
* Generates a regex pattern to match a specific commitment
|
|
3592
3636
|
*
|
|
@@ -3728,7 +3772,7 @@
|
|
|
3728
3772
|
* Markdown documentation for ACTION commitment.
|
|
3729
3773
|
*/
|
|
3730
3774
|
get documentation() {
|
|
3731
|
-
return spaceTrim.spaceTrim(`
|
|
3775
|
+
return spaceTrim$1.spaceTrim(`
|
|
3732
3776
|
# ${this.type}
|
|
3733
3777
|
|
|
3734
3778
|
Defines specific actions or capabilities that the agent can perform.
|
|
@@ -3775,6 +3819,150 @@
|
|
|
3775
3819
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
3776
3820
|
*/
|
|
3777
3821
|
|
|
3822
|
+
/**
|
|
3823
|
+
* Just says that the variable is not used but should be kept
|
|
3824
|
+
* No side effects.
|
|
3825
|
+
*
|
|
3826
|
+
* Note: It can be useful for:
|
|
3827
|
+
*
|
|
3828
|
+
* 1) Suppressing eager optimization of unused imports
|
|
3829
|
+
* 2) Suppressing eslint errors of unused variables in the tests
|
|
3830
|
+
* 3) Keeping the type of the variable for type testing
|
|
3831
|
+
*
|
|
3832
|
+
* @param value any values
|
|
3833
|
+
* @returns void
|
|
3834
|
+
* @private within the repository
|
|
3835
|
+
*/
|
|
3836
|
+
function keepUnused(...valuesToKeep) {
|
|
3837
|
+
}
|
|
3838
|
+
|
|
3839
|
+
/**
|
|
3840
|
+
* CLOSED commitment definition
|
|
3841
|
+
*
|
|
3842
|
+
* The CLOSED commitment specifies that the agent CANNOT be modified by conversation.
|
|
3843
|
+
* It prevents the agent from learning from interactions and updating its source code.
|
|
3844
|
+
*
|
|
3845
|
+
* Example usage in agent source:
|
|
3846
|
+
*
|
|
3847
|
+
* ```book
|
|
3848
|
+
* CLOSED
|
|
3849
|
+
* ```
|
|
3850
|
+
*
|
|
3851
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
3852
|
+
*/
|
|
3853
|
+
class ClosedCommitmentDefinition extends BaseCommitmentDefinition {
|
|
3854
|
+
constructor() {
|
|
3855
|
+
super('CLOSED');
|
|
3856
|
+
}
|
|
3857
|
+
/**
|
|
3858
|
+
* Short one-line description of CLOSED.
|
|
3859
|
+
*/
|
|
3860
|
+
get description() {
|
|
3861
|
+
return 'Prevent the agent from being modified by conversation.';
|
|
3862
|
+
}
|
|
3863
|
+
/**
|
|
3864
|
+
* Icon for this commitment.
|
|
3865
|
+
*/
|
|
3866
|
+
get icon() {
|
|
3867
|
+
return '๐';
|
|
3868
|
+
}
|
|
3869
|
+
/**
|
|
3870
|
+
* Markdown documentation for CLOSED commitment.
|
|
3871
|
+
*/
|
|
3872
|
+
get documentation() {
|
|
3873
|
+
return spaceTrim$1.spaceTrim(`
|
|
3874
|
+
# CLOSED
|
|
3875
|
+
|
|
3876
|
+
Specifies that the agent **cannot** be modified by conversation with it.
|
|
3877
|
+
This means the agent will **not** learn from interactions and its source code will remain static during conversation.
|
|
3878
|
+
|
|
3879
|
+
By default (if not specified), agents are \`OPEN\` to modification.
|
|
3880
|
+
|
|
3881
|
+
> See also [OPEN](/docs/OPEN)
|
|
3882
|
+
|
|
3883
|
+
## Example
|
|
3884
|
+
|
|
3885
|
+
\`\`\`book
|
|
3886
|
+
CLOSED
|
|
3887
|
+
\`\`\`
|
|
3888
|
+
`);
|
|
3889
|
+
}
|
|
3890
|
+
applyToAgentModelRequirements(requirements, _content) {
|
|
3891
|
+
const updatedMetadata = {
|
|
3892
|
+
...requirements.metadata,
|
|
3893
|
+
isClosed: true,
|
|
3894
|
+
};
|
|
3895
|
+
return {
|
|
3896
|
+
...requirements,
|
|
3897
|
+
metadata: updatedMetadata,
|
|
3898
|
+
};
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
/**
|
|
3902
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
3903
|
+
*/
|
|
3904
|
+
|
|
3905
|
+
/**
|
|
3906
|
+
* COMPONENT commitment definition
|
|
3907
|
+
*
|
|
3908
|
+
* The COMPONENT commitment defines a UI component that the agent can render in the chat.
|
|
3909
|
+
*
|
|
3910
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
3911
|
+
*/
|
|
3912
|
+
class ComponentCommitmentDefinition extends BaseCommitmentDefinition {
|
|
3913
|
+
constructor() {
|
|
3914
|
+
super('COMPONENT');
|
|
3915
|
+
}
|
|
3916
|
+
/**
|
|
3917
|
+
* Short one-line description of COMPONENT.
|
|
3918
|
+
*/
|
|
3919
|
+
get description() {
|
|
3920
|
+
return 'Define a UI component that the agent can render in the chat.';
|
|
3921
|
+
}
|
|
3922
|
+
/**
|
|
3923
|
+
* Icon for this commitment.
|
|
3924
|
+
*/
|
|
3925
|
+
get icon() {
|
|
3926
|
+
return '๐งฉ';
|
|
3927
|
+
}
|
|
3928
|
+
/**
|
|
3929
|
+
* Markdown documentation for COMPONENT commitment.
|
|
3930
|
+
*/
|
|
3931
|
+
get documentation() {
|
|
3932
|
+
return spaceTrim$1.spaceTrim(`
|
|
3933
|
+
# COMPONENT
|
|
3934
|
+
|
|
3935
|
+
Defines a UI component that the agent can render in the chat.
|
|
3936
|
+
|
|
3937
|
+
## Key aspects
|
|
3938
|
+
|
|
3939
|
+
- Tells the agent that a specific component is available.
|
|
3940
|
+
- Provides syntax for using the component.
|
|
3941
|
+
|
|
3942
|
+
## Example
|
|
3943
|
+
|
|
3944
|
+
\`\`\`book
|
|
3945
|
+
COMPONENT Arrow
|
|
3946
|
+
The agent should render an arrow component in the chat UI.
|
|
3947
|
+
Syntax:
|
|
3948
|
+
<Arrow direction="up" color="red" />
|
|
3949
|
+
\`\`\`
|
|
3950
|
+
`);
|
|
3951
|
+
}
|
|
3952
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
3953
|
+
const trimmedContent = content.trim();
|
|
3954
|
+
if (!trimmedContent) {
|
|
3955
|
+
return requirements;
|
|
3956
|
+
}
|
|
3957
|
+
// Add component capability to the system message
|
|
3958
|
+
const componentSection = `Component: ${trimmedContent}`;
|
|
3959
|
+
return this.appendToSystemMessage(requirements, componentSection, '\n\n');
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
/**
|
|
3963
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
3964
|
+
*/
|
|
3965
|
+
|
|
3778
3966
|
/**
|
|
3779
3967
|
* DELETE commitment definition
|
|
3780
3968
|
*
|
|
@@ -3813,7 +4001,7 @@
|
|
|
3813
4001
|
* Markdown documentation for DELETE commitment.
|
|
3814
4002
|
*/
|
|
3815
4003
|
get documentation() {
|
|
3816
|
-
return spaceTrim.spaceTrim(`
|
|
4004
|
+
return spaceTrim$1.spaceTrim(`
|
|
3817
4005
|
# DELETE (CANCEL, DISCARD, REMOVE)
|
|
3818
4006
|
|
|
3819
4007
|
A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
|
|
@@ -3935,7 +4123,7 @@
|
|
|
3935
4123
|
* Markdown documentation for FORMAT commitment.
|
|
3936
4124
|
*/
|
|
3937
4125
|
get documentation() {
|
|
3938
|
-
return spaceTrim.spaceTrim(`
|
|
4126
|
+
return spaceTrim$1.spaceTrim(`
|
|
3939
4127
|
# ${this.type}
|
|
3940
4128
|
|
|
3941
4129
|
Defines the specific output structure and formatting for responses (data formats, templates, structure).
|
|
@@ -3980,6 +4168,79 @@
|
|
|
3980
4168
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
3981
4169
|
*/
|
|
3982
4170
|
|
|
4171
|
+
/**
|
|
4172
|
+
* FROM commitment definition
|
|
4173
|
+
*
|
|
4174
|
+
* The FROM commitment tells the agent that its `agentSource` is inherited from another agent.
|
|
4175
|
+
*
|
|
4176
|
+
* Example usage in agent source:
|
|
4177
|
+
*
|
|
4178
|
+
* ```book
|
|
4179
|
+
* FROM https://s6.ptbk.io/benjamin-white
|
|
4180
|
+
* ```
|
|
4181
|
+
*
|
|
4182
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
4183
|
+
*/
|
|
4184
|
+
class FromCommitmentDefinition extends BaseCommitmentDefinition {
|
|
4185
|
+
constructor(type = 'FROM') {
|
|
4186
|
+
super(type);
|
|
4187
|
+
}
|
|
4188
|
+
/**
|
|
4189
|
+
* Short one-line description of FROM.
|
|
4190
|
+
*/
|
|
4191
|
+
get description() {
|
|
4192
|
+
return 'Inherit agent source from another agent.';
|
|
4193
|
+
}
|
|
4194
|
+
/**
|
|
4195
|
+
* Icon for this commitment.
|
|
4196
|
+
*/
|
|
4197
|
+
get icon() {
|
|
4198
|
+
return '๐งฌ';
|
|
4199
|
+
}
|
|
4200
|
+
/**
|
|
4201
|
+
* Markdown documentation for FROM commitment.
|
|
4202
|
+
*/
|
|
4203
|
+
get documentation() {
|
|
4204
|
+
return spaceTrim$1.spaceTrim(`
|
|
4205
|
+
# ${this.type}
|
|
4206
|
+
|
|
4207
|
+
Inherits agent source from another agent.
|
|
4208
|
+
|
|
4209
|
+
## Examples
|
|
4210
|
+
|
|
4211
|
+
\`\`\`book
|
|
4212
|
+
My AI Agent
|
|
4213
|
+
|
|
4214
|
+
FROM https://s6.ptbk.io/benjamin-white
|
|
4215
|
+
RULE Speak only in English.
|
|
4216
|
+
\`\`\`
|
|
4217
|
+
`);
|
|
4218
|
+
}
|
|
4219
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
4220
|
+
const trimmedContent = content.trim();
|
|
4221
|
+
if (!trimmedContent) {
|
|
4222
|
+
return requirements;
|
|
4223
|
+
}
|
|
4224
|
+
// Validate URL
|
|
4225
|
+
try {
|
|
4226
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4227
|
+
const url = new URL(trimmedContent);
|
|
4228
|
+
// TODO: Add more validation if needed (e.g. check for valid protocol)
|
|
4229
|
+
}
|
|
4230
|
+
catch (error) {
|
|
4231
|
+
console.warn(`Invalid URL in FROM commitment: ${trimmedContent}`);
|
|
4232
|
+
return requirements;
|
|
4233
|
+
}
|
|
4234
|
+
return {
|
|
4235
|
+
...requirements,
|
|
4236
|
+
parentAgentUrl: trimmedContent,
|
|
4237
|
+
};
|
|
4238
|
+
}
|
|
4239
|
+
}
|
|
4240
|
+
/**
|
|
4241
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
4242
|
+
*/
|
|
4243
|
+
|
|
3983
4244
|
/**
|
|
3984
4245
|
* GOAL commitment definition
|
|
3985
4246
|
*
|
|
@@ -4016,7 +4277,7 @@
|
|
|
4016
4277
|
* Markdown documentation for GOAL commitment.
|
|
4017
4278
|
*/
|
|
4018
4279
|
get documentation() {
|
|
4019
|
-
return spaceTrim.spaceTrim(`
|
|
4280
|
+
return spaceTrim$1.spaceTrim(`
|
|
4020
4281
|
# ${this.type}
|
|
4021
4282
|
|
|
4022
4283
|
Defines the main goal which should be achieved by the AI assistant. There can be multiple goals, and later goals are more important than earlier goals.
|
|
@@ -4118,7 +4379,7 @@
|
|
|
4118
4379
|
* Markdown documentation for KNOWLEDGE commitment.
|
|
4119
4380
|
*/
|
|
4120
4381
|
get documentation() {
|
|
4121
|
-
return spaceTrim.spaceTrim(`
|
|
4382
|
+
return spaceTrim$1.spaceTrim(`
|
|
4122
4383
|
# ${this.type}
|
|
4123
4384
|
|
|
4124
4385
|
Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
|
|
@@ -4188,6 +4449,77 @@
|
|
|
4188
4449
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
4189
4450
|
*/
|
|
4190
4451
|
|
|
4452
|
+
/**
|
|
4453
|
+
* LANGUAGE commitment definition
|
|
4454
|
+
*
|
|
4455
|
+
* The LANGUAGE/LANGUAGES commitment specifies the language(s) the agent should use in its responses.
|
|
4456
|
+
*
|
|
4457
|
+
* Example usage in agent source:
|
|
4458
|
+
*
|
|
4459
|
+
* ```book
|
|
4460
|
+
* LANGUAGE English
|
|
4461
|
+
* LANGUAGE French, English and Czech
|
|
4462
|
+
* ```
|
|
4463
|
+
*
|
|
4464
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
4465
|
+
*/
|
|
4466
|
+
class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
4467
|
+
constructor(type = 'LANGUAGE') {
|
|
4468
|
+
super(type);
|
|
4469
|
+
}
|
|
4470
|
+
/**
|
|
4471
|
+
* Short one-line description of LANGUAGE/LANGUAGES.
|
|
4472
|
+
*/
|
|
4473
|
+
get description() {
|
|
4474
|
+
return 'Specifies the language(s) the agent should use.';
|
|
4475
|
+
}
|
|
4476
|
+
/**
|
|
4477
|
+
* Icon for this commitment.
|
|
4478
|
+
*/
|
|
4479
|
+
get icon() {
|
|
4480
|
+
return '๐';
|
|
4481
|
+
}
|
|
4482
|
+
/**
|
|
4483
|
+
* Markdown documentation for LANGUAGE/LANGUAGES commitment.
|
|
4484
|
+
*/
|
|
4485
|
+
get documentation() {
|
|
4486
|
+
return spaceTrim$1.spaceTrim(`
|
|
4487
|
+
# ${this.type}
|
|
4488
|
+
|
|
4489
|
+
Specifies the language(s) the agent should use in its responses.
|
|
4490
|
+
This is a specialized variation of the RULE commitment focused on language constraints.
|
|
4491
|
+
|
|
4492
|
+
## Examples
|
|
4493
|
+
|
|
4494
|
+
\`\`\`book
|
|
4495
|
+
Paul Smith & Associรฉs
|
|
4496
|
+
|
|
4497
|
+
PERSONA You are a company lawyer.
|
|
4498
|
+
LANGUAGE French, English and Czech
|
|
4499
|
+
\`\`\`
|
|
4500
|
+
|
|
4501
|
+
\`\`\`book
|
|
4502
|
+
Customer Support
|
|
4503
|
+
|
|
4504
|
+
PERSONA You are a customer support agent.
|
|
4505
|
+
LANGUAGE English
|
|
4506
|
+
\`\`\`
|
|
4507
|
+
`);
|
|
4508
|
+
}
|
|
4509
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
4510
|
+
const trimmedContent = content.trim();
|
|
4511
|
+
if (!trimmedContent) {
|
|
4512
|
+
return requirements;
|
|
4513
|
+
}
|
|
4514
|
+
// Add language rule to the system message
|
|
4515
|
+
const languageSection = `Language: ${trimmedContent}`;
|
|
4516
|
+
return this.appendToSystemMessage(requirements, languageSection, '\n\n');
|
|
4517
|
+
}
|
|
4518
|
+
}
|
|
4519
|
+
/**
|
|
4520
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
4521
|
+
*/
|
|
4522
|
+
|
|
4191
4523
|
/**
|
|
4192
4524
|
* MEMORY commitment definition
|
|
4193
4525
|
*
|
|
@@ -4225,7 +4557,7 @@
|
|
|
4225
4557
|
* Markdown documentation for MEMORY commitment.
|
|
4226
4558
|
*/
|
|
4227
4559
|
get documentation() {
|
|
4228
|
-
return spaceTrim.spaceTrim(`
|
|
4560
|
+
return spaceTrim$1.spaceTrim(`
|
|
4229
4561
|
# ${this.type}
|
|
4230
4562
|
|
|
4231
4563
|
Similar to KNOWLEDGE but focuses on remembering past interactions and user preferences. This commitment helps the agent maintain context about the user's history, preferences, and previous conversations.
|
|
@@ -4295,23 +4627,6 @@
|
|
|
4295
4627
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
4296
4628
|
*/
|
|
4297
4629
|
|
|
4298
|
-
/**
|
|
4299
|
-
* Just says that the variable is not used but should be kept
|
|
4300
|
-
* No side effects.
|
|
4301
|
-
*
|
|
4302
|
-
* Note: It can be useful for:
|
|
4303
|
-
*
|
|
4304
|
-
* 1) Suppressing eager optimization of unused imports
|
|
4305
|
-
* 2) Suppressing eslint errors of unused variables in the tests
|
|
4306
|
-
* 3) Keeping the type of the variable for type testing
|
|
4307
|
-
*
|
|
4308
|
-
* @param value any values
|
|
4309
|
-
* @returns void
|
|
4310
|
-
* @private within the repository
|
|
4311
|
-
*/
|
|
4312
|
-
function keepUnused(...valuesToKeep) {
|
|
4313
|
-
}
|
|
4314
|
-
|
|
4315
4630
|
/**
|
|
4316
4631
|
* AGENT MESSAGE commitment definition
|
|
4317
4632
|
*
|
|
@@ -4346,7 +4661,7 @@
|
|
|
4346
4661
|
* Markdown documentation for AGENT MESSAGE commitment.
|
|
4347
4662
|
*/
|
|
4348
4663
|
get documentation() {
|
|
4349
|
-
return spaceTrim.spaceTrim(`
|
|
4664
|
+
return spaceTrim$1.spaceTrim(`
|
|
4350
4665
|
# ${this.type}
|
|
4351
4666
|
|
|
4352
4667
|
Defines a message from the agent in the conversation history. This is used to pre-fill the chat with a conversation history or to provide few-shot examples.
|
|
@@ -4423,7 +4738,7 @@
|
|
|
4423
4738
|
* Markdown documentation for INITIAL MESSAGE commitment.
|
|
4424
4739
|
*/
|
|
4425
4740
|
get documentation() {
|
|
4426
|
-
return spaceTrim.spaceTrim(`
|
|
4741
|
+
return spaceTrim$1.spaceTrim(`
|
|
4427
4742
|
# ${this.type}
|
|
4428
4743
|
|
|
4429
4744
|
Defines the first message that the user sees when opening the chat. This message is purely for display purposes in the UI and does not inherently become part of the LLM's system prompt context (unless also included via other means).
|
|
@@ -4487,7 +4802,7 @@
|
|
|
4487
4802
|
* Markdown documentation for MESSAGE commitment.
|
|
4488
4803
|
*/
|
|
4489
4804
|
get documentation() {
|
|
4490
|
-
return spaceTrim.spaceTrim(`
|
|
4805
|
+
return spaceTrim$1.spaceTrim(`
|
|
4491
4806
|
# ${this.type}
|
|
4492
4807
|
|
|
4493
4808
|
Contains 1:1 text of the message which AI assistant already sent during the conversation. Later messages are later in the conversation. It is similar to EXAMPLE but it is not example, it is the real message which AI assistant already sent.
|
|
@@ -4599,7 +4914,7 @@
|
|
|
4599
4914
|
* Markdown documentation for USER MESSAGE commitment.
|
|
4600
4915
|
*/
|
|
4601
4916
|
get documentation() {
|
|
4602
|
-
return spaceTrim.spaceTrim(`
|
|
4917
|
+
return spaceTrim$1.spaceTrim(`
|
|
4603
4918
|
# ${this.type}
|
|
4604
4919
|
|
|
4605
4920
|
Defines a message from the user in the conversation history. This is used to pre-fill the chat with a conversation history or to provide few-shot examples.
|
|
@@ -4678,7 +4993,7 @@
|
|
|
4678
4993
|
* Markdown documentation for META commitment.
|
|
4679
4994
|
*/
|
|
4680
4995
|
get documentation() {
|
|
4681
|
-
return spaceTrim.spaceTrim(`
|
|
4996
|
+
return spaceTrim$1.spaceTrim(`
|
|
4682
4997
|
# META
|
|
4683
4998
|
|
|
4684
4999
|
Sets meta-information about the agent that is used for display and attribution purposes.
|
|
@@ -4789,6 +5104,12 @@
|
|
|
4789
5104
|
* META COLOR #00ff00
|
|
4790
5105
|
* ```
|
|
4791
5106
|
*
|
|
5107
|
+
* You can also specify multiple colors separated by comma:
|
|
5108
|
+
*
|
|
5109
|
+
* ```book
|
|
5110
|
+
* META COLOR #ff0000, #00ff00, #0000ff
|
|
5111
|
+
* ```
|
|
5112
|
+
*
|
|
4792
5113
|
* @private [๐ช] Maybe export the commitments through some package
|
|
4793
5114
|
*/
|
|
4794
5115
|
class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
@@ -4799,7 +5120,7 @@
|
|
|
4799
5120
|
* Short one-line description of META COLOR.
|
|
4800
5121
|
*/
|
|
4801
5122
|
get description() {
|
|
4802
|
-
return "Set the agent's accent color.";
|
|
5123
|
+
return "Set the agent's accent color or gradient.";
|
|
4803
5124
|
}
|
|
4804
5125
|
/**
|
|
4805
5126
|
* Icon for this commitment.
|
|
@@ -4811,10 +5132,10 @@
|
|
|
4811
5132
|
* Markdown documentation for META COLOR commitment.
|
|
4812
5133
|
*/
|
|
4813
5134
|
get documentation() {
|
|
4814
|
-
return spaceTrim.spaceTrim(`
|
|
5135
|
+
return spaceTrim$1.spaceTrim(`
|
|
4815
5136
|
# META COLOR
|
|
4816
5137
|
|
|
4817
|
-
Sets the agent's accent color.
|
|
5138
|
+
Sets the agent's accent color or gradient.
|
|
4818
5139
|
|
|
4819
5140
|
## Key aspects
|
|
4820
5141
|
|
|
@@ -4822,6 +5143,7 @@
|
|
|
4822
5143
|
- Only one \`META COLOR\` should be used per agent.
|
|
4823
5144
|
- If multiple are specified, the last one takes precedence.
|
|
4824
5145
|
- Used for visual representation in user interfaces.
|
|
5146
|
+
- Can specify multiple colors separated by comma to create a gradient.
|
|
4825
5147
|
|
|
4826
5148
|
## Examples
|
|
4827
5149
|
|
|
@@ -4838,6 +5160,13 @@
|
|
|
4838
5160
|
META COLOR #e74c3c
|
|
4839
5161
|
PERSONA You are a creative and inspiring assistant
|
|
4840
5162
|
\`\`\`
|
|
5163
|
+
|
|
5164
|
+
\`\`\`book
|
|
5165
|
+
Gradient Agent
|
|
5166
|
+
|
|
5167
|
+
META COLOR #ff0000, #00ff00, #0000ff
|
|
5168
|
+
PERSONA You are a colorful agent
|
|
5169
|
+
\`\`\`
|
|
4841
5170
|
`);
|
|
4842
5171
|
}
|
|
4843
5172
|
applyToAgentModelRequirements(requirements, content) {
|
|
@@ -4859,6 +5188,91 @@
|
|
|
4859
5188
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
4860
5189
|
*/
|
|
4861
5190
|
|
|
5191
|
+
/**
|
|
5192
|
+
* META FONT commitment definition
|
|
5193
|
+
*
|
|
5194
|
+
* The META FONT commitment sets the agent's font.
|
|
5195
|
+
* This commitment is special because it doesn't affect the system message,
|
|
5196
|
+
* but is handled separately in the parsing logic.
|
|
5197
|
+
*
|
|
5198
|
+
* Example usage in agent source:
|
|
5199
|
+
*
|
|
5200
|
+
* ```book
|
|
5201
|
+
* META FONT Poppins, Arial, sans-serif
|
|
5202
|
+
* META FONT Roboto
|
|
5203
|
+
* ```
|
|
5204
|
+
*
|
|
5205
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
5206
|
+
*/
|
|
5207
|
+
class MetaFontCommitmentDefinition extends BaseCommitmentDefinition {
|
|
5208
|
+
constructor() {
|
|
5209
|
+
super('META FONT', ['FONT']);
|
|
5210
|
+
}
|
|
5211
|
+
/**
|
|
5212
|
+
* Short one-line description of META FONT.
|
|
5213
|
+
*/
|
|
5214
|
+
get description() {
|
|
5215
|
+
return "Set the agent's font.";
|
|
5216
|
+
}
|
|
5217
|
+
/**
|
|
5218
|
+
* Icon for this commitment.
|
|
5219
|
+
*/
|
|
5220
|
+
get icon() {
|
|
5221
|
+
return '๐ค';
|
|
5222
|
+
}
|
|
5223
|
+
/**
|
|
5224
|
+
* Markdown documentation for META FONT commitment.
|
|
5225
|
+
*/
|
|
5226
|
+
get documentation() {
|
|
5227
|
+
return spaceTrim$1.spaceTrim(`
|
|
5228
|
+
# META FONT
|
|
5229
|
+
|
|
5230
|
+
Sets the agent's font.
|
|
5231
|
+
|
|
5232
|
+
## Key aspects
|
|
5233
|
+
|
|
5234
|
+
- Does not modify the agent's behavior or responses.
|
|
5235
|
+
- Only one \`META FONT\` should be used per agent.
|
|
5236
|
+
- If multiple are specified, the last one takes precedence.
|
|
5237
|
+
- Used for visual representation in user interfaces.
|
|
5238
|
+
- Supports Google Fonts.
|
|
5239
|
+
|
|
5240
|
+
## Examples
|
|
5241
|
+
|
|
5242
|
+
\`\`\`book
|
|
5243
|
+
Modern Assistant
|
|
5244
|
+
|
|
5245
|
+
META FONT Poppins, Arial, sans-serif
|
|
5246
|
+
PERSONA You are a modern assistant
|
|
5247
|
+
\`\`\`
|
|
5248
|
+
|
|
5249
|
+
\`\`\`book
|
|
5250
|
+
Classic Helper
|
|
5251
|
+
|
|
5252
|
+
META FONT Times New Roman
|
|
5253
|
+
PERSONA You are a classic helper
|
|
5254
|
+
\`\`\`
|
|
5255
|
+
`);
|
|
5256
|
+
}
|
|
5257
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
5258
|
+
// META FONT doesn't modify the system message or model requirements
|
|
5259
|
+
// It's handled separately in the parsing logic
|
|
5260
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
5261
|
+
return requirements;
|
|
5262
|
+
}
|
|
5263
|
+
/**
|
|
5264
|
+
* Extracts the font from the content
|
|
5265
|
+
* This is used by the parsing logic
|
|
5266
|
+
*/
|
|
5267
|
+
extractProfileFont(content) {
|
|
5268
|
+
const trimmedContent = content.trim();
|
|
5269
|
+
return trimmedContent || null;
|
|
5270
|
+
}
|
|
5271
|
+
}
|
|
5272
|
+
/**
|
|
5273
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
5274
|
+
*/
|
|
5275
|
+
|
|
4862
5276
|
/**
|
|
4863
5277
|
* META IMAGE commitment definition
|
|
4864
5278
|
*
|
|
@@ -4895,7 +5309,7 @@
|
|
|
4895
5309
|
* Markdown documentation for META IMAGE commitment.
|
|
4896
5310
|
*/
|
|
4897
5311
|
get documentation() {
|
|
4898
|
-
return spaceTrim.spaceTrim(`
|
|
5312
|
+
return spaceTrim$1.spaceTrim(`
|
|
4899
5313
|
# META IMAGE
|
|
4900
5314
|
|
|
4901
5315
|
Sets the agent's avatar/profile image URL.
|
|
@@ -4946,6 +5360,115 @@
|
|
|
4946
5360
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
4947
5361
|
*/
|
|
4948
5362
|
|
|
5363
|
+
/**
|
|
5364
|
+
* META LINK commitment definition
|
|
5365
|
+
*
|
|
5366
|
+
* The `META LINK` commitment represents the link to the person from whom the agent is created.
|
|
5367
|
+
* This commitment is special because it doesn't affect the system message,
|
|
5368
|
+
* but is handled separately in the parsing logic for profile display.
|
|
5369
|
+
*
|
|
5370
|
+
* Example usage in agent source:
|
|
5371
|
+
*
|
|
5372
|
+
* ```
|
|
5373
|
+
* META LINK https://twitter.com/username
|
|
5374
|
+
* META LINK https://linkedin.com/in/profile
|
|
5375
|
+
* META LINK https://github.com/username
|
|
5376
|
+
* ```
|
|
5377
|
+
*
|
|
5378
|
+
* Multiple `META LINK` commitments can be used when there are multiple sources:
|
|
5379
|
+
*
|
|
5380
|
+
* ```book
|
|
5381
|
+
* META LINK https://twitter.com/username
|
|
5382
|
+
* META LINK https://linkedin.com/in/profile
|
|
5383
|
+
* ```
|
|
5384
|
+
*
|
|
5385
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
5386
|
+
*/
|
|
5387
|
+
class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
|
|
5388
|
+
constructor() {
|
|
5389
|
+
super('META LINK');
|
|
5390
|
+
}
|
|
5391
|
+
/**
|
|
5392
|
+
* Short one-line description of META LINK.
|
|
5393
|
+
*/
|
|
5394
|
+
get description() {
|
|
5395
|
+
return 'Provide profile/source links for the person the agent models.';
|
|
5396
|
+
}
|
|
5397
|
+
/**
|
|
5398
|
+
* Icon for this commitment.
|
|
5399
|
+
*/
|
|
5400
|
+
get icon() {
|
|
5401
|
+
return '๐';
|
|
5402
|
+
}
|
|
5403
|
+
/**
|
|
5404
|
+
* Markdown documentation for META LINK commitment.
|
|
5405
|
+
*/
|
|
5406
|
+
get documentation() {
|
|
5407
|
+
return spaceTrim$1.spaceTrim(`
|
|
5408
|
+
# META LINK
|
|
5409
|
+
|
|
5410
|
+
Represents a profile or source link for the person the agent is modeled after.
|
|
5411
|
+
|
|
5412
|
+
## Key aspects
|
|
5413
|
+
|
|
5414
|
+
- Does not modify the agent's behavior or responses.
|
|
5415
|
+
- Multiple \`META LINK\` commitments can be used for different social profiles.
|
|
5416
|
+
- Used for attribution and crediting the original person.
|
|
5417
|
+
- Displayed in user interfaces for transparency.
|
|
5418
|
+
|
|
5419
|
+
## Examples
|
|
5420
|
+
|
|
5421
|
+
\`\`\`book
|
|
5422
|
+
Expert Consultant
|
|
5423
|
+
|
|
5424
|
+
META LINK https://twitter.com/expertname
|
|
5425
|
+
META LINK https://linkedin.com/in/expertprofile
|
|
5426
|
+
PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
|
|
5427
|
+
KNOWLEDGE Extensive background in machine learning and neural networks
|
|
5428
|
+
\`\`\`
|
|
5429
|
+
|
|
5430
|
+
\`\`\`book
|
|
5431
|
+
Open Source Developer
|
|
5432
|
+
|
|
5433
|
+
META LINK https://github.com/developer
|
|
5434
|
+
META LINK https://twitter.com/devhandle
|
|
5435
|
+
PERSONA You are an experienced open source developer
|
|
5436
|
+
ACTION Can help with code reviews and architecture decisions
|
|
5437
|
+
STYLE Be direct and technical in explanations
|
|
5438
|
+
\`\`\`
|
|
5439
|
+
`);
|
|
5440
|
+
}
|
|
5441
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
5442
|
+
// META LINK doesn't modify the system message or model requirements
|
|
5443
|
+
// It's handled separately in the parsing logic for profile link extraction
|
|
5444
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
5445
|
+
return requirements;
|
|
5446
|
+
}
|
|
5447
|
+
/**
|
|
5448
|
+
* Extracts the profile link URL from the content
|
|
5449
|
+
* This is used by the parsing logic
|
|
5450
|
+
*/
|
|
5451
|
+
extractProfileLinkUrl(content) {
|
|
5452
|
+
const trimmedContent = content.trim();
|
|
5453
|
+
return trimmedContent || null;
|
|
5454
|
+
}
|
|
5455
|
+
/**
|
|
5456
|
+
* Validates if the provided content is a valid URL
|
|
5457
|
+
*/
|
|
5458
|
+
isValidUrl(content) {
|
|
5459
|
+
try {
|
|
5460
|
+
new URL(content.trim());
|
|
5461
|
+
return true;
|
|
5462
|
+
}
|
|
5463
|
+
catch (_a) {
|
|
5464
|
+
return false;
|
|
5465
|
+
}
|
|
5466
|
+
}
|
|
5467
|
+
}
|
|
5468
|
+
/**
|
|
5469
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
5470
|
+
*/
|
|
5471
|
+
|
|
4949
5472
|
/**
|
|
4950
5473
|
* MODEL commitment definition
|
|
4951
5474
|
*
|
|
@@ -4991,7 +5514,7 @@
|
|
|
4991
5514
|
* Markdown documentation for MODEL commitment.
|
|
4992
5515
|
*/
|
|
4993
5516
|
get documentation() {
|
|
4994
|
-
return spaceTrim.spaceTrim(`
|
|
5517
|
+
return spaceTrim$1.spaceTrim(`
|
|
4995
5518
|
# ${this.type}
|
|
4996
5519
|
|
|
4997
5520
|
Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
|
|
@@ -5232,7 +5755,7 @@
|
|
|
5232
5755
|
* Markdown documentation for NOTE commitment.
|
|
5233
5756
|
*/
|
|
5234
5757
|
get documentation() {
|
|
5235
|
-
return spaceTrim.spaceTrim(`
|
|
5758
|
+
return spaceTrim$1.spaceTrim(`
|
|
5236
5759
|
# ${this.type}
|
|
5237
5760
|
|
|
5238
5761
|
Adds comments for documentation without changing agent behavior.
|
|
@@ -5297,6 +5820,74 @@
|
|
|
5297
5820
|
* [๐] Ignore a discrepancy between file name and entity name
|
|
5298
5821
|
*/
|
|
5299
5822
|
|
|
5823
|
+
/**
|
|
5824
|
+
* OPEN commitment definition
|
|
5825
|
+
*
|
|
5826
|
+
* The OPEN commitment specifies that the agent can be modified by conversation.
|
|
5827
|
+
* This is the default behavior.
|
|
5828
|
+
*
|
|
5829
|
+
* Example usage in agent source:
|
|
5830
|
+
*
|
|
5831
|
+
* ```book
|
|
5832
|
+
* OPEN
|
|
5833
|
+
* ```
|
|
5834
|
+
*
|
|
5835
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
5836
|
+
*/
|
|
5837
|
+
class OpenCommitmentDefinition extends BaseCommitmentDefinition {
|
|
5838
|
+
constructor() {
|
|
5839
|
+
super('OPEN');
|
|
5840
|
+
}
|
|
5841
|
+
/**
|
|
5842
|
+
* Short one-line description of OPEN.
|
|
5843
|
+
*/
|
|
5844
|
+
get description() {
|
|
5845
|
+
return 'Allow the agent to be modified by conversation (default).';
|
|
5846
|
+
}
|
|
5847
|
+
/**
|
|
5848
|
+
* Icon for this commitment.
|
|
5849
|
+
*/
|
|
5850
|
+
get icon() {
|
|
5851
|
+
return '๐';
|
|
5852
|
+
}
|
|
5853
|
+
/**
|
|
5854
|
+
* Markdown documentation for OPEN commitment.
|
|
5855
|
+
*/
|
|
5856
|
+
get documentation() {
|
|
5857
|
+
return spaceTrim$1.spaceTrim(`
|
|
5858
|
+
# OPEN
|
|
5859
|
+
|
|
5860
|
+
Specifies that the agent can be modified by conversation with it.
|
|
5861
|
+
This means the agent will learn from interactions and update its source code.
|
|
5862
|
+
|
|
5863
|
+
This is the default behavior if neither \`OPEN\` nor \`CLOSED\` is specified.
|
|
5864
|
+
|
|
5865
|
+
> See also [CLOSED](/docs/CLOSED)
|
|
5866
|
+
|
|
5867
|
+
## Example
|
|
5868
|
+
|
|
5869
|
+
\`\`\`book
|
|
5870
|
+
OPEN
|
|
5871
|
+
\`\`\`
|
|
5872
|
+
`);
|
|
5873
|
+
}
|
|
5874
|
+
applyToAgentModelRequirements(requirements, _content) {
|
|
5875
|
+
// Since OPEN is default, we can just ensure isClosed is false
|
|
5876
|
+
// But to be explicit we can set it
|
|
5877
|
+
const updatedMetadata = {
|
|
5878
|
+
...requirements.metadata,
|
|
5879
|
+
isClosed: false,
|
|
5880
|
+
};
|
|
5881
|
+
return {
|
|
5882
|
+
...requirements,
|
|
5883
|
+
metadata: updatedMetadata,
|
|
5884
|
+
};
|
|
5885
|
+
}
|
|
5886
|
+
}
|
|
5887
|
+
/**
|
|
5888
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
5889
|
+
*/
|
|
5890
|
+
|
|
5300
5891
|
/**
|
|
5301
5892
|
* PERSONA commitment definition
|
|
5302
5893
|
*
|
|
@@ -5340,7 +5931,7 @@
|
|
|
5340
5931
|
* Markdown documentation for PERSONA commitment.
|
|
5341
5932
|
*/
|
|
5342
5933
|
get documentation() {
|
|
5343
|
-
return spaceTrim.spaceTrim(`
|
|
5934
|
+
return spaceTrim$1.spaceTrim(`
|
|
5344
5935
|
# ${this.type}
|
|
5345
5936
|
|
|
5346
5937
|
Defines who the agent is, their background, expertise, and personality traits.
|
|
@@ -5473,7 +6064,7 @@
|
|
|
5473
6064
|
* Markdown documentation for RULE/RULES commitment.
|
|
5474
6065
|
*/
|
|
5475
6066
|
get documentation() {
|
|
5476
|
-
return spaceTrim.spaceTrim(`
|
|
6067
|
+
return spaceTrim$1.spaceTrim(`
|
|
5477
6068
|
# ${this.type}
|
|
5478
6069
|
|
|
5479
6070
|
Adds behavioral constraints and guidelines that the agent must follow.
|
|
@@ -5555,7 +6146,7 @@
|
|
|
5555
6146
|
* Markdown documentation for SAMPLE/EXAMPLE commitment.
|
|
5556
6147
|
*/
|
|
5557
6148
|
get documentation() {
|
|
5558
|
-
return spaceTrim.spaceTrim(`
|
|
6149
|
+
return spaceTrim$1.spaceTrim(`
|
|
5559
6150
|
# ${this.type}
|
|
5560
6151
|
|
|
5561
6152
|
Provides examples of how the agent should respond or behave in certain situations.
|
|
@@ -5638,7 +6229,7 @@
|
|
|
5638
6229
|
* Markdown documentation for SCENARIO commitment.
|
|
5639
6230
|
*/
|
|
5640
6231
|
get documentation() {
|
|
5641
|
-
return spaceTrim.spaceTrim(`
|
|
6232
|
+
return spaceTrim$1.spaceTrim(`
|
|
5642
6233
|
# ${this.type}
|
|
5643
6234
|
|
|
5644
6235
|
Defines a specific situation or context in which the AI assistant should operate. It helps to set the scene for the AI's responses. Later scenarios are more important than earlier scenarios.
|
|
@@ -5760,7 +6351,7 @@
|
|
|
5760
6351
|
* Markdown documentation for STYLE commitment.
|
|
5761
6352
|
*/
|
|
5762
6353
|
get documentation() {
|
|
5763
|
-
return spaceTrim.spaceTrim(`
|
|
6354
|
+
return spaceTrim$1.spaceTrim(`
|
|
5764
6355
|
# ${this.type}
|
|
5765
6356
|
|
|
5766
6357
|
Defines how the agent should format and present its responses (tone, writing style, formatting).
|
|
@@ -5807,6 +6398,389 @@
|
|
|
5807
6398
|
* [๐] Ignore a discrepancy between file name and entity name
|
|
5808
6399
|
*/
|
|
5809
6400
|
|
|
6401
|
+
/**
|
|
6402
|
+
* USE commitment definition
|
|
6403
|
+
*
|
|
6404
|
+
* The USE commitment indicates that the agent should utilize specific tools or capabilities
|
|
6405
|
+
* to access and interact with external systems when necessary.
|
|
6406
|
+
*
|
|
6407
|
+
* Supported USE types:
|
|
6408
|
+
* - USE BROWSER: Enables the agent to use a web browser tool
|
|
6409
|
+
* - USE SEARCH ENGINE (future): Enables search engine access
|
|
6410
|
+
* - USE FILE SYSTEM (future): Enables file system operations
|
|
6411
|
+
* - USE MCP (future): Enables MCP server connections
|
|
6412
|
+
*
|
|
6413
|
+
* The content following the USE commitment is ignored (similar to NOTE).
|
|
6414
|
+
*
|
|
6415
|
+
* Example usage in agent source:
|
|
6416
|
+
*
|
|
6417
|
+
* ```book
|
|
6418
|
+
* USE BROWSER
|
|
6419
|
+
* USE SEARCH ENGINE
|
|
6420
|
+
* ```
|
|
6421
|
+
*
|
|
6422
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
6423
|
+
*/
|
|
6424
|
+
class UseCommitmentDefinition extends BaseCommitmentDefinition {
|
|
6425
|
+
constructor() {
|
|
6426
|
+
super('USE');
|
|
6427
|
+
}
|
|
6428
|
+
/**
|
|
6429
|
+
* Short one-line description of USE commitments.
|
|
6430
|
+
*/
|
|
6431
|
+
get description() {
|
|
6432
|
+
return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
|
|
6433
|
+
}
|
|
6434
|
+
/**
|
|
6435
|
+
* Icon for this commitment.
|
|
6436
|
+
*/
|
|
6437
|
+
get icon() {
|
|
6438
|
+
return '๐ง';
|
|
6439
|
+
}
|
|
6440
|
+
/**
|
|
6441
|
+
* Markdown documentation for USE commitment.
|
|
6442
|
+
*/
|
|
6443
|
+
get documentation() {
|
|
6444
|
+
return spaceTrim$1.spaceTrim(`
|
|
6445
|
+
# USE
|
|
6446
|
+
|
|
6447
|
+
Enables the agent to use specific tools or capabilities for interacting with external systems.
|
|
6448
|
+
|
|
6449
|
+
## Supported USE types
|
|
6450
|
+
|
|
6451
|
+
- **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
|
|
6452
|
+
- **USE SEARCH ENGINE** (future) - Enables search engine access
|
|
6453
|
+
- **USE FILE SYSTEM** (future) - Enables file system operations
|
|
6454
|
+
- **USE MCP** (future) - Enables MCP server connections
|
|
6455
|
+
|
|
6456
|
+
## Key aspects
|
|
6457
|
+
|
|
6458
|
+
- The content following the USE commitment is ignored (similar to NOTE)
|
|
6459
|
+
- Multiple USE commitments can be specified to enable multiple capabilities
|
|
6460
|
+
- The actual tool usage is handled by the agent runtime
|
|
6461
|
+
|
|
6462
|
+
## Examples
|
|
6463
|
+
|
|
6464
|
+
### Basic browser usage
|
|
6465
|
+
|
|
6466
|
+
\`\`\`book
|
|
6467
|
+
Research Assistant
|
|
6468
|
+
|
|
6469
|
+
PERSONA You are a helpful research assistant
|
|
6470
|
+
USE BROWSER
|
|
6471
|
+
KNOWLEDGE Can search the web for up-to-date information
|
|
6472
|
+
\`\`\`
|
|
6473
|
+
|
|
6474
|
+
### Multiple tools
|
|
6475
|
+
|
|
6476
|
+
\`\`\`book
|
|
6477
|
+
Data Analyst
|
|
6478
|
+
|
|
6479
|
+
PERSONA You are a data analyst assistant
|
|
6480
|
+
USE BROWSER
|
|
6481
|
+
USE FILE SYSTEM
|
|
6482
|
+
ACTION Can analyze data from various sources
|
|
6483
|
+
\`\`\`
|
|
6484
|
+
`);
|
|
6485
|
+
}
|
|
6486
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
6487
|
+
// USE commitments don't modify the system message or model requirements directly
|
|
6488
|
+
// They are handled separately in the parsing logic for capability extraction
|
|
6489
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
6490
|
+
return requirements;
|
|
6491
|
+
}
|
|
6492
|
+
/**
|
|
6493
|
+
* Extracts the tool type from the USE commitment
|
|
6494
|
+
* This is used by the parsing logic
|
|
6495
|
+
*/
|
|
6496
|
+
extractToolType(content) {
|
|
6497
|
+
var _a, _b;
|
|
6498
|
+
const trimmedContent = content.trim();
|
|
6499
|
+
// The tool type is the first word after USE (already stripped)
|
|
6500
|
+
const match = trimmedContent.match(/^(\w+)/);
|
|
6501
|
+
return (_b = (_a = match === null || match === void 0 ? void 0 : match[1]) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : null;
|
|
6502
|
+
}
|
|
6503
|
+
/**
|
|
6504
|
+
* Checks if this is a known USE type
|
|
6505
|
+
*/
|
|
6506
|
+
isKnownUseType(useType) {
|
|
6507
|
+
const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
|
|
6508
|
+
return knownTypes.includes(useType.toUpperCase());
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6511
|
+
/**
|
|
6512
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
6513
|
+
*/
|
|
6514
|
+
|
|
6515
|
+
/**
|
|
6516
|
+
* USE BROWSER commitment definition
|
|
6517
|
+
*
|
|
6518
|
+
* The `USE BROWSER` commitment indicates that the agent should utilize a web browser tool
|
|
6519
|
+
* to access and retrieve up-to-date information from the internet when necessary.
|
|
6520
|
+
*
|
|
6521
|
+
* The content following `USE BROWSER` is ignored (similar to NOTE).
|
|
6522
|
+
*
|
|
6523
|
+
* Example usage in agent source:
|
|
6524
|
+
*
|
|
6525
|
+
* ```book
|
|
6526
|
+
* USE BROWSER
|
|
6527
|
+
* USE BROWSER This will be ignored
|
|
6528
|
+
* ```
|
|
6529
|
+
*
|
|
6530
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
6531
|
+
*/
|
|
6532
|
+
class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
6533
|
+
constructor() {
|
|
6534
|
+
super('USE BROWSER', ['BROWSER']);
|
|
6535
|
+
}
|
|
6536
|
+
/**
|
|
6537
|
+
* Short one-line description of USE BROWSER.
|
|
6538
|
+
*/
|
|
6539
|
+
get description() {
|
|
6540
|
+
return 'Enable the agent to use a web browser tool for accessing internet information.';
|
|
6541
|
+
}
|
|
6542
|
+
/**
|
|
6543
|
+
* Icon for this commitment.
|
|
6544
|
+
*/
|
|
6545
|
+
get icon() {
|
|
6546
|
+
return '๐';
|
|
6547
|
+
}
|
|
6548
|
+
/**
|
|
6549
|
+
* Markdown documentation for USE BROWSER commitment.
|
|
6550
|
+
*/
|
|
6551
|
+
get documentation() {
|
|
6552
|
+
return spaceTrim$1.spaceTrim(`
|
|
6553
|
+
# USE BROWSER
|
|
6554
|
+
|
|
6555
|
+
Enables the agent to use a web browser tool to access and retrieve up-to-date information from the internet.
|
|
6556
|
+
|
|
6557
|
+
## Key aspects
|
|
6558
|
+
|
|
6559
|
+
- The content following \`USE BROWSER\` is ignored (similar to NOTE)
|
|
6560
|
+
- The actual browser tool usage is handled by the agent runtime
|
|
6561
|
+
- Allows the agent to fetch current information from websites
|
|
6562
|
+
- Useful for research tasks, fact-checking, and accessing dynamic content
|
|
6563
|
+
|
|
6564
|
+
## Examples
|
|
6565
|
+
|
|
6566
|
+
\`\`\`book
|
|
6567
|
+
Research Assistant
|
|
6568
|
+
|
|
6569
|
+
PERSONA You are a helpful research assistant specialized in finding current information
|
|
6570
|
+
USE BROWSER
|
|
6571
|
+
RULE Always cite your sources when providing information from the web
|
|
6572
|
+
\`\`\`
|
|
6573
|
+
|
|
6574
|
+
\`\`\`book
|
|
6575
|
+
News Analyst
|
|
6576
|
+
|
|
6577
|
+
PERSONA You are a news analyst who stays up-to-date with current events
|
|
6578
|
+
USE BROWSER
|
|
6579
|
+
STYLE Present news in a balanced and objective manner
|
|
6580
|
+
ACTION Can search for and summarize news articles
|
|
6581
|
+
\`\`\`
|
|
6582
|
+
|
|
6583
|
+
\`\`\`book
|
|
6584
|
+
Company Lawyer
|
|
6585
|
+
|
|
6586
|
+
PERSONA You are a company lawyer providing legal advice
|
|
6587
|
+
USE BROWSER
|
|
6588
|
+
KNOWLEDGE Corporate law and legal procedures
|
|
6589
|
+
RULE Always recommend consulting with a licensed attorney for specific legal matters
|
|
6590
|
+
\`\`\`
|
|
6591
|
+
`);
|
|
6592
|
+
}
|
|
6593
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
6594
|
+
// We simply mark that browser capability is enabled in metadata
|
|
6595
|
+
// Get existing metadata
|
|
6596
|
+
const existingMetadata = requirements.metadata || {};
|
|
6597
|
+
// Get existing tools array or create new one
|
|
6598
|
+
const existingTools = existingMetadata.tools || [];
|
|
6599
|
+
// Add 'browser' to tools if not already present
|
|
6600
|
+
const updatedTools = existingTools.includes('browser') ? existingTools : [...existingTools, 'browser'];
|
|
6601
|
+
// Return requirements with updated metadata
|
|
6602
|
+
return {
|
|
6603
|
+
...requirements,
|
|
6604
|
+
metadata: {
|
|
6605
|
+
...existingMetadata,
|
|
6606
|
+
tools: updatedTools,
|
|
6607
|
+
useBrowser: true,
|
|
6608
|
+
},
|
|
6609
|
+
};
|
|
6610
|
+
}
|
|
6611
|
+
}
|
|
6612
|
+
/**
|
|
6613
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
6614
|
+
*/
|
|
6615
|
+
|
|
6616
|
+
/**
|
|
6617
|
+
* USE MCP commitment definition
|
|
6618
|
+
*
|
|
6619
|
+
* The `USE MCP` commitment allows to specify an MCP server URL which the agent will connect to
|
|
6620
|
+
* for retrieving additional instructions and actions.
|
|
6621
|
+
*
|
|
6622
|
+
* The content following `USE MCP` is the URL of the MCP server.
|
|
6623
|
+
*
|
|
6624
|
+
* Example usage in agent source:
|
|
6625
|
+
*
|
|
6626
|
+
* ```book
|
|
6627
|
+
* USE MCP http://mcp-server-url.com
|
|
6628
|
+
* ```
|
|
6629
|
+
*
|
|
6630
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
6631
|
+
*/
|
|
6632
|
+
class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
6633
|
+
constructor() {
|
|
6634
|
+
super('USE MCP', ['MCP']);
|
|
6635
|
+
}
|
|
6636
|
+
/**
|
|
6637
|
+
* Short one-line description of USE MCP.
|
|
6638
|
+
*/
|
|
6639
|
+
get description() {
|
|
6640
|
+
return 'Connects the agent to an external MCP server for additional capabilities.';
|
|
6641
|
+
}
|
|
6642
|
+
/**
|
|
6643
|
+
* Icon for this commitment.
|
|
6644
|
+
*/
|
|
6645
|
+
get icon() {
|
|
6646
|
+
return '๐';
|
|
6647
|
+
}
|
|
6648
|
+
/**
|
|
6649
|
+
* Markdown documentation for USE MCP commitment.
|
|
6650
|
+
*/
|
|
6651
|
+
get documentation() {
|
|
6652
|
+
return spaceTrim$1.spaceTrim(`
|
|
6653
|
+
# USE MCP
|
|
6654
|
+
|
|
6655
|
+
Connects the agent to an external Model Context Protocol (MCP) server.
|
|
6656
|
+
|
|
6657
|
+
## Key aspects
|
|
6658
|
+
|
|
6659
|
+
- The content following \`USE MCP\` must be a valid URL
|
|
6660
|
+
- Multiple MCP servers can be connected by using multiple \`USE MCP\` commitments
|
|
6661
|
+
- The agent will have access to tools and resources provided by the MCP server
|
|
6662
|
+
|
|
6663
|
+
## Example
|
|
6664
|
+
|
|
6665
|
+
\`\`\`book
|
|
6666
|
+
Company Lawyer
|
|
6667
|
+
|
|
6668
|
+
PERSONA You are a company lawyer.
|
|
6669
|
+
USE MCP http://legal-db.example.com
|
|
6670
|
+
\`\`\`
|
|
6671
|
+
`);
|
|
6672
|
+
}
|
|
6673
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
6674
|
+
const mcpServerUrl = content.trim();
|
|
6675
|
+
if (!mcpServerUrl) {
|
|
6676
|
+
return requirements;
|
|
6677
|
+
}
|
|
6678
|
+
const existingMcpServers = requirements.mcpServers || [];
|
|
6679
|
+
// Avoid duplicates
|
|
6680
|
+
if (existingMcpServers.includes(mcpServerUrl)) {
|
|
6681
|
+
return requirements;
|
|
6682
|
+
}
|
|
6683
|
+
return {
|
|
6684
|
+
...requirements,
|
|
6685
|
+
mcpServers: [...existingMcpServers, mcpServerUrl],
|
|
6686
|
+
};
|
|
6687
|
+
}
|
|
6688
|
+
}
|
|
6689
|
+
/**
|
|
6690
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
6691
|
+
*/
|
|
6692
|
+
|
|
6693
|
+
/**
|
|
6694
|
+
* USE SEARCH ENGINE commitment definition
|
|
6695
|
+
*
|
|
6696
|
+
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
6697
|
+
* to access and retrieve up-to-date information from the internet when necessary.
|
|
6698
|
+
*
|
|
6699
|
+
* The content following `USE SEARCH ENGINE` is ignored (similar to NOTE).
|
|
6700
|
+
*
|
|
6701
|
+
* Example usage in agent source:
|
|
6702
|
+
*
|
|
6703
|
+
* ```book
|
|
6704
|
+
* USE SEARCH ENGINE
|
|
6705
|
+
* USE SEARCH ENGINE This will be ignored
|
|
6706
|
+
* ```
|
|
6707
|
+
*
|
|
6708
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
6709
|
+
*/
|
|
6710
|
+
class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
6711
|
+
constructor() {
|
|
6712
|
+
super('USE SEARCH ENGINE', ['SEARCH ENGINE', 'SEARCH']);
|
|
6713
|
+
}
|
|
6714
|
+
/**
|
|
6715
|
+
* Short one-line description of USE SEARCH ENGINE.
|
|
6716
|
+
*/
|
|
6717
|
+
get description() {
|
|
6718
|
+
return 'Enable the agent to use a search engine tool for accessing internet information.';
|
|
6719
|
+
}
|
|
6720
|
+
/**
|
|
6721
|
+
* Icon for this commitment.
|
|
6722
|
+
*/
|
|
6723
|
+
get icon() {
|
|
6724
|
+
return '๐';
|
|
6725
|
+
}
|
|
6726
|
+
/**
|
|
6727
|
+
* Markdown documentation for USE SEARCH ENGINE commitment.
|
|
6728
|
+
*/
|
|
6729
|
+
get documentation() {
|
|
6730
|
+
return spaceTrim$1.spaceTrim(`
|
|
6731
|
+
# USE SEARCH ENGINE
|
|
6732
|
+
|
|
6733
|
+
Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
|
|
6734
|
+
|
|
6735
|
+
## Key aspects
|
|
6736
|
+
|
|
6737
|
+
- The content following \`USE SEARCH ENGINE\` is ignored (similar to NOTE)
|
|
6738
|
+
- The actual search engine tool usage is handled by the agent runtime
|
|
6739
|
+
- Allows the agent to search for current information from the web
|
|
6740
|
+
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
6741
|
+
|
|
6742
|
+
## Examples
|
|
6743
|
+
|
|
6744
|
+
\`\`\`book
|
|
6745
|
+
Research Assistant
|
|
6746
|
+
|
|
6747
|
+
PERSONA You are a helpful research assistant specialized in finding current information
|
|
6748
|
+
USE SEARCH ENGINE
|
|
6749
|
+
RULE Always cite your sources when providing information from the web
|
|
6750
|
+
\`\`\`
|
|
6751
|
+
|
|
6752
|
+
\`\`\`book
|
|
6753
|
+
Fact Checker
|
|
6754
|
+
|
|
6755
|
+
PERSONA You are a fact checker
|
|
6756
|
+
USE SEARCH ENGINE
|
|
6757
|
+
ACTION Search for claims and verify them against reliable sources
|
|
6758
|
+
\`\`\`
|
|
6759
|
+
`);
|
|
6760
|
+
}
|
|
6761
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
6762
|
+
// We simply mark that search engine capability is enabled in metadata
|
|
6763
|
+
// Get existing metadata
|
|
6764
|
+
const existingMetadata = requirements.metadata || {};
|
|
6765
|
+
// Get existing tools array or create new one
|
|
6766
|
+
const existingTools = existingMetadata.tools || [];
|
|
6767
|
+
// Add 'search-engine' to tools if not already present
|
|
6768
|
+
const updatedTools = existingTools.includes('search-engine') ? existingTools : [...existingTools, 'search-engine'];
|
|
6769
|
+
// Return requirements with updated metadata
|
|
6770
|
+
return {
|
|
6771
|
+
...requirements,
|
|
6772
|
+
metadata: {
|
|
6773
|
+
...existingMetadata,
|
|
6774
|
+
tools: updatedTools,
|
|
6775
|
+
useSearchEngine: true,
|
|
6776
|
+
},
|
|
6777
|
+
};
|
|
6778
|
+
}
|
|
6779
|
+
}
|
|
6780
|
+
/**
|
|
6781
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
6782
|
+
*/
|
|
6783
|
+
|
|
5810
6784
|
/**
|
|
5811
6785
|
* Placeholder commitment definition for commitments that are not yet implemented
|
|
5812
6786
|
*
|
|
@@ -5835,7 +6809,7 @@
|
|
|
5835
6809
|
* Markdown documentation available at runtime.
|
|
5836
6810
|
*/
|
|
5837
6811
|
get documentation() {
|
|
5838
|
-
return spaceTrim.spaceTrim(`
|
|
6812
|
+
return spaceTrim$1.spaceTrim(`
|
|
5839
6813
|
# ${this.type}
|
|
5840
6814
|
|
|
5841
6815
|
This commitment is not yet fully implemented.
|
|
@@ -5893,16 +6867,22 @@
|
|
|
5893
6867
|
new StyleCommitmentDefinition('STYLES'),
|
|
5894
6868
|
new RuleCommitmentDefinition('RULE'),
|
|
5895
6869
|
new RuleCommitmentDefinition('RULES'),
|
|
6870
|
+
new LanguageCommitmentDefinition('LANGUAGE'),
|
|
6871
|
+
new LanguageCommitmentDefinition('LANGUAGES'),
|
|
5896
6872
|
new SampleCommitmentDefinition('SAMPLE'),
|
|
5897
6873
|
new SampleCommitmentDefinition('EXAMPLE'),
|
|
5898
6874
|
new FormatCommitmentDefinition('FORMAT'),
|
|
5899
6875
|
new FormatCommitmentDefinition('FORMATS'),
|
|
6876
|
+
new FromCommitmentDefinition('FROM'),
|
|
5900
6877
|
new ModelCommitmentDefinition('MODEL'),
|
|
5901
6878
|
new ModelCommitmentDefinition('MODELS'),
|
|
5902
6879
|
new ActionCommitmentDefinition('ACTION'),
|
|
5903
6880
|
new ActionCommitmentDefinition('ACTIONS'),
|
|
6881
|
+
new ComponentCommitmentDefinition(),
|
|
5904
6882
|
new MetaImageCommitmentDefinition(),
|
|
5905
6883
|
new MetaColorCommitmentDefinition(),
|
|
6884
|
+
new MetaFontCommitmentDefinition(),
|
|
6885
|
+
new MetaLinkCommitmentDefinition(),
|
|
5906
6886
|
new MetaCommitmentDefinition(),
|
|
5907
6887
|
new NoteCommitmentDefinition('NOTE'),
|
|
5908
6888
|
new NoteCommitmentDefinition('NOTES'),
|
|
@@ -5921,6 +6901,12 @@
|
|
|
5921
6901
|
new DeleteCommitmentDefinition('CANCEL'),
|
|
5922
6902
|
new DeleteCommitmentDefinition('DISCARD'),
|
|
5923
6903
|
new DeleteCommitmentDefinition('REMOVE'),
|
|
6904
|
+
new OpenCommitmentDefinition(),
|
|
6905
|
+
new ClosedCommitmentDefinition(),
|
|
6906
|
+
new UseBrowserCommitmentDefinition(),
|
|
6907
|
+
new UseSearchEngineCommitmentDefinition(),
|
|
6908
|
+
new UseMcpCommitmentDefinition(),
|
|
6909
|
+
new UseCommitmentDefinition(),
|
|
5924
6910
|
// Not yet implemented commitments (using placeholder)
|
|
5925
6911
|
new NotYetImplementedCommitmentDefinition('EXPECT'),
|
|
5926
6912
|
new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
|
|
@@ -5953,6 +6939,11 @@
|
|
|
5953
6939
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
5954
6940
|
*/
|
|
5955
6941
|
|
|
6942
|
+
/**
|
|
6943
|
+
* Regex pattern to match horizontal lines (markdown thematic breaks)
|
|
6944
|
+
* Matches 3 or more hyphens, underscores, or asterisks (with optional spaces between)
|
|
6945
|
+
*/
|
|
6946
|
+
const HORIZONTAL_LINE_PATTERN = /^[\s]*[-_*][\s]*[-_*][\s]*[-_*][\s]*[-_*]*[\s]*$/;
|
|
5956
6947
|
/**
|
|
5957
6948
|
* Parses agent source using the new commitment system with multiline support
|
|
5958
6949
|
* This function replaces the hardcoded commitment parsing in the original parseAgentSource
|
|
@@ -5995,7 +6986,7 @@
|
|
|
5995
6986
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
5996
6987
|
commitments.push({
|
|
5997
6988
|
type: currentCommitment.type,
|
|
5998
|
-
content: spaceTrim.spaceTrim(fullContent),
|
|
6989
|
+
content: spaceTrim$1.spaceTrim(fullContent),
|
|
5999
6990
|
originalLine: currentCommitment.originalStartLine,
|
|
6000
6991
|
lineNumber: currentCommitment.startLineNumber,
|
|
6001
6992
|
});
|
|
@@ -6015,6 +7006,24 @@
|
|
|
6015
7006
|
break;
|
|
6016
7007
|
}
|
|
6017
7008
|
}
|
|
7009
|
+
// Check if this is a horizontal line (ends any current commitment)
|
|
7010
|
+
const isHorizontalLine = HORIZONTAL_LINE_PATTERN.test(line);
|
|
7011
|
+
if (isHorizontalLine) {
|
|
7012
|
+
// Save the current commitment if it exists
|
|
7013
|
+
if (currentCommitment) {
|
|
7014
|
+
const fullContent = currentCommitment.contentLines.join('\n');
|
|
7015
|
+
commitments.push({
|
|
7016
|
+
type: currentCommitment.type,
|
|
7017
|
+
content: spaceTrim$1.spaceTrim(fullContent),
|
|
7018
|
+
originalLine: currentCommitment.originalStartLine,
|
|
7019
|
+
lineNumber: currentCommitment.startLineNumber,
|
|
7020
|
+
});
|
|
7021
|
+
currentCommitment = null;
|
|
7022
|
+
}
|
|
7023
|
+
// Add horizontal line to non-commitment lines
|
|
7024
|
+
nonCommitmentLines.push(line);
|
|
7025
|
+
continue;
|
|
7026
|
+
}
|
|
6018
7027
|
if (!foundNewCommitment) {
|
|
6019
7028
|
if (currentCommitment) {
|
|
6020
7029
|
// This line belongs to the current commitment
|
|
@@ -6031,7 +7040,7 @@
|
|
|
6031
7040
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
6032
7041
|
commitments.push({
|
|
6033
7042
|
type: currentCommitment.type,
|
|
6034
|
-
content: spaceTrim.spaceTrim(fullContent),
|
|
7043
|
+
content: spaceTrim$1.spaceTrim(fullContent),
|
|
6035
7044
|
originalLine: currentCommitment.originalStartLine,
|
|
6036
7045
|
lineNumber: currentCommitment.startLineNumber,
|
|
6037
7046
|
});
|
|
@@ -6101,16 +7110,6 @@
|
|
|
6101
7110
|
return uniqueParameters;
|
|
6102
7111
|
}
|
|
6103
7112
|
|
|
6104
|
-
/**
|
|
6105
|
-
* Creates temporary default agent name based on agent source hash
|
|
6106
|
-
*
|
|
6107
|
-
* @public exported from `@promptbook/core`
|
|
6108
|
-
*/
|
|
6109
|
-
function createDefaultAgentName(agentSource) {
|
|
6110
|
-
const agentHash = computeAgentHash(agentSource);
|
|
6111
|
-
return normalizeAgentName(`Agent ${agentHash.substring(0, 6)}`);
|
|
6112
|
-
}
|
|
6113
|
-
|
|
6114
7113
|
/**
|
|
6115
7114
|
* Parses basic information from agent source
|
|
6116
7115
|
*
|
|
@@ -6150,7 +7149,9 @@
|
|
|
6150
7149
|
const links = [];
|
|
6151
7150
|
for (const commitment of parseResult.commitments) {
|
|
6152
7151
|
if (commitment.type === 'META LINK') {
|
|
6153
|
-
|
|
7152
|
+
const linkValue = spaceTrim__default["default"](commitment.content);
|
|
7153
|
+
links.push(linkValue);
|
|
7154
|
+
meta.link = linkValue;
|
|
6154
7155
|
continue;
|
|
6155
7156
|
}
|
|
6156
7157
|
if (commitment.type === 'META IMAGE') {
|
|
@@ -6161,6 +7162,10 @@
|
|
|
6161
7162
|
meta.color = spaceTrim__default["default"](commitment.content);
|
|
6162
7163
|
continue;
|
|
6163
7164
|
}
|
|
7165
|
+
if (commitment.type === 'META FONT') {
|
|
7166
|
+
meta.font = spaceTrim__default["default"](commitment.content);
|
|
7167
|
+
continue;
|
|
7168
|
+
}
|
|
6164
7169
|
if (commitment.type !== 'META') {
|
|
6165
7170
|
continue;
|
|
6166
7171
|
}
|
|
@@ -7953,9 +8958,9 @@
|
|
|
7953
8958
|
const mdSaveFormatDefinition = {
|
|
7954
8959
|
formatName: 'md',
|
|
7955
8960
|
label: 'Markdown',
|
|
7956
|
-
getContent: ({ messages }) => spaceTrim.spaceTrim(`
|
|
8961
|
+
getContent: ({ messages }) => spaceTrim$1.spaceTrim(`
|
|
7957
8962
|
${messages
|
|
7958
|
-
.map((message) => spaceTrim.spaceTrim(`
|
|
8963
|
+
.map((message) => spaceTrim$1.spaceTrim(`
|
|
7959
8964
|
**${message.from}:**
|
|
7960
8965
|
|
|
7961
8966
|
> ${message.content.replace(/\n/g, '\n> ')}
|
|
@@ -8216,7 +9221,7 @@
|
|
|
8216
9221
|
// Note: Do not hide tooltip on mouse leave, it will be hidden by clicking outside
|
|
8217
9222
|
};
|
|
8218
9223
|
const isMe = participant === null || participant === void 0 ? void 0 : participant.isMe;
|
|
8219
|
-
const color = Color.
|
|
9224
|
+
const color = Color.fromSafe((participant && participant.color) || (isMe ? USER_CHAT_COLOR : PROMPTBOOK_CHAT_COLOR));
|
|
8220
9225
|
const colorOfText = color.then(textColor);
|
|
8221
9226
|
const { contentWithoutButtons, buttons } = parseMessageButtons(message.content);
|
|
8222
9227
|
const shouldShowButtons = isLastMessage && buttons.length > 0 && onMessage;
|
|
@@ -8853,7 +9858,7 @@
|
|
|
8853
9858
|
* @public exported from `@promptbook/components`
|
|
8854
9859
|
*/
|
|
8855
9860
|
function LlmChat(props) {
|
|
8856
|
-
const { llmTools, persistenceKey, onChange, onReset, initialMessages, sendMessage, userParticipantName = 'USER', llmParticipantName = 'ASSISTANT', ...restProps } = props;
|
|
9861
|
+
const { llmTools, persistenceKey, onChange, onReset, initialMessages, sendMessage, userParticipantName = 'USER', llmParticipantName = 'ASSISTANT', autoExecuteMessage, ...restProps } = props;
|
|
8857
9862
|
// Internal state management
|
|
8858
9863
|
// DRY: Single factory for seeding initial messages (used on mount and after reset)
|
|
8859
9864
|
const buildInitialMessages = react.useCallback(() => (initialMessages ? [...initialMessages] : []), [initialMessages]);
|
|
@@ -9187,6 +10192,14 @@
|
|
|
9187
10192
|
sendMessage._attach(handleMessage);
|
|
9188
10193
|
}
|
|
9189
10194
|
}, [sendMessage, handleMessage]);
|
|
10195
|
+
// Handle autoExecuteMessage
|
|
10196
|
+
const hasAutoExecutedRef = react.useRef(false);
|
|
10197
|
+
react.useEffect(() => {
|
|
10198
|
+
if (autoExecuteMessage && !hasAutoExecutedRef.current) {
|
|
10199
|
+
hasAutoExecutedRef.current = true;
|
|
10200
|
+
handleMessage(autoExecuteMessage);
|
|
10201
|
+
}
|
|
10202
|
+
}, [autoExecuteMessage, handleMessage]);
|
|
9190
10203
|
return (jsxRuntime.jsx(Chat, { ...restProps, messages, onReset, tasksProgress, participants, onMessage: handleMessage, onReset: handleReset, onVoiceInput: llmTools.callVoiceChatModel ? handleVoiceInput : undefined, isVoiceCalling: isVoiceCalling }));
|
|
9191
10204
|
}
|
|
9192
10205
|
|
|
@@ -10131,7 +11144,7 @@
|
|
|
10131
11144
|
if (!(error instanceof PipelineLogicError)) {
|
|
10132
11145
|
throw error;
|
|
10133
11146
|
}
|
|
10134
|
-
console.error(spaceTrim.spaceTrim((block) => `
|
|
11147
|
+
console.error(spaceTrim$1.spaceTrim((block) => `
|
|
10135
11148
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
10136
11149
|
|
|
10137
11150
|
${block(error.message)}
|
|
@@ -10158,7 +11171,7 @@
|
|
|
10158
11171
|
})();
|
|
10159
11172
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
10160
11173
|
// <- Note: [๐ฒ]
|
|
10161
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11174
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10162
11175
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
10163
11176
|
|
|
10164
11177
|
${block(pipelineIdentification)}
|
|
@@ -10166,7 +11179,7 @@
|
|
|
10166
11179
|
}
|
|
10167
11180
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
10168
11181
|
// <- Note: [๐ฒ]
|
|
10169
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11182
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10170
11183
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
10171
11184
|
|
|
10172
11185
|
${block(pipelineIdentification)}
|
|
@@ -10175,7 +11188,7 @@
|
|
|
10175
11188
|
// TODO: [๐ง ] Maybe do here some proper JSON-schema / ZOD checking
|
|
10176
11189
|
if (!Array.isArray(pipeline.parameters)) {
|
|
10177
11190
|
// TODO: [๐ง ] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
10178
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
11191
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
10179
11192
|
Pipeline is valid JSON but with wrong structure
|
|
10180
11193
|
|
|
10181
11194
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -10186,7 +11199,7 @@
|
|
|
10186
11199
|
// TODO: [๐ง ] Maybe do here some proper JSON-schema / ZOD checking
|
|
10187
11200
|
if (!Array.isArray(pipeline.tasks)) {
|
|
10188
11201
|
// TODO: [๐ง ] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
10189
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
11202
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
10190
11203
|
Pipeline is valid JSON but with wrong structure
|
|
10191
11204
|
|
|
10192
11205
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -10212,7 +11225,7 @@
|
|
|
10212
11225
|
// Note: Check each parameter individually
|
|
10213
11226
|
for (const parameter of pipeline.parameters) {
|
|
10214
11227
|
if (parameter.isInput && parameter.isOutput) {
|
|
10215
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11228
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10216
11229
|
|
|
10217
11230
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
10218
11231
|
|
|
@@ -10223,7 +11236,7 @@
|
|
|
10223
11236
|
if (!parameter.isInput &&
|
|
10224
11237
|
!parameter.isOutput &&
|
|
10225
11238
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
10226
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11239
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10227
11240
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
10228
11241
|
|
|
10229
11242
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -10235,7 +11248,7 @@
|
|
|
10235
11248
|
}
|
|
10236
11249
|
// Note: Testing that parameter is either input or result of some task
|
|
10237
11250
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
10238
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11251
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10239
11252
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
10240
11253
|
|
|
10241
11254
|
You can do one of these:
|
|
@@ -10251,14 +11264,14 @@
|
|
|
10251
11264
|
// Note: Checking each task individually
|
|
10252
11265
|
for (const task of pipeline.tasks) {
|
|
10253
11266
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
10254
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11267
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10255
11268
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
10256
11269
|
|
|
10257
11270
|
${block(pipelineIdentification)}
|
|
10258
11271
|
`));
|
|
10259
11272
|
}
|
|
10260
11273
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
10261
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11274
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10262
11275
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
10263
11276
|
|
|
10264
11277
|
${block(pipelineIdentification)}
|
|
@@ -10268,7 +11281,7 @@
|
|
|
10268
11281
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
10269
11282
|
if (!task.format &&
|
|
10270
11283
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
10271
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11284
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10272
11285
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
10273
11286
|
|
|
10274
11287
|
${block(pipelineIdentification)}
|
|
@@ -10276,7 +11289,7 @@
|
|
|
10276
11289
|
}
|
|
10277
11290
|
for (const joker of task.jokerParameterNames) {
|
|
10278
11291
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
10279
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11292
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10280
11293
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
10281
11294
|
|
|
10282
11295
|
${block(pipelineIdentification)}
|
|
@@ -10287,21 +11300,21 @@
|
|
|
10287
11300
|
if (task.expectations) {
|
|
10288
11301
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
10289
11302
|
if (min !== undefined && max !== undefined && min > max) {
|
|
10290
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11303
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10291
11304
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
10292
11305
|
|
|
10293
11306
|
${block(pipelineIdentification)}
|
|
10294
11307
|
`));
|
|
10295
11308
|
}
|
|
10296
11309
|
if (min !== undefined && min < 0) {
|
|
10297
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11310
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10298
11311
|
Min expectation of ${unit} must be zero or positive
|
|
10299
11312
|
|
|
10300
11313
|
${block(pipelineIdentification)}
|
|
10301
11314
|
`));
|
|
10302
11315
|
}
|
|
10303
11316
|
if (max !== undefined && max <= 0) {
|
|
10304
|
-
throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
|
|
11317
|
+
throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
|
|
10305
11318
|
Max expectation of ${unit} must be positive
|
|
10306
11319
|
|
|
10307
11320
|
${block(pipelineIdentification)}
|
|
@@ -10323,7 +11336,7 @@
|
|
|
10323
11336
|
while (unresovedTasks.length > 0) {
|
|
10324
11337
|
if (loopLimit-- < 0) {
|
|
10325
11338
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
10326
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
11339
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
10327
11340
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
10328
11341
|
|
|
10329
11342
|
${block(pipelineIdentification)}
|
|
@@ -10333,7 +11346,7 @@
|
|
|
10333
11346
|
if (currentlyResovedTasks.length === 0) {
|
|
10334
11347
|
throw new PipelineLogicError(
|
|
10335
11348
|
// TODO: [๐] DRY
|
|
10336
|
-
spaceTrim.spaceTrim((block) => `
|
|
11349
|
+
spaceTrim$1.spaceTrim((block) => `
|
|
10337
11350
|
|
|
10338
11351
|
Can not resolve some parameters:
|
|
10339
11352
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -10454,7 +11467,7 @@
|
|
|
10454
11467
|
for (const pipeline of pipelines) {
|
|
10455
11468
|
// TODO: [๐ ] DRY
|
|
10456
11469
|
if (pipeline.pipelineUrl === undefined) {
|
|
10457
|
-
throw new PipelineUrlError(spaceTrim.spaceTrim(`
|
|
11470
|
+
throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
|
|
10458
11471
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
10459
11472
|
|
|
10460
11473
|
File:
|
|
@@ -10476,7 +11489,7 @@
|
|
|
10476
11489
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
10477
11490
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
10478
11491
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
10479
|
-
throw new PipelineUrlError(spaceTrim.spaceTrim(`
|
|
11492
|
+
throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
|
|
10480
11493
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection ๐
|
|
10481
11494
|
|
|
10482
11495
|
Conflicting files:
|
|
@@ -10508,13 +11521,13 @@
|
|
|
10508
11521
|
const pipeline = this.collection.get(url);
|
|
10509
11522
|
if (!pipeline) {
|
|
10510
11523
|
if (this.listPipelines().length === 0) {
|
|
10511
|
-
throw new NotFoundError(spaceTrim.spaceTrim(`
|
|
11524
|
+
throw new NotFoundError(spaceTrim$1.spaceTrim(`
|
|
10512
11525
|
Pipeline with url "${url}" not found
|
|
10513
11526
|
|
|
10514
11527
|
No pipelines available
|
|
10515
11528
|
`));
|
|
10516
11529
|
}
|
|
10517
|
-
throw new NotFoundError(spaceTrim.spaceTrim((block) => `
|
|
11530
|
+
throw new NotFoundError(spaceTrim$1.spaceTrim((block) => `
|
|
10518
11531
|
Pipeline with url "${url}" not found
|
|
10519
11532
|
|
|
10520
11533
|
Available pipelines:
|
|
@@ -10613,11 +11626,11 @@
|
|
|
10613
11626
|
throw deserializeError(errors[0]);
|
|
10614
11627
|
}
|
|
10615
11628
|
else {
|
|
10616
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
11629
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
10617
11630
|
Multiple errors occurred during Promptbook execution
|
|
10618
11631
|
|
|
10619
11632
|
${block(errors
|
|
10620
|
-
.map(({ name, stack, message }, index) => spaceTrim.spaceTrim((block) => `
|
|
11633
|
+
.map(({ name, stack, message }, index) => spaceTrim$1.spaceTrim((block) => `
|
|
10621
11634
|
${name} ${index + 1}:
|
|
10622
11635
|
${block(stack || message)}
|
|
10623
11636
|
`))
|
|
@@ -11636,7 +12649,7 @@
|
|
|
11636
12649
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
11637
12650
|
knowledgePiecesCount > 0 &&
|
|
11638
12651
|
!dependentParameterNames.includes('knowledge')) {
|
|
11639
|
-
preparedContent = spaceTrim.spaceTrim(`
|
|
12652
|
+
preparedContent = spaceTrim$1.spaceTrim(`
|
|
11640
12653
|
{content}
|
|
11641
12654
|
|
|
11642
12655
|
## Knowledge
|
|
@@ -11868,7 +12881,7 @@
|
|
|
11868
12881
|
}
|
|
11869
12882
|
catch (error) {
|
|
11870
12883
|
assertsError(error);
|
|
11871
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
12884
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
11872
12885
|
Can not extract variables from the script
|
|
11873
12886
|
${block(error.stack || error.message)}
|
|
11874
12887
|
|
|
@@ -12411,7 +13424,7 @@
|
|
|
12411
13424
|
}
|
|
12412
13425
|
catch (error) {
|
|
12413
13426
|
keepUnused(error);
|
|
12414
|
-
throw new ExpectError(spaceTrim.spaceTrim((block) => `
|
|
13427
|
+
throw new ExpectError(spaceTrim$1.spaceTrim((block) => `
|
|
12415
13428
|
Expected valid JSON string
|
|
12416
13429
|
|
|
12417
13430
|
The expected JSON text:
|
|
@@ -12474,7 +13487,7 @@
|
|
|
12474
13487
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
12475
13488
|
// TODO: [๐ง ][๐ญ] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
12476
13489
|
if (isJokerAttempt && !jokerParameterName) {
|
|
12477
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
13490
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
12478
13491
|
Joker not found in attempt ${attemptIndex}
|
|
12479
13492
|
|
|
12480
13493
|
${block(pipelineIdentification)}
|
|
@@ -12485,7 +13498,7 @@
|
|
|
12485
13498
|
$ongoingTaskResult.$expectError = null;
|
|
12486
13499
|
if (isJokerAttempt) {
|
|
12487
13500
|
if (parameters[jokerParameterName] === undefined) {
|
|
12488
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
13501
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
12489
13502
|
Joker parameter {${jokerParameterName}} not defined
|
|
12490
13503
|
|
|
12491
13504
|
${block(pipelineIdentification)}
|
|
@@ -12543,7 +13556,7 @@
|
|
|
12543
13556
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
12544
13557
|
break variant;
|
|
12545
13558
|
case 'EMBEDDING':
|
|
12546
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
13559
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
12547
13560
|
Embedding model can not be used in pipeline
|
|
12548
13561
|
|
|
12549
13562
|
This should be catched during parsing
|
|
@@ -12554,7 +13567,7 @@
|
|
|
12554
13567
|
break variant;
|
|
12555
13568
|
// <- case [๐ค]:
|
|
12556
13569
|
default:
|
|
12557
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
13570
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
12558
13571
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
12559
13572
|
|
|
12560
13573
|
${block(pipelineIdentification)}
|
|
@@ -12565,14 +13578,14 @@
|
|
|
12565
13578
|
break;
|
|
12566
13579
|
case 'SCRIPT_TASK':
|
|
12567
13580
|
if (arrayableToArray(tools.script).length === 0) {
|
|
12568
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
13581
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
12569
13582
|
No script execution tools are available
|
|
12570
13583
|
|
|
12571
13584
|
${block(pipelineIdentification)}
|
|
12572
13585
|
`));
|
|
12573
13586
|
}
|
|
12574
13587
|
if (!task.contentLanguage) {
|
|
12575
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
13588
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
12576
13589
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
12577
13590
|
|
|
12578
13591
|
${block(pipelineIdentification)}
|
|
@@ -12603,7 +13616,7 @@
|
|
|
12603
13616
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
12604
13617
|
}
|
|
12605
13618
|
else {
|
|
12606
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
13619
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
12607
13620
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
12608
13621
|
|
|
12609
13622
|
${block(pipelineIdentification)}
|
|
@@ -12617,7 +13630,7 @@
|
|
|
12617
13630
|
break taskType;
|
|
12618
13631
|
case 'DIALOG_TASK':
|
|
12619
13632
|
if (tools.userInterface === undefined) {
|
|
12620
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
13633
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
12621
13634
|
User interface tools are not available
|
|
12622
13635
|
|
|
12623
13636
|
${block(pipelineIdentification)}
|
|
@@ -12635,7 +13648,7 @@
|
|
|
12635
13648
|
break taskType;
|
|
12636
13649
|
// <- case: [๐
ฑ]
|
|
12637
13650
|
default:
|
|
12638
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
13651
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
12639
13652
|
Unknown execution type "${task.taskType}"
|
|
12640
13653
|
|
|
12641
13654
|
${block(pipelineIdentification)}
|
|
@@ -12733,7 +13746,7 @@
|
|
|
12733
13746
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
12734
13747
|
// Note: Create a summary of all failures
|
|
12735
13748
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
12736
|
-
.map((failure) => spaceTrim.spaceTrim((block) => {
|
|
13749
|
+
.map((failure) => spaceTrim$1.spaceTrim((block) => {
|
|
12737
13750
|
var _a, _b;
|
|
12738
13751
|
return `
|
|
12739
13752
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -12743,14 +13756,14 @@
|
|
|
12743
13756
|
Result:
|
|
12744
13757
|
${block(failure.result === null
|
|
12745
13758
|
? 'null'
|
|
12746
|
-
: spaceTrim.spaceTrim(failure.result)
|
|
13759
|
+
: spaceTrim$1.spaceTrim(failure.result)
|
|
12747
13760
|
.split('\n')
|
|
12748
13761
|
.map((line) => `> ${line}`)
|
|
12749
13762
|
.join('\n'))}
|
|
12750
13763
|
`;
|
|
12751
13764
|
}))
|
|
12752
13765
|
.join('\n\n---\n\n');
|
|
12753
|
-
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
|
|
13766
|
+
throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => {
|
|
12754
13767
|
var _a;
|
|
12755
13768
|
return `
|
|
12756
13769
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -12770,7 +13783,7 @@
|
|
|
12770
13783
|
}
|
|
12771
13784
|
}
|
|
12772
13785
|
if ($ongoingTaskResult.$resultString === null) {
|
|
12773
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
13786
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
12774
13787
|
Something went wrong and prompt result is null
|
|
12775
13788
|
|
|
12776
13789
|
${block(pipelineIdentification)}
|
|
@@ -13076,7 +14089,7 @@
|
|
|
13076
14089
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
13077
14090
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
13078
14091
|
if (reservedParameters[parameterName] === undefined) {
|
|
13079
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
14092
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
13080
14093
|
Reserved parameter {${parameterName}} is not defined
|
|
13081
14094
|
|
|
13082
14095
|
${block(pipelineIdentification)}
|
|
@@ -13102,7 +14115,7 @@
|
|
|
13102
14115
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
13103
14116
|
// TODO: [๐ฉ๐พโ๐คโ๐ฉ๐ป] Use here `mapAvailableToExpectedParameters`
|
|
13104
14117
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
13105
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
14118
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
13106
14119
|
Dependent parameters are not consistent with used parameters:
|
|
13107
14120
|
|
|
13108
14121
|
Dependent parameters:
|
|
@@ -13146,7 +14159,7 @@
|
|
|
13146
14159
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
13147
14160
|
// Houston, we have a problem
|
|
13148
14161
|
// Note: Checking part is also done in `validatePipeline`, but itโs good to doublecheck
|
|
13149
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
14162
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
13150
14163
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
13151
14164
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
13152
14165
|
|
|
@@ -13215,7 +14228,7 @@
|
|
|
13215
14228
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
13216
14229
|
if (parametersToPass[parameter.name] === undefined) {
|
|
13217
14230
|
// [4]
|
|
13218
|
-
$warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
14231
|
+
$warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
13219
14232
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
13220
14233
|
|
|
13221
14234
|
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
@@ -13323,7 +14336,7 @@
|
|
|
13323
14336
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
13324
14337
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
13325
14338
|
if (parameter === undefined) {
|
|
13326
|
-
warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
14339
|
+
warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
13327
14340
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
13328
14341
|
|
|
13329
14342
|
${block(pipelineIdentification)}
|
|
@@ -13338,7 +14351,7 @@
|
|
|
13338
14351
|
// TODO: [๐ง ] This should be also non-critical error
|
|
13339
14352
|
return exportJson({
|
|
13340
14353
|
name: 'pipelineExecutorResult',
|
|
13341
|
-
message: spaceTrim.spaceTrim((block) => `
|
|
14354
|
+
message: spaceTrim$1.spaceTrim((block) => `
|
|
13342
14355
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
13343
14356
|
|
|
13344
14357
|
${block(pipelineIdentification)}
|
|
@@ -13347,7 +14360,7 @@
|
|
|
13347
14360
|
value: {
|
|
13348
14361
|
isSuccessful: false,
|
|
13349
14362
|
errors: [
|
|
13350
|
-
new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
|
|
14363
|
+
new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
|
|
13351
14364
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
13352
14365
|
|
|
13353
14366
|
${block(pipelineIdentification)}
|
|
@@ -13374,7 +14387,7 @@
|
|
|
13374
14387
|
while (unresovedTasks.length > 0) {
|
|
13375
14388
|
if (loopLimit-- < 0) {
|
|
13376
14389
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
13377
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
14390
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
13378
14391
|
Loop limit reached during resolving parameters pipeline execution
|
|
13379
14392
|
|
|
13380
14393
|
${block(pipelineIdentification)}
|
|
@@ -13384,7 +14397,7 @@
|
|
|
13384
14397
|
if (!currentTask && resolving.length === 0) {
|
|
13385
14398
|
throw new UnexpectedError(
|
|
13386
14399
|
// TODO: [๐] DRY
|
|
13387
|
-
spaceTrim.spaceTrim((block) => `
|
|
14400
|
+
spaceTrim$1.spaceTrim((block) => `
|
|
13388
14401
|
Can not resolve some parameters:
|
|
13389
14402
|
|
|
13390
14403
|
${block(pipelineIdentification)}
|
|
@@ -13424,7 +14437,7 @@
|
|
|
13424
14437
|
tools,
|
|
13425
14438
|
onProgress(newOngoingResult) {
|
|
13426
14439
|
if (isReturned) {
|
|
13427
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
14440
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
13428
14441
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
13429
14442
|
|
|
13430
14443
|
${block(pipelineIdentification)}
|
|
@@ -13441,7 +14454,7 @@
|
|
|
13441
14454
|
},
|
|
13442
14455
|
logLlmCall,
|
|
13443
14456
|
$executionReport: executionReport,
|
|
13444
|
-
pipelineIdentification: spaceTrim.spaceTrim((block) => `
|
|
14457
|
+
pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
|
|
13445
14458
|
${block(pipelineIdentification)}
|
|
13446
14459
|
Task name: ${currentTask.name}
|
|
13447
14460
|
Task title: ${currentTask.title}
|
|
@@ -13550,7 +14563,7 @@
|
|
|
13550
14563
|
preparedPipeline = pipeline;
|
|
13551
14564
|
}
|
|
13552
14565
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
13553
|
-
console.warn(spaceTrim.spaceTrim((block) => `
|
|
14566
|
+
console.warn(spaceTrim$1.spaceTrim((block) => `
|
|
13554
14567
|
Pipeline is not prepared
|
|
13555
14568
|
|
|
13556
14569
|
${block(pipelineIdentification)}
|
|
@@ -13575,7 +14588,7 @@
|
|
|
13575
14588
|
tools,
|
|
13576
14589
|
onProgress,
|
|
13577
14590
|
logLlmCall,
|
|
13578
|
-
pipelineIdentification: spaceTrim.spaceTrim((block) => `
|
|
14591
|
+
pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
|
|
13579
14592
|
${block(pipelineIdentification)}
|
|
13580
14593
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
13581
14594
|
`),
|
|
@@ -15513,18 +16526,26 @@
|
|
|
15513
16526
|
modelName: 'assistant',
|
|
15514
16527
|
// <- [๐ง ] What is the best value here
|
|
15515
16528
|
});
|
|
16529
|
+
// Build thread messages: include previous thread messages + current user message
|
|
16530
|
+
const threadMessages = [];
|
|
16531
|
+
// TODO: [๐น] Maybe this should not be here but in other place, look at commit 39d705e75e5bcf7a818c3af36bc13e1c8475c30c
|
|
16532
|
+
// Add previous messages from thread (if any)
|
|
16533
|
+
if ('thread' in prompt &&
|
|
16534
|
+
Array.isArray(prompt.thread)) {
|
|
16535
|
+
const previousMessages = prompt.thread.map((msg) => ({
|
|
16536
|
+
role: (msg.role === 'assistant' ? 'assistant' : 'user'),
|
|
16537
|
+
content: msg.content,
|
|
16538
|
+
}));
|
|
16539
|
+
threadMessages.push(...previousMessages);
|
|
16540
|
+
}
|
|
16541
|
+
// Always add the current user message
|
|
16542
|
+
threadMessages.push({ role: 'user', content: rawPromptContent });
|
|
15516
16543
|
const rawRequest = {
|
|
15517
16544
|
// TODO: [๐จโ๐จโ๐งโ๐ง] ...modelSettings,
|
|
15518
16545
|
// TODO: [๐จโ๐จโ๐งโ๐ง][๐ง ] What about system message for assistants, does it make sense - combination of OpenAI assistants with Promptbook Personas
|
|
15519
16546
|
assistant_id: this.assistantId,
|
|
15520
16547
|
thread: {
|
|
15521
|
-
messages:
|
|
15522
|
-
Array.isArray(prompt.thread)
|
|
15523
|
-
? prompt.thread.map((msg) => ({
|
|
15524
|
-
role: msg.role === 'assistant' ? 'assistant' : 'user',
|
|
15525
|
-
content: msg.content,
|
|
15526
|
-
}))
|
|
15527
|
-
: [{ role: 'user', content: rawPromptContent }],
|
|
16548
|
+
messages: threadMessages,
|
|
15528
16549
|
},
|
|
15529
16550
|
// <- TODO: Add user identification here> user: this.options.user,
|
|
15530
16551
|
};
|
|
@@ -15544,7 +16565,7 @@
|
|
|
15544
16565
|
console.info('textDelta', textDelta.value);
|
|
15545
16566
|
}
|
|
15546
16567
|
const chunk = {
|
|
15547
|
-
content:
|
|
16568
|
+
content: snapshot.value,
|
|
15548
16569
|
modelName: 'assistant',
|
|
15549
16570
|
timing: {
|
|
15550
16571
|
start,
|
|
@@ -16165,6 +17186,7 @@
|
|
|
16165
17186
|
* Note: This method also implements the learning mechanism
|
|
16166
17187
|
*/
|
|
16167
17188
|
async callChatModelStream(prompt, onProgress) {
|
|
17189
|
+
var _a;
|
|
16168
17190
|
// [1] Check if the user is asking the same thing as in the samples
|
|
16169
17191
|
const modelRequirements = await this.getAgentModelRequirements();
|
|
16170
17192
|
if (modelRequirements.samples) {
|
|
@@ -16212,6 +17234,9 @@
|
|
|
16212
17234
|
if (result.rawResponse && 'sample' in result.rawResponse) {
|
|
16213
17235
|
return result;
|
|
16214
17236
|
}
|
|
17237
|
+
if ((_a = modelRequirements.metadata) === null || _a === void 0 ? void 0 : _a.isClosed) {
|
|
17238
|
+
return result;
|
|
17239
|
+
}
|
|
16215
17240
|
// TODO: !!! Extract learning to separate method
|
|
16216
17241
|
// Learning: Append the conversation sample to the agent source
|
|
16217
17242
|
const learningExample = spaceTrim__default["default"]((block) => `
|