@promptbook/core 0.103.0-42 → 0.103.0-44
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/README.md +6 -18
- package/esm/index.es.js +704 -372
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +6 -0
- package/esm/typings/src/_packages/node.index.d.ts +0 -2
- package/esm/typings/src/_packages/types.index.d.ts +22 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -4
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +1 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +6 -1
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +1 -1
- package/esm/typings/src/book-components/Qr/useQrCode.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/login.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/start-agents-server.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +1 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +2 -29
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +107 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +129 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/errors/0-index.d.ts +3 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -1
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +5 -2
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +4 -2
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +4 -3
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
- package/esm/typings/src/remote-server/startAgentServer.d.ts +2 -2
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +0 -19
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +1 -1
- package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +5 -1
- package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +1 -1
- package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +1 -1
- package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +4 -1
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +1 -1
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +4 -1
- package/esm/typings/src/transpilers/openai-sdk/register.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +19 -1
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +1 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -1
- package/esm/typings/src/utils/files/$induceBookDownload.d.ts +2 -2
- package/esm/typings/src/utils/files/$induceFileDownload.d.ts +2 -2
- package/esm/typings/src/utils/files/ObjectUrl.d.ts +1 -1
- package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +6 -0
- package/esm/typings/src/utils/organization/$side_effect.d.ts +1 -1
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +25 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
- package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +627 -292
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.d.ts +0 -89
- package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.test.d.ts +0 -1
- package/esm/typings/src/commands/_common/parseCommand.test.d.ts +0 -1
- package/esm/typings/src/execution/utils/logLlmCall.d.ts +0 -8
package/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import spaceTrim, { spaceTrim as spaceTrim$
|
|
1
|
+
import spaceTrim$1, { spaceTrim as spaceTrim$2 } from 'spacetrim';
|
|
2
2
|
import { randomBytes } from 'crypto';
|
|
3
3
|
import { Subject, BehaviorSubject } from 'rxjs';
|
|
4
4
|
import { forTime, forEver } from 'waitasecond';
|
|
@@ -20,14 +20,14 @@ import OpenAI from 'openai';
|
|
|
20
20
|
* @generated
|
|
21
21
|
* @see https://github.com/webgptorg/book
|
|
22
22
|
*/
|
|
23
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
23
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
24
24
|
/**
|
|
25
25
|
* The version of the Promptbook engine
|
|
26
26
|
*
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-44';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -841,6 +841,23 @@ class Color {
|
|
|
841
841
|
* TODO: Maybe connect with textures
|
|
842
842
|
*/
|
|
843
843
|
|
|
844
|
+
/**
|
|
845
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
846
|
+
*
|
|
847
|
+
* @param amount from 0 to 1
|
|
848
|
+
*
|
|
849
|
+
* @public exported from `@promptbook/color`
|
|
850
|
+
*/
|
|
851
|
+
function grayscale(amount) {
|
|
852
|
+
return ({ red, green, blue, alpha }) => {
|
|
853
|
+
const average = (red + green + blue) / 3;
|
|
854
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
855
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
856
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
857
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
|
|
844
861
|
/**
|
|
845
862
|
* Converts HSL values to RGB values
|
|
846
863
|
*
|
|
@@ -956,102 +973,6 @@ function lighten(amount) {
|
|
|
956
973
|
* TODO: Maybe implement by mix+hsl
|
|
957
974
|
*/
|
|
958
975
|
|
|
959
|
-
/**
|
|
960
|
-
* Calculates distance between two colors
|
|
961
|
-
*
|
|
962
|
-
* @param color1 first color
|
|
963
|
-
* @param color2 second color
|
|
964
|
-
*
|
|
965
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
966
|
-
*
|
|
967
|
-
* @public exported from `@promptbook/color`
|
|
968
|
-
*/
|
|
969
|
-
/**
|
|
970
|
-
* Calculates distance between two colors without square root
|
|
971
|
-
*
|
|
972
|
-
* @param color1 first color
|
|
973
|
-
* @param color2 second color
|
|
974
|
-
*
|
|
975
|
-
* @public exported from `@promptbook/color`
|
|
976
|
-
*/
|
|
977
|
-
function colorDistanceSquared(color1, color2) {
|
|
978
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
979
|
-
const r = color1.red - color2.red;
|
|
980
|
-
const g = color1.green - color2.green;
|
|
981
|
-
const b = color1.blue - color2.blue;
|
|
982
|
-
const weightR = 2 + rmean / 256;
|
|
983
|
-
const weightG = 4.0;
|
|
984
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
985
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
986
|
-
return distance;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
/**
|
|
990
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
991
|
-
*
|
|
992
|
-
* @param colors array of colors to choose from
|
|
993
|
-
*
|
|
994
|
-
* @public exported from `@promptbook/color`
|
|
995
|
-
*/
|
|
996
|
-
function nearest(...colors) {
|
|
997
|
-
return (color) => {
|
|
998
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
999
|
-
const minDistance = Math.min(...distances);
|
|
1000
|
-
const minIndex = distances.indexOf(minDistance);
|
|
1001
|
-
const nearestColor = colors[minIndex];
|
|
1002
|
-
return nearestColor;
|
|
1003
|
-
};
|
|
1004
|
-
}
|
|
1005
|
-
|
|
1006
|
-
/**
|
|
1007
|
-
* Color transformer which returns the negative color
|
|
1008
|
-
*
|
|
1009
|
-
* @public exported from `@promptbook/color`
|
|
1010
|
-
*/
|
|
1011
|
-
function negative(color) {
|
|
1012
|
-
const r = 255 - color.red;
|
|
1013
|
-
const g = 255 - color.green;
|
|
1014
|
-
const b = 255 - color.blue;
|
|
1015
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
/**
|
|
1019
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
1020
|
-
*
|
|
1021
|
-
* @param colors array of colors to choose from
|
|
1022
|
-
*
|
|
1023
|
-
* @public exported from `@promptbook/color`
|
|
1024
|
-
*/
|
|
1025
|
-
function furthest(...colors) {
|
|
1026
|
-
return (color) => {
|
|
1027
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
1028
|
-
return furthestColor;
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
1033
|
-
*
|
|
1034
|
-
* @public exported from `@promptbook/color`
|
|
1035
|
-
*/
|
|
1036
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
1037
|
-
|
|
1038
|
-
/**
|
|
1039
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
1040
|
-
*
|
|
1041
|
-
* @param amount from 0 to 1
|
|
1042
|
-
*
|
|
1043
|
-
* @public exported from `@promptbook/color`
|
|
1044
|
-
*/
|
|
1045
|
-
function grayscale(amount) {
|
|
1046
|
-
return ({ red, green, blue, alpha }) => {
|
|
1047
|
-
const average = (red + green + blue) / 3;
|
|
1048
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
1049
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
1050
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
1051
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
1052
|
-
};
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
976
|
/**
|
|
1056
977
|
* Makes color transformer which saturate the given color
|
|
1057
978
|
*
|
|
@@ -1461,6 +1382,19 @@ const IS_PIPELINE_LOGIC_VALIDATED = just(
|
|
|
1461
1382
|
/**/
|
|
1462
1383
|
// Note: In normal situations, we check the pipeline logic:
|
|
1463
1384
|
true);
|
|
1385
|
+
/**
|
|
1386
|
+
* Indicates whether cost-prevention is enabled. When true, real API keys are prevented from being used in tests.
|
|
1387
|
+
*
|
|
1388
|
+
* @private within the repository
|
|
1389
|
+
*/
|
|
1390
|
+
const IS_COST_PREVENTED = just(
|
|
1391
|
+
/*/
|
|
1392
|
+
// Note: In normal situations, we prevent ability to use real API keys in tests:
|
|
1393
|
+
true,
|
|
1394
|
+
/**/
|
|
1395
|
+
/**/
|
|
1396
|
+
// When working on preparations, you can temporarily turn off the prevention:
|
|
1397
|
+
false);
|
|
1464
1398
|
/**
|
|
1465
1399
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1466
1400
|
* TODO: [🧠][🧜♂️] Maybe join remoteServerUrl and path into single value
|
|
@@ -1474,7 +1408,7 @@ true);
|
|
|
1474
1408
|
function getErrorReportUrl(error) {
|
|
1475
1409
|
const report = {
|
|
1476
1410
|
title: `🐜 Error report from ${NAME}`,
|
|
1477
|
-
body: spaceTrim((block) => `
|
|
1411
|
+
body: spaceTrim$1((block) => `
|
|
1478
1412
|
|
|
1479
1413
|
|
|
1480
1414
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1517,7 +1451,7 @@ function getErrorReportUrl(error) {
|
|
|
1517
1451
|
*/
|
|
1518
1452
|
class UnexpectedError extends Error {
|
|
1519
1453
|
constructor(message) {
|
|
1520
|
-
super(spaceTrim$
|
|
1454
|
+
super(spaceTrim$2((block) => `
|
|
1521
1455
|
${block(message)}
|
|
1522
1456
|
|
|
1523
1457
|
Note: This error should not happen.
|
|
@@ -1543,7 +1477,7 @@ class WrappedError extends Error {
|
|
|
1543
1477
|
constructor(whatWasThrown) {
|
|
1544
1478
|
const tag = `[🤮]`;
|
|
1545
1479
|
console.error(tag, whatWasThrown);
|
|
1546
|
-
super(spaceTrim$
|
|
1480
|
+
super(spaceTrim$2(`
|
|
1547
1481
|
Non-Error object was thrown
|
|
1548
1482
|
|
|
1549
1483
|
Note: Look for ${tag} in the console for more details
|
|
@@ -1767,7 +1701,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
1767
1701
|
pipelineString += '\n\n';
|
|
1768
1702
|
pipelineString += '```' + contentLanguage;
|
|
1769
1703
|
pipelineString += '\n';
|
|
1770
|
-
pipelineString += spaceTrim(content);
|
|
1704
|
+
pipelineString += spaceTrim$1(content);
|
|
1771
1705
|
// <- TODO: [main] !!3 Escape
|
|
1772
1706
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
1773
1707
|
pipelineString += '\n';
|
|
@@ -1888,7 +1822,7 @@ function checkSerializableAsJson(options) {
|
|
|
1888
1822
|
}
|
|
1889
1823
|
else if (typeof value === 'object') {
|
|
1890
1824
|
if (value instanceof Date) {
|
|
1891
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1825
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1892
1826
|
\`${name}\` is Date
|
|
1893
1827
|
|
|
1894
1828
|
Use \`string_date_iso8601\` instead
|
|
@@ -1907,7 +1841,7 @@ function checkSerializableAsJson(options) {
|
|
|
1907
1841
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
1908
1842
|
}
|
|
1909
1843
|
else if (value instanceof Error) {
|
|
1910
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1844
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1911
1845
|
\`${name}\` is unserialized Error
|
|
1912
1846
|
|
|
1913
1847
|
Use function \`serializeError\`
|
|
@@ -1930,7 +1864,7 @@ function checkSerializableAsJson(options) {
|
|
|
1930
1864
|
}
|
|
1931
1865
|
catch (error) {
|
|
1932
1866
|
assertsError(error);
|
|
1933
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1867
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1934
1868
|
\`${name}\` is not serializable
|
|
1935
1869
|
|
|
1936
1870
|
${block(error.stack || error.message)}
|
|
@@ -1962,7 +1896,7 @@ function checkSerializableAsJson(options) {
|
|
|
1962
1896
|
}
|
|
1963
1897
|
}
|
|
1964
1898
|
else {
|
|
1965
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1899
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1966
1900
|
\`${name}\` is unknown type
|
|
1967
1901
|
|
|
1968
1902
|
Additional message for \`${name}\`:
|
|
@@ -2256,7 +2190,7 @@ function validatePipeline(pipeline) {
|
|
|
2256
2190
|
if (!(error instanceof PipelineLogicError)) {
|
|
2257
2191
|
throw error;
|
|
2258
2192
|
}
|
|
2259
|
-
console.error(spaceTrim$
|
|
2193
|
+
console.error(spaceTrim$2((block) => `
|
|
2260
2194
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
2261
2195
|
|
|
2262
2196
|
${block(error.message)}
|
|
@@ -2283,7 +2217,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2283
2217
|
})();
|
|
2284
2218
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
2285
2219
|
// <- Note: [🚲]
|
|
2286
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2220
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2287
2221
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
2288
2222
|
|
|
2289
2223
|
${block(pipelineIdentification)}
|
|
@@ -2291,7 +2225,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2291
2225
|
}
|
|
2292
2226
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
2293
2227
|
// <- Note: [🚲]
|
|
2294
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2228
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2295
2229
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
2296
2230
|
|
|
2297
2231
|
${block(pipelineIdentification)}
|
|
@@ -2300,7 +2234,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2300
2234
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2301
2235
|
if (!Array.isArray(pipeline.parameters)) {
|
|
2302
2236
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2303
|
-
throw new ParseError(spaceTrim$
|
|
2237
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
2304
2238
|
Pipeline is valid JSON but with wrong structure
|
|
2305
2239
|
|
|
2306
2240
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -2311,7 +2245,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2311
2245
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2312
2246
|
if (!Array.isArray(pipeline.tasks)) {
|
|
2313
2247
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2314
|
-
throw new ParseError(spaceTrim$
|
|
2248
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
2315
2249
|
Pipeline is valid JSON but with wrong structure
|
|
2316
2250
|
|
|
2317
2251
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -2337,7 +2271,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2337
2271
|
// Note: Check each parameter individually
|
|
2338
2272
|
for (const parameter of pipeline.parameters) {
|
|
2339
2273
|
if (parameter.isInput && parameter.isOutput) {
|
|
2340
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2274
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2341
2275
|
|
|
2342
2276
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
2343
2277
|
|
|
@@ -2348,7 +2282,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2348
2282
|
if (!parameter.isInput &&
|
|
2349
2283
|
!parameter.isOutput &&
|
|
2350
2284
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
2351
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2285
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2352
2286
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
2353
2287
|
|
|
2354
2288
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -2360,7 +2294,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2360
2294
|
}
|
|
2361
2295
|
// Note: Testing that parameter is either input or result of some task
|
|
2362
2296
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
2363
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2297
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2364
2298
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
2365
2299
|
|
|
2366
2300
|
You can do one of these:
|
|
@@ -2376,14 +2310,14 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2376
2310
|
// Note: Checking each task individually
|
|
2377
2311
|
for (const task of pipeline.tasks) {
|
|
2378
2312
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
2379
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2313
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2380
2314
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
2381
2315
|
|
|
2382
2316
|
${block(pipelineIdentification)}
|
|
2383
2317
|
`));
|
|
2384
2318
|
}
|
|
2385
2319
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
2386
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2320
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2387
2321
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
2388
2322
|
|
|
2389
2323
|
${block(pipelineIdentification)}
|
|
@@ -2393,7 +2327,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2393
2327
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
2394
2328
|
if (!task.format &&
|
|
2395
2329
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
2396
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2330
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2397
2331
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
2398
2332
|
|
|
2399
2333
|
${block(pipelineIdentification)}
|
|
@@ -2401,7 +2335,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2401
2335
|
}
|
|
2402
2336
|
for (const joker of task.jokerParameterNames) {
|
|
2403
2337
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
2404
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2338
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2405
2339
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
2406
2340
|
|
|
2407
2341
|
${block(pipelineIdentification)}
|
|
@@ -2412,21 +2346,21 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2412
2346
|
if (task.expectations) {
|
|
2413
2347
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
2414
2348
|
if (min !== undefined && max !== undefined && min > max) {
|
|
2415
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2349
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2416
2350
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
2417
2351
|
|
|
2418
2352
|
${block(pipelineIdentification)}
|
|
2419
2353
|
`));
|
|
2420
2354
|
}
|
|
2421
2355
|
if (min !== undefined && min < 0) {
|
|
2422
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2356
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2423
2357
|
Min expectation of ${unit} must be zero or positive
|
|
2424
2358
|
|
|
2425
2359
|
${block(pipelineIdentification)}
|
|
2426
2360
|
`));
|
|
2427
2361
|
}
|
|
2428
2362
|
if (max !== undefined && max <= 0) {
|
|
2429
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2363
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2430
2364
|
Max expectation of ${unit} must be positive
|
|
2431
2365
|
|
|
2432
2366
|
${block(pipelineIdentification)}
|
|
@@ -2448,7 +2382,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2448
2382
|
while (unresovedTasks.length > 0) {
|
|
2449
2383
|
if (loopLimit-- < 0) {
|
|
2450
2384
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
2451
|
-
throw new UnexpectedError(spaceTrim$
|
|
2385
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2452
2386
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
2453
2387
|
|
|
2454
2388
|
${block(pipelineIdentification)}
|
|
@@ -2458,7 +2392,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2458
2392
|
if (currentlyResovedTasks.length === 0) {
|
|
2459
2393
|
throw new PipelineLogicError(
|
|
2460
2394
|
// TODO: [🐎] DRY
|
|
2461
|
-
spaceTrim$
|
|
2395
|
+
spaceTrim$2((block) => `
|
|
2462
2396
|
|
|
2463
2397
|
Can not resolve some parameters:
|
|
2464
2398
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -2622,7 +2556,7 @@ class SimplePipelineCollection {
|
|
|
2622
2556
|
for (const pipeline of pipelines) {
|
|
2623
2557
|
// TODO: [👠] DRY
|
|
2624
2558
|
if (pipeline.pipelineUrl === undefined) {
|
|
2625
|
-
throw new PipelineUrlError(spaceTrim$
|
|
2559
|
+
throw new PipelineUrlError(spaceTrim$2(`
|
|
2626
2560
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
2627
2561
|
|
|
2628
2562
|
File:
|
|
@@ -2644,7 +2578,7 @@ class SimplePipelineCollection {
|
|
|
2644
2578
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
2645
2579
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
2646
2580
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
2647
|
-
throw new PipelineUrlError(spaceTrim$
|
|
2581
|
+
throw new PipelineUrlError(spaceTrim$2(`
|
|
2648
2582
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
2649
2583
|
|
|
2650
2584
|
Conflicting files:
|
|
@@ -2676,13 +2610,13 @@ class SimplePipelineCollection {
|
|
|
2676
2610
|
const pipeline = this.collection.get(url);
|
|
2677
2611
|
if (!pipeline) {
|
|
2678
2612
|
if (this.listPipelines().length === 0) {
|
|
2679
|
-
throw new NotFoundError(spaceTrim$
|
|
2613
|
+
throw new NotFoundError(spaceTrim$2(`
|
|
2680
2614
|
Pipeline with url "${url}" not found
|
|
2681
2615
|
|
|
2682
2616
|
No pipelines available
|
|
2683
2617
|
`));
|
|
2684
2618
|
}
|
|
2685
|
-
throw new NotFoundError(spaceTrim$
|
|
2619
|
+
throw new NotFoundError(spaceTrim$2((block) => `
|
|
2686
2620
|
Pipeline with url "${url}" not found
|
|
2687
2621
|
|
|
2688
2622
|
Available pipelines:
|
|
@@ -2723,7 +2657,7 @@ function createPipelineCollectionFromJson(...promptbooks) {
|
|
|
2723
2657
|
*/
|
|
2724
2658
|
class MissingToolsError extends Error {
|
|
2725
2659
|
constructor(message) {
|
|
2726
|
-
super(spaceTrim$
|
|
2660
|
+
super(spaceTrim$2((block) => `
|
|
2727
2661
|
${block(message)}
|
|
2728
2662
|
|
|
2729
2663
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -2830,6 +2764,22 @@ class CollectionError extends Error {
|
|
|
2830
2764
|
}
|
|
2831
2765
|
}
|
|
2832
2766
|
|
|
2767
|
+
/**
|
|
2768
|
+
* This error indicates error from the database
|
|
2769
|
+
*
|
|
2770
|
+
* @public exported from `@promptbook/core`
|
|
2771
|
+
*/
|
|
2772
|
+
class DatabaseError extends Error {
|
|
2773
|
+
constructor(message) {
|
|
2774
|
+
super(message);
|
|
2775
|
+
this.name = 'DatabaseError';
|
|
2776
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
/**
|
|
2780
|
+
* TODO: !!!! Explain that NotFoundError (!!! and other specific errors) has priority over DatabaseError in some contexts
|
|
2781
|
+
*/
|
|
2782
|
+
|
|
2833
2783
|
/**
|
|
2834
2784
|
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
2835
2785
|
*
|
|
@@ -2905,7 +2855,7 @@ class NotAllowed extends Error {
|
|
|
2905
2855
|
*/
|
|
2906
2856
|
class NotYetImplementedError extends Error {
|
|
2907
2857
|
constructor(message) {
|
|
2908
|
-
super(spaceTrim$
|
|
2858
|
+
super(spaceTrim$2((block) => `
|
|
2909
2859
|
${block(message)}
|
|
2910
2860
|
|
|
2911
2861
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -2924,6 +2874,7 @@ class NotYetImplementedError extends Error {
|
|
|
2924
2874
|
/**
|
|
2925
2875
|
* Generates random token
|
|
2926
2876
|
*
|
|
2877
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
2927
2878
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2928
2879
|
*
|
|
2929
2880
|
* @private internal helper function
|
|
@@ -2933,6 +2884,7 @@ function $randomToken(randomness) {
|
|
|
2933
2884
|
return randomBytes(randomness).toString('hex');
|
|
2934
2885
|
}
|
|
2935
2886
|
/**
|
|
2887
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
2936
2888
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2937
2889
|
*/
|
|
2938
2890
|
|
|
@@ -2993,6 +2945,7 @@ const PROMPTBOOK_ERRORS = {
|
|
|
2993
2945
|
UnexpectedError,
|
|
2994
2946
|
WrappedError,
|
|
2995
2947
|
NotAllowed,
|
|
2948
|
+
DatabaseError,
|
|
2996
2949
|
// TODO: [🪑]> VersionMismatchError,
|
|
2997
2950
|
};
|
|
2998
2951
|
/**
|
|
@@ -3040,7 +2993,7 @@ function serializeError(error) {
|
|
|
3040
2993
|
const { name, message, stack } = error;
|
|
3041
2994
|
const { id } = error;
|
|
3042
2995
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3043
|
-
console.error(spaceTrim((block) => `
|
|
2996
|
+
console.error(spaceTrim$1((block) => `
|
|
3044
2997
|
|
|
3045
2998
|
Cannot serialize error with name "${name}"
|
|
3046
2999
|
|
|
@@ -3073,7 +3026,7 @@ function jsonParse(value) {
|
|
|
3073
3026
|
}
|
|
3074
3027
|
else if (typeof value !== 'string') {
|
|
3075
3028
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
3076
|
-
throw new Error(spaceTrim(`
|
|
3029
|
+
throw new Error(spaceTrim$1(`
|
|
3077
3030
|
Can not parse JSON from non-string value.
|
|
3078
3031
|
|
|
3079
3032
|
The value type: ${typeof value}
|
|
@@ -3087,7 +3040,7 @@ function jsonParse(value) {
|
|
|
3087
3040
|
if (!(error instanceof Error)) {
|
|
3088
3041
|
throw error;
|
|
3089
3042
|
}
|
|
3090
|
-
throw new Error(spaceTrim((block) => `
|
|
3043
|
+
throw new Error(spaceTrim$1((block) => `
|
|
3091
3044
|
${block(error.message)}
|
|
3092
3045
|
|
|
3093
3046
|
The expected JSON text:
|
|
@@ -3140,7 +3093,7 @@ function deserializeError(error) {
|
|
|
3140
3093
|
message = `${name}: ${message}`;
|
|
3141
3094
|
}
|
|
3142
3095
|
if (stack !== undefined && stack !== '') {
|
|
3143
|
-
message = spaceTrim((block) => `
|
|
3096
|
+
message = spaceTrim$1((block) => `
|
|
3144
3097
|
${block(message)}
|
|
3145
3098
|
|
|
3146
3099
|
Original stack trace:
|
|
@@ -3177,11 +3130,11 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
3177
3130
|
throw deserializeError(errors[0]);
|
|
3178
3131
|
}
|
|
3179
3132
|
else {
|
|
3180
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
3133
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
3181
3134
|
Multiple errors occurred during Promptbook execution
|
|
3182
3135
|
|
|
3183
3136
|
${block(errors
|
|
3184
|
-
.map(({ name, stack, message }, index) => spaceTrim$
|
|
3137
|
+
.map(({ name, stack, message }, index) => spaceTrim$2((block) => `
|
|
3185
3138
|
${name} ${index + 1}:
|
|
3186
3139
|
${block(stack || message)}
|
|
3187
3140
|
`))
|
|
@@ -3652,14 +3605,14 @@ class MultipleLlmExecutionTools {
|
|
|
3652
3605
|
if (description === undefined) {
|
|
3653
3606
|
return headLine;
|
|
3654
3607
|
}
|
|
3655
|
-
return spaceTrim((block) => `
|
|
3608
|
+
return spaceTrim$1((block) => `
|
|
3656
3609
|
${headLine}
|
|
3657
3610
|
|
|
3658
3611
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
3659
3612
|
`);
|
|
3660
3613
|
})
|
|
3661
3614
|
.join('\n\n');
|
|
3662
|
-
return spaceTrim((block) => `
|
|
3615
|
+
return spaceTrim$1((block) => `
|
|
3663
3616
|
Multiple LLM Providers:
|
|
3664
3617
|
|
|
3665
3618
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -3750,7 +3703,7 @@ class MultipleLlmExecutionTools {
|
|
|
3750
3703
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3751
3704
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3752
3705
|
// 3) ...
|
|
3753
|
-
spaceTrim((block) => `
|
|
3706
|
+
spaceTrim$1((block) => `
|
|
3754
3707
|
All execution tools of ${this.title} failed:
|
|
3755
3708
|
|
|
3756
3709
|
${block(errors
|
|
@@ -3763,7 +3716,7 @@ class MultipleLlmExecutionTools {
|
|
|
3763
3716
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
3764
3717
|
}
|
|
3765
3718
|
else {
|
|
3766
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
3719
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
3767
3720
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
3768
3721
|
|
|
3769
3722
|
Available \`LlmExecutionTools\`:
|
|
@@ -3796,7 +3749,7 @@ class MultipleLlmExecutionTools {
|
|
|
3796
3749
|
*/
|
|
3797
3750
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
3798
3751
|
if (llmExecutionTools.length === 0) {
|
|
3799
|
-
const warningMessage = spaceTrim(`
|
|
3752
|
+
const warningMessage = spaceTrim$1(`
|
|
3800
3753
|
You have not provided any \`LlmExecutionTools\`
|
|
3801
3754
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
3802
3755
|
|
|
@@ -3829,6 +3782,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
3829
3782
|
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
|
3830
3783
|
}
|
|
3831
3784
|
/**
|
|
3785
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
3832
3786
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3833
3787
|
*/
|
|
3834
3788
|
|
|
@@ -3845,6 +3799,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
3845
3799
|
return llmTools;
|
|
3846
3800
|
}
|
|
3847
3801
|
/**
|
|
3802
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
3848
3803
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3849
3804
|
*/
|
|
3850
3805
|
|
|
@@ -4049,14 +4004,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
4049
4004
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
4050
4005
|
});
|
|
4051
4006
|
if (metadata.length === 0) {
|
|
4052
|
-
return spaceTrim(`
|
|
4007
|
+
return spaceTrim$1(`
|
|
4053
4008
|
**No scrapers are available**
|
|
4054
4009
|
|
|
4055
4010
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
4056
4011
|
At least there should be available the metadata of the scrapers
|
|
4057
4012
|
`);
|
|
4058
4013
|
}
|
|
4059
|
-
return spaceTrim((block) => `
|
|
4014
|
+
return spaceTrim$1((block) => `
|
|
4060
4015
|
Available scrapers are:
|
|
4061
4016
|
${block(metadata
|
|
4062
4017
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -4558,7 +4513,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
4558
4513
|
else if (urlOrRequest instanceof Request) {
|
|
4559
4514
|
url = urlOrRequest.url;
|
|
4560
4515
|
}
|
|
4561
|
-
throw new PromptbookFetchError(spaceTrim((block) => `
|
|
4516
|
+
throw new PromptbookFetchError(spaceTrim$1((block) => `
|
|
4562
4517
|
Can not fetch "${url}"
|
|
4563
4518
|
|
|
4564
4519
|
Fetch error:
|
|
@@ -4719,7 +4674,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
4719
4674
|
const fileExtension = getFileExtension(filename);
|
|
4720
4675
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
4721
4676
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
4722
|
-
throw new NotFoundError(spaceTrim((block) => `
|
|
4677
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
4723
4678
|
Can not make source handler for file which does not exist:
|
|
4724
4679
|
|
|
4725
4680
|
File:
|
|
@@ -4812,7 +4767,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4812
4767
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
4813
4768
|
break;
|
|
4814
4769
|
}
|
|
4815
|
-
console.warn(spaceTrim((block) => `
|
|
4770
|
+
console.warn(spaceTrim$1((block) => `
|
|
4816
4771
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
4817
4772
|
|
|
4818
4773
|
The source:
|
|
@@ -4828,7 +4783,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4828
4783
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
4829
4784
|
}
|
|
4830
4785
|
if (partialPieces === null) {
|
|
4831
|
-
throw new KnowledgeScrapeError(spaceTrim((block) => `
|
|
4786
|
+
throw new KnowledgeScrapeError(spaceTrim$1((block) => `
|
|
4832
4787
|
Cannot scrape knowledge
|
|
4833
4788
|
|
|
4834
4789
|
The source:
|
|
@@ -4907,7 +4862,7 @@ async function prepareTasks(pipeline, tools, options) {
|
|
|
4907
4862
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
4908
4863
|
knowledgePiecesCount > 0 &&
|
|
4909
4864
|
!dependentParameterNames.includes('knowledge')) {
|
|
4910
|
-
preparedContent = spaceTrim$
|
|
4865
|
+
preparedContent = spaceTrim$2(`
|
|
4911
4866
|
{content}
|
|
4912
4867
|
|
|
4913
4868
|
## Knowledge
|
|
@@ -5220,7 +5175,7 @@ function extractVariablesFromJavascript(script) {
|
|
|
5220
5175
|
}
|
|
5221
5176
|
catch (error) {
|
|
5222
5177
|
assertsError(error);
|
|
5223
|
-
throw new ParseError(spaceTrim$
|
|
5178
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
5224
5179
|
Can not extract variables from the script
|
|
5225
5180
|
${block(error.stack || error.message)}
|
|
5226
5181
|
|
|
@@ -5403,7 +5358,7 @@ const CsvFormatParser = {
|
|
|
5403
5358
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5404
5359
|
const csv = csvParse(value, settings);
|
|
5405
5360
|
if (csv.errors.length !== 0) {
|
|
5406
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
5361
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
5407
5362
|
CSV parsing error
|
|
5408
5363
|
|
|
5409
5364
|
Error(s) from CSV parsing:
|
|
@@ -5448,7 +5403,7 @@ const CsvFormatParser = {
|
|
|
5448
5403
|
const { value, settings, mapCallback, onProgress } = options;
|
|
5449
5404
|
const csv = csvParse(value, settings);
|
|
5450
5405
|
if (csv.errors.length !== 0) {
|
|
5451
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
5406
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
5452
5407
|
CSV parsing error
|
|
5453
5408
|
|
|
5454
5409
|
Error(s) from CSV parsing:
|
|
@@ -5658,7 +5613,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
5658
5613
|
}
|
|
5659
5614
|
// Phase 2️⃣: Non-matching mapping
|
|
5660
5615
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
5661
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
5616
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
5662
5617
|
Can not map available parameters to expected parameters
|
|
5663
5618
|
|
|
5664
5619
|
Mapped parameters:
|
|
@@ -5776,18 +5731,6 @@ function templateParameters(template, parameters) {
|
|
|
5776
5731
|
return replacedTemplates;
|
|
5777
5732
|
}
|
|
5778
5733
|
|
|
5779
|
-
/**
|
|
5780
|
-
* Logs an LLM call with the given report.
|
|
5781
|
-
*
|
|
5782
|
-
* @private internal utility of `createPipelineExecutor`
|
|
5783
|
-
*/
|
|
5784
|
-
function logLlmCall(logLlmCall, report) {
|
|
5785
|
-
logLlmCall({
|
|
5786
|
-
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
5787
|
-
report,
|
|
5788
|
-
});
|
|
5789
|
-
}
|
|
5790
|
-
|
|
5791
5734
|
/**
|
|
5792
5735
|
* Extracts all code blocks from markdown.
|
|
5793
5736
|
*
|
|
@@ -6106,7 +6049,7 @@ function validatePromptResult(options) {
|
|
|
6106
6049
|
}
|
|
6107
6050
|
catch (error) {
|
|
6108
6051
|
keepUnused(error);
|
|
6109
|
-
throw new ExpectError(spaceTrim$
|
|
6052
|
+
throw new ExpectError(spaceTrim$2((block) => `
|
|
6110
6053
|
Expected valid JSON string
|
|
6111
6054
|
|
|
6112
6055
|
The expected JSON text:
|
|
@@ -6155,7 +6098,7 @@ function validatePromptResult(options) {
|
|
|
6155
6098
|
*/
|
|
6156
6099
|
async function executeAttempts(options) {
|
|
6157
6100
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
6158
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall
|
|
6101
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
|
|
6159
6102
|
const $ongoingTaskResult = {
|
|
6160
6103
|
$result: null,
|
|
6161
6104
|
$resultString: null,
|
|
@@ -6169,7 +6112,7 @@ async function executeAttempts(options) {
|
|
|
6169
6112
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
6170
6113
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
6171
6114
|
if (isJokerAttempt && !jokerParameterName) {
|
|
6172
|
-
throw new UnexpectedError(spaceTrim$
|
|
6115
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6173
6116
|
Joker not found in attempt ${attemptIndex}
|
|
6174
6117
|
|
|
6175
6118
|
${block(pipelineIdentification)}
|
|
@@ -6180,7 +6123,7 @@ async function executeAttempts(options) {
|
|
|
6180
6123
|
$ongoingTaskResult.$expectError = null;
|
|
6181
6124
|
if (isJokerAttempt) {
|
|
6182
6125
|
if (parameters[jokerParameterName] === undefined) {
|
|
6183
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6126
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6184
6127
|
Joker parameter {${jokerParameterName}} not defined
|
|
6185
6128
|
|
|
6186
6129
|
${block(pipelineIdentification)}
|
|
@@ -6238,7 +6181,7 @@ async function executeAttempts(options) {
|
|
|
6238
6181
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
6239
6182
|
break variant;
|
|
6240
6183
|
case 'EMBEDDING':
|
|
6241
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6184
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6242
6185
|
Embedding model can not be used in pipeline
|
|
6243
6186
|
|
|
6244
6187
|
This should be catched during parsing
|
|
@@ -6249,7 +6192,7 @@ async function executeAttempts(options) {
|
|
|
6249
6192
|
break variant;
|
|
6250
6193
|
// <- case [🤖]:
|
|
6251
6194
|
default:
|
|
6252
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6195
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6253
6196
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
6254
6197
|
|
|
6255
6198
|
${block(pipelineIdentification)}
|
|
@@ -6260,14 +6203,14 @@ async function executeAttempts(options) {
|
|
|
6260
6203
|
break;
|
|
6261
6204
|
case 'SCRIPT_TASK':
|
|
6262
6205
|
if (arrayableToArray(tools.script).length === 0) {
|
|
6263
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6206
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6264
6207
|
No script execution tools are available
|
|
6265
6208
|
|
|
6266
6209
|
${block(pipelineIdentification)}
|
|
6267
6210
|
`));
|
|
6268
6211
|
}
|
|
6269
6212
|
if (!task.contentLanguage) {
|
|
6270
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6213
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6271
6214
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
6272
6215
|
|
|
6273
6216
|
${block(pipelineIdentification)}
|
|
@@ -6298,7 +6241,7 @@ async function executeAttempts(options) {
|
|
|
6298
6241
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
6299
6242
|
}
|
|
6300
6243
|
else {
|
|
6301
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6244
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6302
6245
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
6303
6246
|
|
|
6304
6247
|
${block(pipelineIdentification)}
|
|
@@ -6312,7 +6255,7 @@ async function executeAttempts(options) {
|
|
|
6312
6255
|
break taskType;
|
|
6313
6256
|
case 'DIALOG_TASK':
|
|
6314
6257
|
if (tools.userInterface === undefined) {
|
|
6315
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6258
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6316
6259
|
User interface tools are not available
|
|
6317
6260
|
|
|
6318
6261
|
${block(pipelineIdentification)}
|
|
@@ -6330,7 +6273,7 @@ async function executeAttempts(options) {
|
|
|
6330
6273
|
break taskType;
|
|
6331
6274
|
// <- case: [🅱]
|
|
6332
6275
|
default:
|
|
6333
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6276
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6334
6277
|
Unknown execution type "${task.taskType}"
|
|
6335
6278
|
|
|
6336
6279
|
${block(pipelineIdentification)}
|
|
@@ -6417,15 +6360,18 @@ async function executeAttempts(options) {
|
|
|
6417
6360
|
: serializeError($ongoingTaskResult.$expectError),
|
|
6418
6361
|
};
|
|
6419
6362
|
$executionReport.promptExecutions.push(executionPromptReport);
|
|
6420
|
-
if (logLlmCall
|
|
6421
|
-
logLlmCall(
|
|
6363
|
+
if (logLlmCall) {
|
|
6364
|
+
logLlmCall({
|
|
6365
|
+
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
6366
|
+
report: executionPromptReport,
|
|
6367
|
+
});
|
|
6422
6368
|
}
|
|
6423
6369
|
}
|
|
6424
6370
|
}
|
|
6425
6371
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
6426
6372
|
// Note: Create a summary of all failures
|
|
6427
6373
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
6428
|
-
.map((failure) => spaceTrim$
|
|
6374
|
+
.map((failure) => spaceTrim$2((block) => {
|
|
6429
6375
|
var _a, _b;
|
|
6430
6376
|
return `
|
|
6431
6377
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -6435,14 +6381,14 @@ async function executeAttempts(options) {
|
|
|
6435
6381
|
Result:
|
|
6436
6382
|
${block(failure.result === null
|
|
6437
6383
|
? 'null'
|
|
6438
|
-
: spaceTrim$
|
|
6384
|
+
: spaceTrim$2(failure.result)
|
|
6439
6385
|
.split('\n')
|
|
6440
6386
|
.map((line) => `> ${line}`)
|
|
6441
6387
|
.join('\n'))}
|
|
6442
6388
|
`;
|
|
6443
6389
|
}))
|
|
6444
6390
|
.join('\n\n---\n\n');
|
|
6445
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6391
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => {
|
|
6446
6392
|
var _a;
|
|
6447
6393
|
return `
|
|
6448
6394
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -6462,7 +6408,7 @@ async function executeAttempts(options) {
|
|
|
6462
6408
|
}
|
|
6463
6409
|
}
|
|
6464
6410
|
if ($ongoingTaskResult.$resultString === null) {
|
|
6465
|
-
throw new UnexpectedError(spaceTrim$
|
|
6411
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6466
6412
|
Something went wrong and prompt result is null
|
|
6467
6413
|
|
|
6468
6414
|
${block(pipelineIdentification)}
|
|
@@ -6489,7 +6435,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6489
6435
|
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
6490
6436
|
}
|
|
6491
6437
|
if (jokerParameterNames.length !== 0) {
|
|
6492
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6438
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6493
6439
|
JOKER parameters are not supported together with FOREACH command
|
|
6494
6440
|
|
|
6495
6441
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6502,7 +6448,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6502
6448
|
if (formatDefinition === undefined) {
|
|
6503
6449
|
throw new UnexpectedError(
|
|
6504
6450
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6505
|
-
spaceTrim((block) => `
|
|
6451
|
+
spaceTrim$1((block) => `
|
|
6506
6452
|
Unsupported format "${task.foreach.formatName}"
|
|
6507
6453
|
|
|
6508
6454
|
Available formats:
|
|
@@ -6519,7 +6465,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6519
6465
|
if (subvalueParser === undefined) {
|
|
6520
6466
|
throw new UnexpectedError(
|
|
6521
6467
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6522
|
-
spaceTrim((block) => `
|
|
6468
|
+
spaceTrim$1((block) => `
|
|
6523
6469
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6524
6470
|
|
|
6525
6471
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6559,7 +6505,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6559
6505
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6560
6506
|
throw error;
|
|
6561
6507
|
}
|
|
6562
|
-
const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
|
|
6508
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6563
6509
|
${error.message}
|
|
6564
6510
|
|
|
6565
6511
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6583,7 +6529,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6583
6529
|
...options,
|
|
6584
6530
|
priority: priority + index,
|
|
6585
6531
|
parameters: allSubparameters,
|
|
6586
|
-
pipelineIdentification: spaceTrim((block) => `
|
|
6532
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
6587
6533
|
${block(pipelineIdentification)}
|
|
6588
6534
|
Subparameter index: ${index}
|
|
6589
6535
|
`),
|
|
@@ -6592,7 +6538,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6592
6538
|
}
|
|
6593
6539
|
catch (error) {
|
|
6594
6540
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6595
|
-
console.error(spaceTrim((block) => `
|
|
6541
|
+
console.error(spaceTrim$1((block) => `
|
|
6596
6542
|
${error.message}
|
|
6597
6543
|
|
|
6598
6544
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6692,7 +6638,7 @@ async function getKnowledgeForTask(options) {
|
|
|
6692
6638
|
},
|
|
6693
6639
|
content: task.content,
|
|
6694
6640
|
parameters,
|
|
6695
|
-
};
|
|
6641
|
+
}; /* <- Note: [🤛] */
|
|
6696
6642
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6697
6643
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6698
6644
|
const { index } = knowledgePiece;
|
|
@@ -6768,7 +6714,7 @@ async function getReservedParametersForTask(options) {
|
|
|
6768
6714
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
6769
6715
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
6770
6716
|
if (reservedParameters[parameterName] === undefined) {
|
|
6771
|
-
throw new UnexpectedError(spaceTrim$
|
|
6717
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6772
6718
|
Reserved parameter {${parameterName}} is not defined
|
|
6773
6719
|
|
|
6774
6720
|
${block(pipelineIdentification)}
|
|
@@ -6794,7 +6740,7 @@ async function executeTask(options) {
|
|
|
6794
6740
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
6795
6741
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
6796
6742
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
6797
|
-
throw new UnexpectedError(spaceTrim$
|
|
6743
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6798
6744
|
Dependent parameters are not consistent with used parameters:
|
|
6799
6745
|
|
|
6800
6746
|
Dependent parameters:
|
|
@@ -6838,7 +6784,7 @@ async function executeTask(options) {
|
|
|
6838
6784
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
6839
6785
|
// Houston, we have a problem
|
|
6840
6786
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
6841
|
-
throw new UnexpectedError(spaceTrim$
|
|
6787
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6842
6788
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
6843
6789
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
6844
6790
|
|
|
@@ -6907,7 +6853,7 @@ function filterJustOutputParameters(options) {
|
|
|
6907
6853
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
6908
6854
|
if (parametersToPass[parameter.name] === undefined) {
|
|
6909
6855
|
// [4]
|
|
6910
|
-
$warnings.push(new PipelineExecutionError(spaceTrim$
|
|
6856
|
+
$warnings.push(new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6911
6857
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
6912
6858
|
|
|
6913
6859
|
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
@@ -7015,7 +6961,7 @@ async function executePipeline(options) {
|
|
|
7015
6961
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
7016
6962
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
7017
6963
|
if (parameter === undefined) {
|
|
7018
|
-
warnings.push(new PipelineExecutionError(spaceTrim$
|
|
6964
|
+
warnings.push(new PipelineExecutionError(spaceTrim$2((block) => `
|
|
7019
6965
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
7020
6966
|
|
|
7021
6967
|
${block(pipelineIdentification)}
|
|
@@ -7030,7 +6976,7 @@ async function executePipeline(options) {
|
|
|
7030
6976
|
// TODO: [🧠] This should be also non-critical error
|
|
7031
6977
|
return exportJson({
|
|
7032
6978
|
name: 'pipelineExecutorResult',
|
|
7033
|
-
message: spaceTrim$
|
|
6979
|
+
message: spaceTrim$2((block) => `
|
|
7034
6980
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
7035
6981
|
|
|
7036
6982
|
${block(pipelineIdentification)}
|
|
@@ -7039,7 +6985,7 @@ async function executePipeline(options) {
|
|
|
7039
6985
|
value: {
|
|
7040
6986
|
isSuccessful: false,
|
|
7041
6987
|
errors: [
|
|
7042
|
-
new PipelineExecutionError(spaceTrim$
|
|
6988
|
+
new PipelineExecutionError(spaceTrim$2((block) => `
|
|
7043
6989
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
7044
6990
|
|
|
7045
6991
|
${block(pipelineIdentification)}
|
|
@@ -7066,7 +7012,7 @@ async function executePipeline(options) {
|
|
|
7066
7012
|
while (unresovedTasks.length > 0) {
|
|
7067
7013
|
if (loopLimit-- < 0) {
|
|
7068
7014
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
7069
|
-
throw new UnexpectedError(spaceTrim$
|
|
7015
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
7070
7016
|
Loop limit reached during resolving parameters pipeline execution
|
|
7071
7017
|
|
|
7072
7018
|
${block(pipelineIdentification)}
|
|
@@ -7076,7 +7022,7 @@ async function executePipeline(options) {
|
|
|
7076
7022
|
if (!currentTask && resolving.length === 0) {
|
|
7077
7023
|
throw new UnexpectedError(
|
|
7078
7024
|
// TODO: [🐎] DRY
|
|
7079
|
-
spaceTrim$
|
|
7025
|
+
spaceTrim$2((block) => `
|
|
7080
7026
|
Can not resolve some parameters:
|
|
7081
7027
|
|
|
7082
7028
|
${block(pipelineIdentification)}
|
|
@@ -7116,7 +7062,7 @@ async function executePipeline(options) {
|
|
|
7116
7062
|
tools,
|
|
7117
7063
|
onProgress(newOngoingResult) {
|
|
7118
7064
|
if (isReturned) {
|
|
7119
|
-
throw new UnexpectedError(spaceTrim$
|
|
7065
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
7120
7066
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
7121
7067
|
|
|
7122
7068
|
${block(pipelineIdentification)}
|
|
@@ -7133,7 +7079,7 @@ async function executePipeline(options) {
|
|
|
7133
7079
|
},
|
|
7134
7080
|
logLlmCall,
|
|
7135
7081
|
$executionReport: executionReport,
|
|
7136
|
-
pipelineIdentification: spaceTrim$
|
|
7082
|
+
pipelineIdentification: spaceTrim$2((block) => `
|
|
7137
7083
|
${block(pipelineIdentification)}
|
|
7138
7084
|
Task name: ${currentTask.name}
|
|
7139
7085
|
Task title: ${currentTask.title}
|
|
@@ -7242,7 +7188,7 @@ function createPipelineExecutor(options) {
|
|
|
7242
7188
|
preparedPipeline = pipeline;
|
|
7243
7189
|
}
|
|
7244
7190
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
7245
|
-
console.warn(spaceTrim$
|
|
7191
|
+
console.warn(spaceTrim$2((block) => `
|
|
7246
7192
|
Pipeline is not prepared
|
|
7247
7193
|
|
|
7248
7194
|
${block(pipelineIdentification)}
|
|
@@ -7267,7 +7213,7 @@ function createPipelineExecutor(options) {
|
|
|
7267
7213
|
tools,
|
|
7268
7214
|
onProgress,
|
|
7269
7215
|
logLlmCall,
|
|
7270
|
-
pipelineIdentification: spaceTrim$
|
|
7216
|
+
pipelineIdentification: spaceTrim$2((block) => `
|
|
7271
7217
|
${block(pipelineIdentification)}
|
|
7272
7218
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
7273
7219
|
`),
|
|
@@ -7598,7 +7544,7 @@ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7598
7544
|
* Markdown documentation for ACTION commitment.
|
|
7599
7545
|
*/
|
|
7600
7546
|
get documentation() {
|
|
7601
|
-
return spaceTrim$
|
|
7547
|
+
return spaceTrim$2(`
|
|
7602
7548
|
# ${this.type}
|
|
7603
7549
|
|
|
7604
7550
|
Defines specific actions or capabilities that the agent can perform.
|
|
@@ -7677,7 +7623,7 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7677
7623
|
* Markdown documentation for DELETE commitment.
|
|
7678
7624
|
*/
|
|
7679
7625
|
get documentation() {
|
|
7680
|
-
return spaceTrim$
|
|
7626
|
+
return spaceTrim$2(`
|
|
7681
7627
|
# DELETE (CANCEL, DISCARD, REMOVE)
|
|
7682
7628
|
|
|
7683
7629
|
A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
|
|
@@ -7793,7 +7739,7 @@ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7793
7739
|
* Markdown documentation for FORMAT commitment.
|
|
7794
7740
|
*/
|
|
7795
7741
|
get documentation() {
|
|
7796
|
-
return spaceTrim$
|
|
7742
|
+
return spaceTrim$2(`
|
|
7797
7743
|
# ${this.type}
|
|
7798
7744
|
|
|
7799
7745
|
Defines the specific output structure and formatting for responses (data formats, templates, structure).
|
|
@@ -7868,7 +7814,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7868
7814
|
* Markdown documentation for GOAL commitment.
|
|
7869
7815
|
*/
|
|
7870
7816
|
get documentation() {
|
|
7871
|
-
return spaceTrim$
|
|
7817
|
+
return spaceTrim$2(`
|
|
7872
7818
|
# ${this.type}
|
|
7873
7819
|
|
|
7874
7820
|
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.
|
|
@@ -7964,7 +7910,7 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7964
7910
|
* Markdown documentation for KNOWLEDGE commitment.
|
|
7965
7911
|
*/
|
|
7966
7912
|
get documentation() {
|
|
7967
|
-
return spaceTrim$
|
|
7913
|
+
return spaceTrim$2(`
|
|
7968
7914
|
# ${this.type}
|
|
7969
7915
|
|
|
7970
7916
|
Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
|
|
@@ -8081,7 +8027,7 @@ class MemoryCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8081
8027
|
* Markdown documentation for MEMORY commitment.
|
|
8082
8028
|
*/
|
|
8083
8029
|
get documentation() {
|
|
8084
|
-
return spaceTrim$
|
|
8030
|
+
return spaceTrim$2(`
|
|
8085
8031
|
# ${this.type}
|
|
8086
8032
|
|
|
8087
8033
|
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.
|
|
@@ -8183,7 +8129,7 @@ class MessageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8183
8129
|
* Markdown documentation for MESSAGE commitment.
|
|
8184
8130
|
*/
|
|
8185
8131
|
get documentation() {
|
|
8186
|
-
return spaceTrim$
|
|
8132
|
+
return spaceTrim$2(`
|
|
8187
8133
|
# ${this.type}
|
|
8188
8134
|
|
|
8189
8135
|
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.
|
|
@@ -8301,7 +8247,7 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8301
8247
|
* Markdown documentation for META commitment.
|
|
8302
8248
|
*/
|
|
8303
8249
|
get documentation() {
|
|
8304
|
-
return spaceTrim$
|
|
8250
|
+
return spaceTrim$2(`
|
|
8305
8251
|
# META
|
|
8306
8252
|
|
|
8307
8253
|
Sets meta-information about the agent that is used for display and attribution purposes.
|
|
@@ -8437,7 +8383,7 @@ class ModelCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8437
8383
|
* Markdown documentation for MODEL commitment.
|
|
8438
8384
|
*/
|
|
8439
8385
|
get documentation() {
|
|
8440
|
-
return spaceTrim$
|
|
8386
|
+
return spaceTrim$2(`
|
|
8441
8387
|
# ${this.type}
|
|
8442
8388
|
|
|
8443
8389
|
Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
|
|
@@ -8672,7 +8618,7 @@ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8672
8618
|
* Markdown documentation for NOTE commitment.
|
|
8673
8619
|
*/
|
|
8674
8620
|
get documentation() {
|
|
8675
|
-
return spaceTrim$
|
|
8621
|
+
return spaceTrim$2(`
|
|
8676
8622
|
# ${this.type}
|
|
8677
8623
|
|
|
8678
8624
|
Adds comments for documentation without changing agent behavior.
|
|
@@ -8774,7 +8720,7 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8774
8720
|
* Markdown documentation for PERSONA commitment.
|
|
8775
8721
|
*/
|
|
8776
8722
|
get documentation() {
|
|
8777
|
-
return spaceTrim$
|
|
8723
|
+
return spaceTrim$2(`
|
|
8778
8724
|
# ${this.type}
|
|
8779
8725
|
|
|
8780
8726
|
Defines who the agent is, their background, expertise, and personality traits.
|
|
@@ -8900,7 +8846,7 @@ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8900
8846
|
* Markdown documentation for RULE/RULES commitment.
|
|
8901
8847
|
*/
|
|
8902
8848
|
get documentation() {
|
|
8903
|
-
return spaceTrim$
|
|
8849
|
+
return spaceTrim$2(`
|
|
8904
8850
|
# ${this.type}
|
|
8905
8851
|
|
|
8906
8852
|
Adds behavioral constraints and guidelines that the agent must follow.
|
|
@@ -8976,7 +8922,7 @@ class SampleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
8976
8922
|
* Markdown documentation for SAMPLE/EXAMPLE commitment.
|
|
8977
8923
|
*/
|
|
8978
8924
|
get documentation() {
|
|
8979
|
-
return spaceTrim$
|
|
8925
|
+
return spaceTrim$2(`
|
|
8980
8926
|
# ${this.type}
|
|
8981
8927
|
|
|
8982
8928
|
Provides examples of how the agent should respond or behave in certain situations.
|
|
@@ -9053,7 +8999,7 @@ class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
9053
8999
|
* Markdown documentation for SCENARIO commitment.
|
|
9054
9000
|
*/
|
|
9055
9001
|
get documentation() {
|
|
9056
|
-
return spaceTrim$
|
|
9002
|
+
return spaceTrim$2(`
|
|
9057
9003
|
# ${this.type}
|
|
9058
9004
|
|
|
9059
9005
|
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.
|
|
@@ -9169,7 +9115,7 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
9169
9115
|
* Markdown documentation for STYLE commitment.
|
|
9170
9116
|
*/
|
|
9171
9117
|
get documentation() {
|
|
9172
|
-
return spaceTrim$
|
|
9118
|
+
return spaceTrim$2(`
|
|
9173
9119
|
# ${this.type}
|
|
9174
9120
|
|
|
9175
9121
|
Defines how the agent should format and present its responses (tone, writing style, formatting).
|
|
@@ -9238,7 +9184,7 @@ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
9238
9184
|
* Markdown documentation available at runtime.
|
|
9239
9185
|
*/
|
|
9240
9186
|
get documentation() {
|
|
9241
|
-
return spaceTrim$
|
|
9187
|
+
return spaceTrim$2(`
|
|
9242
9188
|
# ${this.type}
|
|
9243
9189
|
|
|
9244
9190
|
This commitment is not yet fully implemented.
|
|
@@ -9412,7 +9358,7 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
9412
9358
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
9413
9359
|
commitments.push({
|
|
9414
9360
|
type: currentCommitment.type,
|
|
9415
|
-
content: spaceTrim$
|
|
9361
|
+
content: spaceTrim$2(fullContent),
|
|
9416
9362
|
originalLine: currentCommitment.originalStartLine,
|
|
9417
9363
|
lineNumber: currentCommitment.startLineNumber,
|
|
9418
9364
|
});
|
|
@@ -9448,7 +9394,7 @@ function parseAgentSourceWithCommitments(agentSource) {
|
|
|
9448
9394
|
const fullContent = currentCommitment.contentLines.join('\n');
|
|
9449
9395
|
commitments.push({
|
|
9450
9396
|
type: currentCommitment.type,
|
|
9451
|
-
content: spaceTrim$
|
|
9397
|
+
content: spaceTrim$2(fullContent),
|
|
9452
9398
|
originalLine: currentCommitment.originalStartLine,
|
|
9453
9399
|
lineNumber: currentCommitment.startLineNumber,
|
|
9454
9400
|
});
|
|
@@ -9762,7 +9708,7 @@ function parseAgentSource(agentSource) {
|
|
|
9762
9708
|
// Parse META commitments - format is "META TYPE content"
|
|
9763
9709
|
const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
|
|
9764
9710
|
const metaType = normalizeTo_camelCase(metaTypeRaw);
|
|
9765
|
-
meta[metaType] = spaceTrim(commitment.content.substring(metaTypeRaw.length));
|
|
9711
|
+
meta[metaType] = spaceTrim$1(commitment.content.substring(metaTypeRaw.length));
|
|
9766
9712
|
}
|
|
9767
9713
|
// Generate gravatar fallback if no meta image specified
|
|
9768
9714
|
if (!meta.image) {
|
|
@@ -9932,17 +9878,213 @@ function validateBook(source) {
|
|
|
9932
9878
|
/**
|
|
9933
9879
|
* Default book
|
|
9934
9880
|
*
|
|
9881
|
+
* @deprecated Use `$generateBookBoilerplate` instead
|
|
9935
9882
|
* @public exported from `@promptbook/core`
|
|
9936
9883
|
*/
|
|
9937
|
-
const DEFAULT_BOOK = padBook(validateBook(spaceTrim(`
|
|
9884
|
+
const DEFAULT_BOOK = padBook(validateBook(spaceTrim$1(`
|
|
9938
9885
|
AI Avatar
|
|
9939
9886
|
|
|
9940
9887
|
PERSONA A friendly AI assistant that helps you with your tasks
|
|
9941
9888
|
`)));
|
|
9942
9889
|
// <- Note: Not using book`...` notation to avoid strange error in jest unit tests `TypeError: (0 , book_notation_1.book) is not a function`
|
|
9943
|
-
// <- TODO: !!! GENESIS_BOOK
|
|
9890
|
+
// <- TODO: !!! `GENESIS_BOOK` / `ADAM_BOOK` in `/agents/adam.book`
|
|
9944
9891
|
// <- !!! Buttons into genesis book
|
|
9945
|
-
// <- TODO: !!!
|
|
9892
|
+
// <- TODO: !!! generateBookBoilerplate and deprecate `DEFAULT_BOOK`
|
|
9893
|
+
|
|
9894
|
+
/**
|
|
9895
|
+
* Trims string from all 4 sides
|
|
9896
|
+
*
|
|
9897
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
9898
|
+
* Developed by same author @hejny as this package
|
|
9899
|
+
*
|
|
9900
|
+
* @public exported from `@promptbook/utils`
|
|
9901
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
9902
|
+
*/
|
|
9903
|
+
const spaceTrim = spaceTrim$2;
|
|
9904
|
+
|
|
9905
|
+
/**
|
|
9906
|
+
* Agent collection stored in Supabase table
|
|
9907
|
+
*
|
|
9908
|
+
* Note: This object can work both from Node.js and browser environment depending on the Supabase client provided
|
|
9909
|
+
*
|
|
9910
|
+
* @public exported from `@promptbook/core`
|
|
9911
|
+
* <- TODO: !!! Move to `@promptbook/supabase` package
|
|
9912
|
+
*/
|
|
9913
|
+
class AgentCollectionInSupabase /* TODO: !!!! implements AgentCollection */ {
|
|
9914
|
+
/**
|
|
9915
|
+
* @param rootPath - path to the directory with agents
|
|
9916
|
+
* @param tools - Execution tools to be used in !!! `Agent` itself and listing the agents
|
|
9917
|
+
* @param options - Options for the collection creation
|
|
9918
|
+
*/
|
|
9919
|
+
constructor(supabaseClient,
|
|
9920
|
+
/// TODO: !!! Remove> private readonly tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>,
|
|
9921
|
+
options) {
|
|
9922
|
+
this.supabaseClient = supabaseClient;
|
|
9923
|
+
this.options = options;
|
|
9924
|
+
const { isVerbose = DEFAULT_IS_VERBOSE } = options || {};
|
|
9925
|
+
if (isVerbose) {
|
|
9926
|
+
console.info(`Creating pipeline collection from supabase...`);
|
|
9927
|
+
}
|
|
9928
|
+
}
|
|
9929
|
+
/**
|
|
9930
|
+
* Cached defined execution tools
|
|
9931
|
+
*/
|
|
9932
|
+
// !!! private _definedTools: ExecutionTools | null = null;
|
|
9933
|
+
/*
|
|
9934
|
+
TODO: !!! Use or remove
|
|
9935
|
+
/**
|
|
9936
|
+
* Gets or creates execution tools for the collection
|
|
9937
|
+
* /
|
|
9938
|
+
private async getTools(): Promise<ExecutionTools> {
|
|
9939
|
+
if (this._definedTools !== null) {
|
|
9940
|
+
return this._definedTools;
|
|
9941
|
+
}
|
|
9942
|
+
|
|
9943
|
+
this._definedTools = {
|
|
9944
|
+
...(this.tools === undefined || this.tools.fs === undefined ? await $provideExecutionToolsForNode() : {}),
|
|
9945
|
+
...this.tools,
|
|
9946
|
+
};
|
|
9947
|
+
return this._definedTools;
|
|
9948
|
+
}
|
|
9949
|
+
// <- TODO: [👪] Maybe create some common abstraction *(or parent abstract class)*
|
|
9950
|
+
*/
|
|
9951
|
+
/**
|
|
9952
|
+
* Gets all agents in the collection
|
|
9953
|
+
*/
|
|
9954
|
+
async listAgents( /* TODO: [🧠] Allow to pass some condition here */) {
|
|
9955
|
+
const { isVerbose = DEFAULT_IS_VERBOSE } = this.options || {};
|
|
9956
|
+
const result = await this.supabaseClient
|
|
9957
|
+
.from('AgentCollection' /* <- TODO: !!!! Change to `Agent` */)
|
|
9958
|
+
.select('agentProfile');
|
|
9959
|
+
if (result.error) {
|
|
9960
|
+
throw new DatabaseError(spaceTrim((block) => `
|
|
9961
|
+
|
|
9962
|
+
Error fetching agents from Supabase:
|
|
9963
|
+
|
|
9964
|
+
${block(result.error.message)}
|
|
9965
|
+
`));
|
|
9966
|
+
}
|
|
9967
|
+
if (isVerbose) {
|
|
9968
|
+
console.info(`Found ${result.data.length} agents in directory`);
|
|
9969
|
+
}
|
|
9970
|
+
return result.data.map((row) => row.agentProfile);
|
|
9971
|
+
}
|
|
9972
|
+
/**
|
|
9973
|
+
* !!!
|
|
9974
|
+
* /
|
|
9975
|
+
public async spawnAgent(agentName: string_agent_name): Promise<Agent> {
|
|
9976
|
+
|
|
9977
|
+
// <- TODO: !!! ENOENT: no such file or directory, open 'C:\Users\me\work\ai\promptbook\agents\examples\Asistent pro LŠVP.book
|
|
9978
|
+
const { isVerbose = DEFAULT_IS_VERBOSE } = this.options || {};
|
|
9979
|
+
const tools = await this.getTools();
|
|
9980
|
+
|
|
9981
|
+
const agentSourceValue = validateBook(await tools.fs!.readFile(agentSourcePath, 'utf-8'));
|
|
9982
|
+
const agentSource = new BehaviorSubject(agentSourceValue);
|
|
9983
|
+
|
|
9984
|
+
// Note: Write file whenever agent source changes
|
|
9985
|
+
agentSource.subscribe(async (newSource) => {
|
|
9986
|
+
if (isVerbose) {
|
|
9987
|
+
console.info(colors.cyan(`Writing agent source to file ${agentSourcePath}`));
|
|
9988
|
+
}
|
|
9989
|
+
await forTime(500); // <- TODO: [🙌] !!! Remove
|
|
9990
|
+
await tools.fs!.writeFile(agentSourcePath, newSource, 'utf-8');
|
|
9991
|
+
});
|
|
9992
|
+
|
|
9993
|
+
// Note: Watch file for external changes
|
|
9994
|
+
for await (const event of tools.fs!.watch(agentSourcePath)) {
|
|
9995
|
+
// <- TODO: !!!! Solve the memory freeing when the watching is no longer needed
|
|
9996
|
+
|
|
9997
|
+
if (event.eventType !== 'change') {
|
|
9998
|
+
continue;
|
|
9999
|
+
}
|
|
10000
|
+
|
|
10001
|
+
if (isVerbose) {
|
|
10002
|
+
console.info(
|
|
10003
|
+
colors.cyan(`Detected external change in agent source file ${agentSourcePath}, reloading`),
|
|
10004
|
+
);
|
|
10005
|
+
}
|
|
10006
|
+
await forTime(500); // <- TODO: [🙌] !!! Remove
|
|
10007
|
+
const newSource = validateBook(await tools.fs!.readFile(agentSourcePath, 'utf-8'));
|
|
10008
|
+
agentSource.next(newSource);
|
|
10009
|
+
}
|
|
10010
|
+
|
|
10011
|
+
// TODO: [🙌] !!!! Debug the infinite loop when file is changed externally and agent source is updated which causes file to be written again
|
|
10012
|
+
|
|
10013
|
+
const agent = new Agent({
|
|
10014
|
+
...this.options,
|
|
10015
|
+
agentSource,
|
|
10016
|
+
executionTools: this.tools || {},
|
|
10017
|
+
});
|
|
10018
|
+
|
|
10019
|
+
if (isVerbose) {
|
|
10020
|
+
console.info(colors.cyan(`Created agent "${agent.agentName}" from source file ${agentSourcePath}`));
|
|
10021
|
+
}
|
|
10022
|
+
|
|
10023
|
+
return agent;
|
|
10024
|
+
* /
|
|
10025
|
+
}
|
|
10026
|
+
*/
|
|
10027
|
+
/**
|
|
10028
|
+
* !!!@@@
|
|
10029
|
+
*/
|
|
10030
|
+
async getAgentSource(agentName) {
|
|
10031
|
+
const result = await this.supabaseClient
|
|
10032
|
+
.from('AgentCollection' /* <- TODO: !!!! Change to `Agent` */)
|
|
10033
|
+
.select('agentSource')
|
|
10034
|
+
.eq('agentName', agentName)
|
|
10035
|
+
.single();
|
|
10036
|
+
if (result.error) {
|
|
10037
|
+
throw new DatabaseError(spaceTrim((block) => `
|
|
10038
|
+
|
|
10039
|
+
Error fetching agent "${agentName}" from Supabase:
|
|
10040
|
+
|
|
10041
|
+
${block(result.error.message)}
|
|
10042
|
+
`));
|
|
10043
|
+
// <- TODO: !!! First check if the error is "not found" and throw `NotFoundError` instead then throw `DatabaseError`
|
|
10044
|
+
}
|
|
10045
|
+
const agentSource = new BehaviorSubject(result.data.agentSource);
|
|
10046
|
+
// <- TODO: !!!! Dynamic updates
|
|
10047
|
+
return agentSource;
|
|
10048
|
+
}
|
|
10049
|
+
/**
|
|
10050
|
+
* Creates a new agent in the collection
|
|
10051
|
+
*
|
|
10052
|
+
* Note: You can set 'PARENT' in the agent source to inherit from another agent in the collection.
|
|
10053
|
+
*/
|
|
10054
|
+
async createAgent(agentSource) {
|
|
10055
|
+
const agentProfile = parseAgentSource(agentSource);
|
|
10056
|
+
// <- TODO: [🕛]
|
|
10057
|
+
const result = await this.supabaseClient.from('AgentCollection' /* <- TODO: !!!! Change to `Agent` */).insert({
|
|
10058
|
+
agentName: agentProfile.agentName || '!!!!!' /* <- TODO: !!!! Remove */,
|
|
10059
|
+
agentProfile,
|
|
10060
|
+
createdAt: new Date().toISOString(),
|
|
10061
|
+
updatedAt: null,
|
|
10062
|
+
agentVersion: 0,
|
|
10063
|
+
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
10064
|
+
usage: ZERO_USAGE,
|
|
10065
|
+
agentSource: agentSource,
|
|
10066
|
+
});
|
|
10067
|
+
if (result.error) {
|
|
10068
|
+
throw new DatabaseError(spaceTrim((block) => `
|
|
10069
|
+
Error creating agent "${agentProfile.agentName}" in Supabase:
|
|
10070
|
+
|
|
10071
|
+
${block(result.error.message)}
|
|
10072
|
+
`));
|
|
10073
|
+
}
|
|
10074
|
+
return agentProfile;
|
|
10075
|
+
}
|
|
10076
|
+
/**
|
|
10077
|
+
* Deletes an agent from the collection
|
|
10078
|
+
*/
|
|
10079
|
+
async deleteAgent(agentName) {
|
|
10080
|
+
throw new NotYetImplementedError('Method not implemented.');
|
|
10081
|
+
}
|
|
10082
|
+
}
|
|
10083
|
+
/**
|
|
10084
|
+
* TODO: !!!! Implement it here correctly and update JSDoc comments here, and on interface + other implementations
|
|
10085
|
+
* TODO: Write unit test
|
|
10086
|
+
* TODO: [🧠][🚙] `AgentXxx` vs `AgentsXxx` naming convention
|
|
10087
|
+
*/
|
|
9946
10088
|
|
|
9947
10089
|
/**
|
|
9948
10090
|
* Constructs `PipelineCollection` from async sources
|
|
@@ -10041,7 +10183,7 @@ function createPipelineSubcollection(collection, predicate) {
|
|
|
10041
10183
|
}
|
|
10042
10184
|
async function getPipelineByUrl(url) {
|
|
10043
10185
|
if (!predicate(url)) {
|
|
10044
|
-
throw new NotFoundError(await spaceTrim$
|
|
10186
|
+
throw new NotFoundError(await spaceTrim$2(async (block) => `
|
|
10045
10187
|
Promptbook with url "${url}" not found or not accessible
|
|
10046
10188
|
|
|
10047
10189
|
Available promptbooks:
|
|
@@ -10160,7 +10302,7 @@ const knowledgeCommandParser = {
|
|
|
10160
10302
|
*/
|
|
10161
10303
|
parse(input) {
|
|
10162
10304
|
const { args } = input;
|
|
10163
|
-
const knowledgeSourceContent = spaceTrim(args[0] || '');
|
|
10305
|
+
const knowledgeSourceContent = spaceTrim$1(args[0] || '');
|
|
10164
10306
|
if (knowledgeSourceContent === '') {
|
|
10165
10307
|
throw new ParseError(`Source is not defined`);
|
|
10166
10308
|
}
|
|
@@ -10304,7 +10446,7 @@ const sectionCommandParser = {
|
|
|
10304
10446
|
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
10305
10447
|
const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
|
|
10306
10448
|
if (taskTypes.length !== 1) {
|
|
10307
|
-
throw new ParseError(spaceTrim((block) => `
|
|
10449
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
10308
10450
|
Unknown section type "${normalized}"
|
|
10309
10451
|
|
|
10310
10452
|
Supported section types are:
|
|
@@ -10324,7 +10466,7 @@ const sectionCommandParser = {
|
|
|
10324
10466
|
*/
|
|
10325
10467
|
$applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
10326
10468
|
if ($taskJson.isSectionTypeSet === true) {
|
|
10327
|
-
throw new ParseError(spaceTrim(`
|
|
10469
|
+
throw new ParseError(spaceTrim$1(`
|
|
10328
10470
|
Section type is already defined in the section.
|
|
10329
10471
|
It can be defined only once.
|
|
10330
10472
|
`));
|
|
@@ -10673,7 +10815,7 @@ const expectCommandParser = {
|
|
|
10673
10815
|
/**
|
|
10674
10816
|
* Description of the FORMAT command
|
|
10675
10817
|
*/
|
|
10676
|
-
description: spaceTrim(`
|
|
10818
|
+
description: spaceTrim$1(`
|
|
10677
10819
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
10678
10820
|
It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
10679
10821
|
`),
|
|
@@ -10747,7 +10889,7 @@ const expectCommandParser = {
|
|
|
10747
10889
|
}
|
|
10748
10890
|
catch (error) {
|
|
10749
10891
|
assertsError(error);
|
|
10750
|
-
throw new ParseError(spaceTrim((block) => `
|
|
10892
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
10751
10893
|
Invalid FORMAT command
|
|
10752
10894
|
${block(error.message)}:
|
|
10753
10895
|
`));
|
|
@@ -10881,7 +11023,7 @@ function validateParameterName(parameterName) {
|
|
|
10881
11023
|
if (!(error instanceof ParseError)) {
|
|
10882
11024
|
throw error;
|
|
10883
11025
|
}
|
|
10884
|
-
throw new ParseError(spaceTrim((block) => `
|
|
11026
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
10885
11027
|
${block(error.message)}
|
|
10886
11028
|
|
|
10887
11029
|
Tried to validate parameter name:
|
|
@@ -10940,7 +11082,7 @@ const foreachCommandParser = {
|
|
|
10940
11082
|
const assignSign = args[3];
|
|
10941
11083
|
const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
|
|
10942
11084
|
if (formatDefinition === undefined) {
|
|
10943
|
-
throw new ParseError(spaceTrim((block) => `
|
|
11085
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
10944
11086
|
Unsupported format "${formatName}"
|
|
10945
11087
|
|
|
10946
11088
|
Available formats:
|
|
@@ -10952,7 +11094,7 @@ const foreachCommandParser = {
|
|
|
10952
11094
|
}
|
|
10953
11095
|
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
10954
11096
|
if (subvalueParser === undefined) {
|
|
10955
|
-
throw new ParseError(spaceTrim((block) => `
|
|
11097
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
10956
11098
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
10957
11099
|
|
|
10958
11100
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -11000,7 +11142,7 @@ const foreachCommandParser = {
|
|
|
11000
11142
|
outputSubparameterName = 'newLine';
|
|
11001
11143
|
}
|
|
11002
11144
|
else {
|
|
11003
|
-
throw new ParseError(spaceTrim(`
|
|
11145
|
+
throw new ParseError(spaceTrim$1(`
|
|
11004
11146
|
FOREACH ${formatName} ${subformatName} must specify output subparameter
|
|
11005
11147
|
|
|
11006
11148
|
Correct example:
|
|
@@ -11076,7 +11218,7 @@ const formatCommandParser = {
|
|
|
11076
11218
|
/**
|
|
11077
11219
|
* Description of the FORMAT command
|
|
11078
11220
|
*/
|
|
11079
|
-
description: spaceTrim(`
|
|
11221
|
+
description: spaceTrim$1(`
|
|
11080
11222
|
Format command describes the desired output of the task (after post-processing)
|
|
11081
11223
|
It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
11082
11224
|
`),
|
|
@@ -11448,7 +11590,7 @@ const formfactorCommandParser = {
|
|
|
11448
11590
|
const formfactorNameCandidate = args[0].toUpperCase();
|
|
11449
11591
|
const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
|
|
11450
11592
|
if (formfactor === undefined) {
|
|
11451
|
-
throw new ParseError(spaceTrim((block) => `
|
|
11593
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
11452
11594
|
Unknown formfactor name "${formfactorNameCandidate}"
|
|
11453
11595
|
|
|
11454
11596
|
Available formfactors:
|
|
@@ -11467,7 +11609,7 @@ const formfactorCommandParser = {
|
|
|
11467
11609
|
*/
|
|
11468
11610
|
$applyToPipelineJson(command, $pipelineJson) {
|
|
11469
11611
|
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
11470
|
-
throw new ParseError(spaceTrim(`
|
|
11612
|
+
throw new ParseError(spaceTrim$1(`
|
|
11471
11613
|
Redefinition of \`FORMFACTOR\` in the pipeline head
|
|
11472
11614
|
|
|
11473
11615
|
You have used:
|
|
@@ -11610,7 +11752,7 @@ const modelCommandParser = {
|
|
|
11610
11752
|
*/
|
|
11611
11753
|
parse(input) {
|
|
11612
11754
|
const { args, normalized } = input;
|
|
11613
|
-
const availableVariantsMessage = spaceTrim((block) => `
|
|
11755
|
+
const availableVariantsMessage = spaceTrim$1((block) => `
|
|
11614
11756
|
Available variants are:
|
|
11615
11757
|
${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
|
|
11616
11758
|
`);
|
|
@@ -11632,14 +11774,14 @@ const modelCommandParser = {
|
|
|
11632
11774
|
// <- Note: [🤖]
|
|
11633
11775
|
}
|
|
11634
11776
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
11635
|
-
spaceTrim((block) => `
|
|
11777
|
+
spaceTrim$1((block) => `
|
|
11636
11778
|
Embedding model can not be used in pipeline
|
|
11637
11779
|
|
|
11638
11780
|
${block(availableVariantsMessage)}
|
|
11639
11781
|
`);
|
|
11640
11782
|
}
|
|
11641
11783
|
else {
|
|
11642
|
-
throw new ParseError(spaceTrim((block) => `
|
|
11784
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
11643
11785
|
Unknown model variant in command:
|
|
11644
11786
|
|
|
11645
11787
|
${block(availableVariantsMessage)}
|
|
@@ -11654,7 +11796,7 @@ const modelCommandParser = {
|
|
|
11654
11796
|
};
|
|
11655
11797
|
}
|
|
11656
11798
|
else {
|
|
11657
|
-
throw new ParseError(spaceTrim((block) => `
|
|
11799
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
11658
11800
|
Unknown model key in command.
|
|
11659
11801
|
|
|
11660
11802
|
Supported model keys are:
|
|
@@ -11681,7 +11823,7 @@ const modelCommandParser = {
|
|
|
11681
11823
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
11682
11824
|
}
|
|
11683
11825
|
else {
|
|
11684
|
-
throw new ParseError(spaceTrim(`
|
|
11826
|
+
throw new ParseError(spaceTrim$1(`
|
|
11685
11827
|
Redefinition of \`MODEL ${command.key}\` in the pipeline head
|
|
11686
11828
|
|
|
11687
11829
|
You have used:
|
|
@@ -11713,7 +11855,7 @@ const modelCommandParser = {
|
|
|
11713
11855
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
11714
11856
|
}
|
|
11715
11857
|
else {
|
|
11716
|
-
throw new ParseError(spaceTrim(`
|
|
11858
|
+
throw new ParseError(spaceTrim$1(`
|
|
11717
11859
|
Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
|
|
11718
11860
|
|
|
11719
11861
|
You have used:
|
|
@@ -11723,7 +11865,7 @@ const modelCommandParser = {
|
|
|
11723
11865
|
}
|
|
11724
11866
|
}
|
|
11725
11867
|
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
11726
|
-
console.log(spaceTrim(`
|
|
11868
|
+
console.log(spaceTrim$1(`
|
|
11727
11869
|
Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
|
|
11728
11870
|
|
|
11729
11871
|
In pipeline head:
|
|
@@ -11806,7 +11948,7 @@ const parameterCommandParser = {
|
|
|
11806
11948
|
// <- TODO: When [🥶] fixed, change to:
|
|
11807
11949
|
// > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
|
|
11808
11950
|
if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
|
|
11809
|
-
throw new ParseError(spaceTrim((block) => `
|
|
11951
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
11810
11952
|
Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
|
|
11811
11953
|
|
|
11812
11954
|
The description:
|
|
@@ -11988,7 +12130,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
11988
12130
|
persona.description = personaDescription;
|
|
11989
12131
|
return;
|
|
11990
12132
|
}
|
|
11991
|
-
console.warn(spaceTrim(`
|
|
12133
|
+
console.warn(spaceTrim$1(`
|
|
11992
12134
|
|
|
11993
12135
|
Persona "${personaName}" is defined multiple times with different description:
|
|
11994
12136
|
|
|
@@ -11999,7 +12141,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
11999
12141
|
${personaDescription}
|
|
12000
12142
|
|
|
12001
12143
|
`));
|
|
12002
|
-
persona.description += spaceTrim('\n\n' + personaDescription);
|
|
12144
|
+
persona.description += spaceTrim$1('\n\n' + personaDescription);
|
|
12003
12145
|
}
|
|
12004
12146
|
|
|
12005
12147
|
/**
|
|
@@ -12364,7 +12506,7 @@ const COMMANDS = [
|
|
|
12364
12506
|
function getParserForCommand(command) {
|
|
12365
12507
|
const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
|
|
12366
12508
|
if (commandParser === undefined) {
|
|
12367
|
-
throw new UnexpectedError(spaceTrim$
|
|
12509
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
12368
12510
|
Command ${command.type} parser is not found
|
|
12369
12511
|
|
|
12370
12512
|
${block(JSON.stringify(command, null, 4)
|
|
@@ -12440,7 +12582,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
12440
12582
|
.map(removeMarkdownFormatting)
|
|
12441
12583
|
.map((item) => item.trim());
|
|
12442
12584
|
if (items.length === 0 || items[0] === '') {
|
|
12443
|
-
throw new ParseError(spaceTrim$
|
|
12585
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
12444
12586
|
Malformed command:
|
|
12445
12587
|
- ${raw}
|
|
12446
12588
|
|
|
@@ -12476,7 +12618,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
12476
12618
|
return command;
|
|
12477
12619
|
}
|
|
12478
12620
|
}
|
|
12479
|
-
throw new ParseError(spaceTrim$
|
|
12621
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
12480
12622
|
Malformed or unknown command:
|
|
12481
12623
|
- ${raw}
|
|
12482
12624
|
|
|
@@ -12527,7 +12669,7 @@ function parseCommandVariant(input) {
|
|
|
12527
12669
|
if (!(error instanceof ParseError)) {
|
|
12528
12670
|
throw error;
|
|
12529
12671
|
}
|
|
12530
|
-
throw new ParseError(spaceTrim$
|
|
12672
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
12531
12673
|
Invalid ${commandName} command:
|
|
12532
12674
|
|
|
12533
12675
|
Your command:
|
|
@@ -12801,7 +12943,7 @@ const SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
|
|
|
12801
12943
|
* @public exported from `@promptbook/markdown-utils`
|
|
12802
12944
|
*/
|
|
12803
12945
|
function removeMarkdownComments(content) {
|
|
12804
|
-
return spaceTrim$
|
|
12946
|
+
return spaceTrim$2(content.replace(/<!--(.*?)-->/gs, ''));
|
|
12805
12947
|
}
|
|
12806
12948
|
|
|
12807
12949
|
/**
|
|
@@ -12812,7 +12954,7 @@ function removeMarkdownComments(content) {
|
|
|
12812
12954
|
*/
|
|
12813
12955
|
function isFlatPipeline(pipelineString) {
|
|
12814
12956
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
12815
|
-
pipelineString = spaceTrim(pipelineString);
|
|
12957
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
12816
12958
|
const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
12817
12959
|
//const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
|
|
12818
12960
|
const isBacktickBlockUsed = pipelineString.includes('```');
|
|
@@ -12838,7 +12980,7 @@ function deflatePipeline(pipelineString) {
|
|
|
12838
12980
|
if (!isFlatPipeline(pipelineString)) {
|
|
12839
12981
|
return pipelineString;
|
|
12840
12982
|
}
|
|
12841
|
-
pipelineString = spaceTrim(pipelineString);
|
|
12983
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
12842
12984
|
const pipelineStringLines = pipelineString.split('\n');
|
|
12843
12985
|
const potentialReturnStatement = pipelineStringLines.pop();
|
|
12844
12986
|
let returnStatement;
|
|
@@ -12851,19 +12993,19 @@ function deflatePipeline(pipelineString) {
|
|
|
12851
12993
|
returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
|
|
12852
12994
|
pipelineStringLines.push(potentialReturnStatement);
|
|
12853
12995
|
}
|
|
12854
|
-
const prompt = spaceTrim(pipelineStringLines.join('\n'));
|
|
12996
|
+
const prompt = spaceTrim$1(pipelineStringLines.join('\n'));
|
|
12855
12997
|
let quotedPrompt;
|
|
12856
12998
|
if (prompt.split('\n').length <= 1) {
|
|
12857
12999
|
quotedPrompt = `> ${prompt}`;
|
|
12858
13000
|
}
|
|
12859
13001
|
else {
|
|
12860
|
-
quotedPrompt = spaceTrim((block) => `
|
|
13002
|
+
quotedPrompt = spaceTrim$1((block) => `
|
|
12861
13003
|
\`\`\`
|
|
12862
13004
|
${block(prompt.split('`').join('\\`'))}
|
|
12863
13005
|
\`\`\`
|
|
12864
13006
|
`);
|
|
12865
13007
|
}
|
|
12866
|
-
pipelineString = validatePipelineString(spaceTrim((block) => `
|
|
13008
|
+
pipelineString = validatePipelineString(spaceTrim$1((block) => `
|
|
12867
13009
|
# ${DEFAULT_BOOK_TITLE}
|
|
12868
13010
|
|
|
12869
13011
|
## Prompt
|
|
@@ -12927,7 +13069,7 @@ function extractAllListItemsFromMarkdown(markdown) {
|
|
|
12927
13069
|
function extractOneBlockFromMarkdown(markdown) {
|
|
12928
13070
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
12929
13071
|
if (codeBlocks.length !== 1) {
|
|
12930
|
-
throw new ParseError(spaceTrim((block) => `
|
|
13072
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
12931
13073
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
12932
13074
|
|
|
12933
13075
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -12952,7 +13094,7 @@ function parseMarkdownSection(value) {
|
|
|
12952
13094
|
}
|
|
12953
13095
|
const title = lines[0].replace(/^#+\s*/, '');
|
|
12954
13096
|
const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
12955
|
-
const content = spaceTrim(lines.slice(1).join('\n'));
|
|
13097
|
+
const content = spaceTrim$1(lines.slice(1).join('\n'));
|
|
12956
13098
|
if (level < 1 || level > 6) {
|
|
12957
13099
|
throw new ParseError('Markdown section must have heading level between 1 and 6');
|
|
12958
13100
|
}
|
|
@@ -12980,7 +13122,7 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
12980
13122
|
if (buffer.length === 0) {
|
|
12981
13123
|
return;
|
|
12982
13124
|
}
|
|
12983
|
-
let section = spaceTrim(buffer.join('\n'));
|
|
13125
|
+
let section = spaceTrim$1(buffer.join('\n'));
|
|
12984
13126
|
if (section === '') {
|
|
12985
13127
|
return;
|
|
12986
13128
|
}
|
|
@@ -13055,7 +13197,7 @@ function flattenMarkdown(markdown) {
|
|
|
13055
13197
|
flattenedMarkdown += `## ${title}` + `\n\n`;
|
|
13056
13198
|
flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
|
|
13057
13199
|
}
|
|
13058
|
-
return spaceTrim(flattenedMarkdown);
|
|
13200
|
+
return spaceTrim$1(flattenedMarkdown);
|
|
13059
13201
|
}
|
|
13060
13202
|
/**
|
|
13061
13203
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -13117,7 +13259,7 @@ function parsePipeline(pipelineString) {
|
|
|
13117
13259
|
if (pipelineString.startsWith('#!')) {
|
|
13118
13260
|
const [shebangLine, ...restLines] = pipelineString.split('\n');
|
|
13119
13261
|
if (!(shebangLine || '').includes('ptbk')) {
|
|
13120
|
-
throw new ParseError(spaceTrim$
|
|
13262
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
13121
13263
|
It seems that you try to parse a book file which has non-standard shebang line for book files:
|
|
13122
13264
|
Shebang line must contain 'ptbk'
|
|
13123
13265
|
|
|
@@ -13133,7 +13275,7 @@ function parsePipeline(pipelineString) {
|
|
|
13133
13275
|
pipelineString = validatePipelineString(restLines.join('\n'));
|
|
13134
13276
|
}
|
|
13135
13277
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
13136
|
-
pipelineString = spaceTrim$
|
|
13278
|
+
pipelineString = spaceTrim$2(pipelineString);
|
|
13137
13279
|
// <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
|
|
13138
13280
|
pipelineString = deflatePipeline(pipelineString);
|
|
13139
13281
|
// ==============
|
|
@@ -13145,7 +13287,7 @@ function parsePipeline(pipelineString) {
|
|
|
13145
13287
|
// ==============
|
|
13146
13288
|
// Note: 1️⃣◽4️⃣ Check markdown structure
|
|
13147
13289
|
if (pipelineHead === undefined) {
|
|
13148
|
-
throw new UnexpectedError(spaceTrim$
|
|
13290
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
13149
13291
|
Pipeline head is not defined
|
|
13150
13292
|
|
|
13151
13293
|
${block(getPipelineIdentification())}
|
|
@@ -13154,7 +13296,7 @@ function parsePipeline(pipelineString) {
|
|
|
13154
13296
|
`));
|
|
13155
13297
|
}
|
|
13156
13298
|
if (pipelineHead.level !== 1) {
|
|
13157
|
-
throw new UnexpectedError(spaceTrim$
|
|
13299
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
13158
13300
|
Pipeline head is not h1
|
|
13159
13301
|
|
|
13160
13302
|
${block(getPipelineIdentification())}
|
|
@@ -13163,7 +13305,7 @@ function parsePipeline(pipelineString) {
|
|
|
13163
13305
|
`));
|
|
13164
13306
|
}
|
|
13165
13307
|
if (!pipelineSections.every((section) => section.level === 2)) {
|
|
13166
|
-
throw new UnexpectedError(spaceTrim$
|
|
13308
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
13167
13309
|
Not every pipeline section is h2
|
|
13168
13310
|
|
|
13169
13311
|
${block(getPipelineIdentification())}
|
|
@@ -13176,7 +13318,7 @@ function parsePipeline(pipelineString) {
|
|
|
13176
13318
|
const defineParam = (parameterCommand) => {
|
|
13177
13319
|
const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
|
|
13178
13320
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
13179
|
-
throw new ParseError(spaceTrim$
|
|
13321
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
13180
13322
|
Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
|
|
13181
13323
|
|
|
13182
13324
|
${block(getPipelineIdentification())}
|
|
@@ -13187,7 +13329,7 @@ function parsePipeline(pipelineString) {
|
|
|
13187
13329
|
existingParameter.description &&
|
|
13188
13330
|
existingParameter.description !== parameterDescription &&
|
|
13189
13331
|
parameterDescription) {
|
|
13190
|
-
throw new ParseError(spaceTrim$
|
|
13332
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
13191
13333
|
Parameter \`{${parameterName}}\` is defined multiple times with different description:
|
|
13192
13334
|
|
|
13193
13335
|
${block(getPipelineIdentification())}
|
|
@@ -13225,7 +13367,7 @@ function parsePipeline(pipelineString) {
|
|
|
13225
13367
|
description = description.split(/^>.*$/gm).join('');
|
|
13226
13368
|
//Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
|
|
13227
13369
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
13228
|
-
description = spaceTrim$
|
|
13370
|
+
description = spaceTrim$2(description);
|
|
13229
13371
|
if (description === '') {
|
|
13230
13372
|
description = undefined;
|
|
13231
13373
|
}
|
|
@@ -13236,7 +13378,7 @@ function parsePipeline(pipelineString) {
|
|
|
13236
13378
|
const command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
13237
13379
|
const commandParser = getParserForCommand(command);
|
|
13238
13380
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
13239
|
-
throw new ParseError(spaceTrim$
|
|
13381
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
13240
13382
|
Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
|
|
13241
13383
|
|
|
13242
13384
|
${block(getPipelineIdentification())}
|
|
@@ -13250,7 +13392,7 @@ function parsePipeline(pipelineString) {
|
|
|
13250
13392
|
if (!(error instanceof ParseError)) {
|
|
13251
13393
|
throw error;
|
|
13252
13394
|
}
|
|
13253
|
-
throw new ParseError(spaceTrim$
|
|
13395
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
13254
13396
|
Command ${command.type} failed to apply to the pipeline
|
|
13255
13397
|
|
|
13256
13398
|
The error:
|
|
@@ -13303,7 +13445,7 @@ function parsePipeline(pipelineString) {
|
|
|
13303
13445
|
description = description.split(/^>.*$/gm).join('');
|
|
13304
13446
|
//Note: Remove lists and return statement - TODO: [🎾]
|
|
13305
13447
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
13306
|
-
description = spaceTrim$
|
|
13448
|
+
description = spaceTrim$2(description);
|
|
13307
13449
|
if (description === '') {
|
|
13308
13450
|
description = undefined;
|
|
13309
13451
|
}
|
|
@@ -13337,7 +13479,7 @@ function parsePipeline(pipelineString) {
|
|
|
13337
13479
|
for (const { listItem, command } of commands) {
|
|
13338
13480
|
const commandParser = getParserForCommand(command);
|
|
13339
13481
|
if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
|
|
13340
|
-
throw new ParseError(spaceTrim$
|
|
13482
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
13341
13483
|
Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
|
|
13342
13484
|
|
|
13343
13485
|
${block(getPipelineIdentification())}
|
|
@@ -13352,7 +13494,7 @@ function parsePipeline(pipelineString) {
|
|
|
13352
13494
|
if (!(error instanceof ParseError)) {
|
|
13353
13495
|
throw error;
|
|
13354
13496
|
}
|
|
13355
|
-
throw new ParseError(spaceTrim$
|
|
13497
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
13356
13498
|
Command \`${command.type}\` failed to apply to the task
|
|
13357
13499
|
|
|
13358
13500
|
The error:
|
|
@@ -13383,14 +13525,14 @@ function parsePipeline(pipelineString) {
|
|
|
13383
13525
|
// TODO: [🍧] Should be done in SECTION command
|
|
13384
13526
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
13385
13527
|
if (!language) {
|
|
13386
|
-
throw new ParseError(spaceTrim$
|
|
13528
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
13387
13529
|
You must specify the language of the script in the \`SCRIPT\` task
|
|
13388
13530
|
|
|
13389
13531
|
${block(getPipelineIdentification())}
|
|
13390
13532
|
`));
|
|
13391
13533
|
}
|
|
13392
13534
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
13393
|
-
throw new ParseError(spaceTrim$
|
|
13535
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
13394
13536
|
Script language ${language} is not supported.
|
|
13395
13537
|
|
|
13396
13538
|
Supported languages are:
|
|
@@ -13552,7 +13694,7 @@ function addAutoGeneratedSection(content, options) {
|
|
|
13552
13694
|
const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
|
|
13553
13695
|
const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
|
|
13554
13696
|
const sectionMatch = content.match(sectionRegex);
|
|
13555
|
-
const contentToInsert = spaceTrim$
|
|
13697
|
+
const contentToInsert = spaceTrim$2((block) => `
|
|
13556
13698
|
<!--${sectionName}-->
|
|
13557
13699
|
${block(warningLine)}
|
|
13558
13700
|
${block(sectionContent)}
|
|
@@ -13565,7 +13707,7 @@ function addAutoGeneratedSection(content, options) {
|
|
|
13565
13707
|
const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
|
|
13566
13708
|
if (placeForSection !== null) {
|
|
13567
13709
|
const [heading] = placeForSection;
|
|
13568
|
-
return content.replace(heading, spaceTrim$
|
|
13710
|
+
return content.replace(heading, spaceTrim$2((block) => `
|
|
13569
13711
|
${block(contentToInsert)}
|
|
13570
13712
|
|
|
13571
13713
|
${block(heading)}
|
|
@@ -13574,7 +13716,7 @@ function addAutoGeneratedSection(content, options) {
|
|
|
13574
13716
|
console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
|
|
13575
13717
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
13576
13718
|
// <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
|
|
13577
|
-
return spaceTrim$
|
|
13719
|
+
return spaceTrim$2((block) => `
|
|
13578
13720
|
${block(content)}
|
|
13579
13721
|
|
|
13580
13722
|
${block(contentToInsert)}
|
|
@@ -13650,7 +13792,7 @@ function renderPromptbookMermaid(pipelineJson, options) {
|
|
|
13650
13792
|
.filter(([MERMAID_NAME]) => (inputAndIntermediateParametersMermaid + outputParametersMermaid).includes(MERMAID_NAME))
|
|
13651
13793
|
.map(([MERMAID_NAME, title]) => `${MERMAID_NAME}((${title})):::${MERMAID_NAME}`)
|
|
13652
13794
|
.join('\n');
|
|
13653
|
-
const promptbookMermaid = spaceTrim$
|
|
13795
|
+
const promptbookMermaid = spaceTrim$2((block) => `
|
|
13654
13796
|
|
|
13655
13797
|
%% 🔮 Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually
|
|
13656
13798
|
|
|
@@ -13706,7 +13848,7 @@ async function prettifyPipelineString(pipelineString, options) {
|
|
|
13706
13848
|
return { href: `#${task.name}`, title: task.title };
|
|
13707
13849
|
},
|
|
13708
13850
|
});
|
|
13709
|
-
const promptbookMermaidBlock = spaceTrim$
|
|
13851
|
+
const promptbookMermaidBlock = spaceTrim$2((block) => `
|
|
13710
13852
|
\`\`\`mermaid
|
|
13711
13853
|
${block(promptbookMermaid)}
|
|
13712
13854
|
\`\`\`
|
|
@@ -13744,7 +13886,7 @@ class CallbackInterfaceTools {
|
|
|
13744
13886
|
async promptDialog(options) {
|
|
13745
13887
|
const answer = await this.options.callback(options);
|
|
13746
13888
|
if (this.options.isVerbose) {
|
|
13747
|
-
console.info(spaceTrim$
|
|
13889
|
+
console.info(spaceTrim$2((block) => `
|
|
13748
13890
|
📖 ${block(options.promptTitle)}
|
|
13749
13891
|
👤 ${block(answer)}
|
|
13750
13892
|
`));
|
|
@@ -13885,7 +14027,7 @@ function countWorkingDuration(items) {
|
|
|
13885
14027
|
function executionReportJsonToString(executionReportJson, options) {
|
|
13886
14028
|
var _a, _b, _c, _d, _e, _f;
|
|
13887
14029
|
const { taxRate, chartsWidth } = { ...ExecutionReportStringOptionsDefaults, ...(options || {}) };
|
|
13888
|
-
let executionReportString = spaceTrim$
|
|
14030
|
+
let executionReportString = spaceTrim$2((block) => `
|
|
13889
14031
|
# ${executionReportJson.title || 'Execution report'}
|
|
13890
14032
|
|
|
13891
14033
|
${block(executionReportJson.description || '')}
|
|
@@ -14007,7 +14149,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
14007
14149
|
if (just(true)) {
|
|
14008
14150
|
executionReportString +=
|
|
14009
14151
|
'\n\n\n\n' +
|
|
14010
|
-
spaceTrim$
|
|
14152
|
+
spaceTrim$2((block) => {
|
|
14011
14153
|
var _a;
|
|
14012
14154
|
return `
|
|
14013
14155
|
|
|
@@ -14026,7 +14168,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
14026
14168
|
executionReportString += '*No result*';
|
|
14027
14169
|
}
|
|
14028
14170
|
else if (typeof promptExecution.result.content === 'string') {
|
|
14029
|
-
executionReportString += spaceTrim$
|
|
14171
|
+
executionReportString += spaceTrim$2((block) => `
|
|
14030
14172
|
\`\`\`
|
|
14031
14173
|
${block(escapeMarkdownBlock(promptExecution.result.content))}
|
|
14032
14174
|
\`\`\`
|
|
@@ -14039,7 +14181,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
14039
14181
|
if (promptExecution.error && promptExecution.error.message) {
|
|
14040
14182
|
executionReportString +=
|
|
14041
14183
|
'\n\n\n\n' +
|
|
14042
|
-
spaceTrim$
|
|
14184
|
+
spaceTrim$2((block) => `
|
|
14043
14185
|
|
|
14044
14186
|
### Error
|
|
14045
14187
|
|
|
@@ -14115,7 +14257,7 @@ function usageToHuman(usage) {
|
|
|
14115
14257
|
// Note: For negligible usage, we report at least something
|
|
14116
14258
|
reportItems.push('Negligible');
|
|
14117
14259
|
}
|
|
14118
|
-
return spaceTrim((block) => `
|
|
14260
|
+
return spaceTrim$1((block) => `
|
|
14119
14261
|
Usage:
|
|
14120
14262
|
${block(reportItems.map((item) => `- ${item}`).join('\n'))}
|
|
14121
14263
|
`);
|
|
@@ -14357,13 +14499,13 @@ function $registeredLlmToolsMessage() {
|
|
|
14357
14499
|
});
|
|
14358
14500
|
const usedEnvMessage = `Unknown \`.env\` file` ;
|
|
14359
14501
|
if (metadata.length === 0) {
|
|
14360
|
-
return spaceTrim((block) => `
|
|
14502
|
+
return spaceTrim$1((block) => `
|
|
14361
14503
|
No LLM providers are available.
|
|
14362
14504
|
|
|
14363
14505
|
${block(usedEnvMessage)}
|
|
14364
14506
|
`);
|
|
14365
14507
|
}
|
|
14366
|
-
return spaceTrim((block) => `
|
|
14508
|
+
return spaceTrim$1((block) => `
|
|
14367
14509
|
|
|
14368
14510
|
${block(usedEnvMessage)}
|
|
14369
14511
|
|
|
@@ -14409,7 +14551,7 @@ function $registeredLlmToolsMessage() {
|
|
|
14409
14551
|
morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
|
|
14410
14552
|
}
|
|
14411
14553
|
}
|
|
14412
|
-
let providerMessage = spaceTrim(`
|
|
14554
|
+
let providerMessage = spaceTrim$1(`
|
|
14413
14555
|
${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
|
|
14414
14556
|
${morePieces.join('; ')}
|
|
14415
14557
|
`);
|
|
@@ -14455,7 +14597,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
|
|
|
14455
14597
|
.find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
|
|
14456
14598
|
if (registeredItem === undefined) {
|
|
14457
14599
|
// console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
|
|
14458
|
-
throw new Error(spaceTrim((block) => `
|
|
14600
|
+
throw new Error(spaceTrim$1((block) => `
|
|
14459
14601
|
There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
|
|
14460
14602
|
Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
|
|
14461
14603
|
|
|
@@ -14592,7 +14734,7 @@ function cacheLlmTools(llmTools, options = {}) {
|
|
|
14592
14734
|
let normalizedContent = content;
|
|
14593
14735
|
normalizedContent = normalizedContent.replace(/\s+/g, ' ');
|
|
14594
14736
|
normalizedContent = normalizedContent.split('\r\n').join('\n');
|
|
14595
|
-
normalizedContent = spaceTrim(normalizedContent);
|
|
14737
|
+
normalizedContent = spaceTrim$1(normalizedContent);
|
|
14596
14738
|
// Note: Do not need to save everything in the cache, just the relevant parameters
|
|
14597
14739
|
const relevantParameterNames = extractParameterNames(content);
|
|
14598
14740
|
const relevantParameters = Object.fromEntries(Object.entries(parameters).filter(([key]) => relevantParameterNames.has(key)));
|
|
@@ -14798,66 +14940,6 @@ function asUpdatableSubject(value) {
|
|
|
14798
14940
|
* TODO: [🧠] Maybe `BehaviorSubject` is too heavy for this use case, maybe just tuple `[value,setValue]` is enough
|
|
14799
14941
|
*/
|
|
14800
14942
|
|
|
14801
|
-
/**
|
|
14802
|
-
* Represents one AI Agent
|
|
14803
|
-
*
|
|
14804
|
-
* Note: [🦖] There are several different things in Promptbook:
|
|
14805
|
-
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
14806
|
-
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
14807
|
-
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
14808
|
-
* - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
|
|
14809
|
-
*
|
|
14810
|
-
* @public exported from `@promptbook/core`
|
|
14811
|
-
*/
|
|
14812
|
-
class Agent {
|
|
14813
|
-
/**
|
|
14814
|
-
* Not used in Agent, always returns empty array
|
|
14815
|
-
*/
|
|
14816
|
-
get parameters() {
|
|
14817
|
-
return [
|
|
14818
|
-
/* [😰] */
|
|
14819
|
-
];
|
|
14820
|
-
}
|
|
14821
|
-
constructor(options) {
|
|
14822
|
-
this.options = options;
|
|
14823
|
-
/**
|
|
14824
|
-
* Name of the agent
|
|
14825
|
-
*/
|
|
14826
|
-
this.agentName = null;
|
|
14827
|
-
/**
|
|
14828
|
-
* Description of the agent
|
|
14829
|
-
*/
|
|
14830
|
-
this.personaDescription = null;
|
|
14831
|
-
/**
|
|
14832
|
-
* Metadata like image or color
|
|
14833
|
-
*/
|
|
14834
|
-
this.meta = {};
|
|
14835
|
-
this.agentSource = asUpdatableSubject(options.agentSource);
|
|
14836
|
-
this.agentSource.subscribe((source) => {
|
|
14837
|
-
const { agentName, personaDescription, meta } = parseAgentSource(source);
|
|
14838
|
-
this.agentName = agentName;
|
|
14839
|
-
this.personaDescription = personaDescription;
|
|
14840
|
-
this.meta = { ...this.meta, ...meta };
|
|
14841
|
-
});
|
|
14842
|
-
}
|
|
14843
|
-
/**
|
|
14844
|
-
* Creates LlmExecutionTools which exposes the agent as a model
|
|
14845
|
-
*/
|
|
14846
|
-
getLlmExecutionTools() {
|
|
14847
|
-
const llmTools = new AgentLlmExecutionTools({
|
|
14848
|
-
llmTools: getSingleLlmExecutionTools(this.options.executionTools.llm),
|
|
14849
|
-
agentSource: this.agentSource.value, // <- TODO: !!!! Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
|
|
14850
|
-
});
|
|
14851
|
-
// TODO: !!!! Add `Agent` simple "mocked" learning by appending to agent source
|
|
14852
|
-
// TODO: !!!! Add `Agent` learning by promptbookAgent
|
|
14853
|
-
return llmTools;
|
|
14854
|
-
}
|
|
14855
|
-
}
|
|
14856
|
-
/**
|
|
14857
|
-
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
14858
|
-
* TODO: !!! Agent on remote server
|
|
14859
|
-
*/
|
|
14860
|
-
|
|
14861
14943
|
/**
|
|
14862
14944
|
* Change ellipsis character to three dots `…` -> `...`
|
|
14863
14945
|
*
|
|
@@ -15047,7 +15129,7 @@ function pricing(value) {
|
|
|
15047
15129
|
/**
|
|
15048
15130
|
* List of available OpenAI models with pricing
|
|
15049
15131
|
*
|
|
15050
|
-
* Note: Synced with official API docs at 2025-
|
|
15132
|
+
* Note: Synced with official API docs at 2025-11-19
|
|
15051
15133
|
*
|
|
15052
15134
|
* @see https://platform.openai.com/docs/models/
|
|
15053
15135
|
* @see https://openai.com/api/pricing/
|
|
@@ -15057,11 +15139,21 @@ const OPENAI_MODELS = exportJson({
|
|
|
15057
15139
|
name: 'OPENAI_MODELS',
|
|
15058
15140
|
value: [
|
|
15059
15141
|
/**/
|
|
15142
|
+
{
|
|
15143
|
+
modelVariant: 'CHAT',
|
|
15144
|
+
modelTitle: 'gpt-5.1',
|
|
15145
|
+
modelName: 'gpt-5.1',
|
|
15146
|
+
modelDescription: 'The best model for coding and agentic tasks with configurable reasoning effort.',
|
|
15147
|
+
pricing: {
|
|
15148
|
+
prompt: pricing(`$1.25 / 1M tokens`),
|
|
15149
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
15150
|
+
},
|
|
15151
|
+
},
|
|
15060
15152
|
{
|
|
15061
15153
|
modelVariant: 'CHAT',
|
|
15062
15154
|
modelTitle: 'gpt-5',
|
|
15063
15155
|
modelName: 'gpt-5',
|
|
15064
|
-
modelDescription: "OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window. Features revolutionary improvements in complex problem-solving, scientific reasoning, and creative tasks. Demonstrates human-level performance across diverse domains with enhanced safety measures and alignment. Represents the next generation of AI with superior understanding, nuanced responses, and advanced multimodal capabilities.",
|
|
15156
|
+
modelDescription: "OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window. Features revolutionary improvements in complex problem-solving, scientific reasoning, and creative tasks. Demonstrates human-level performance across diverse domains with enhanced safety measures and alignment. Represents the next generation of AI with superior understanding, nuanced responses, and advanced multimodal capabilities. DEPRECATED: Use gpt-5.1 instead.",
|
|
15065
15157
|
pricing: {
|
|
15066
15158
|
prompt: pricing(`$1.25 / 1M tokens`),
|
|
15067
15159
|
output: pricing(`$10.00 / 1M tokens`),
|
|
@@ -16259,7 +16351,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
16259
16351
|
// Note: Match exact or prefix for model families
|
|
16260
16352
|
const model = this.HARDCODED_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
|
|
16261
16353
|
if (model === undefined) {
|
|
16262
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
16354
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
16263
16355
|
Cannot find model in ${this.title} models with name "${defaultModelName}" which should be used as default.
|
|
16264
16356
|
|
|
16265
16357
|
Available models:
|
|
@@ -16622,11 +16714,11 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
16622
16714
|
if (!this.isCreatingNewAssistantsAllowed) {
|
|
16623
16715
|
throw new NotAllowed(`Creating new assistants is not allowed. Set \`isCreatingNewAssistantsAllowed: true\` in options to enable this feature.`);
|
|
16624
16716
|
}
|
|
16625
|
-
await this.playground();
|
|
16717
|
+
// await this.playground();
|
|
16626
16718
|
const { name, instructions } = options;
|
|
16627
16719
|
const client = await this.getClient();
|
|
16628
|
-
|
|
16629
|
-
TODO: !!!
|
|
16720
|
+
/*/
|
|
16721
|
+
//TODO: !!!
|
|
16630
16722
|
async function downloadFile(url: string, folder = './tmp'): Promise<string> {
|
|
16631
16723
|
const filename = path.basename(url.split('?')[0]);
|
|
16632
16724
|
const filepath = path.join(folder, filename);
|
|
@@ -16670,8 +16762,8 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
16670
16762
|
const file = await uploadFileToOpenAI(filepath);
|
|
16671
16763
|
uploadedFiles.push(file.id);
|
|
16672
16764
|
}
|
|
16673
|
-
|
|
16674
|
-
alert('!!!! Creating new OpenAI assistant');
|
|
16765
|
+
/**/
|
|
16766
|
+
// alert('!!!! Creating new OpenAI assistant');
|
|
16675
16767
|
// 3️⃣ Create assistant with uploaded files
|
|
16676
16768
|
const assistant = await client.beta.assistants.create({
|
|
16677
16769
|
name,
|
|
@@ -16832,15 +16924,27 @@ class AgentLlmExecutionTools {
|
|
|
16832
16924
|
const chatPrompt = prompt;
|
|
16833
16925
|
let underlyingLlmResult;
|
|
16834
16926
|
if (OpenAiAssistantExecutionTools.isOpenAiAssistantExecutionTools(this.options.llmTools)) {
|
|
16927
|
+
if (this.options.isVerbose) {
|
|
16928
|
+
console.log(`Creating new OpenAI Assistant for agent ${this.title}...`);
|
|
16929
|
+
}
|
|
16835
16930
|
// <- TODO: !!! Check also `isCreatingNewAssistantsAllowed` and warn about it
|
|
16836
16931
|
const assistant = await this.options.llmTools.createNewAssistant({
|
|
16837
16932
|
name: this.title,
|
|
16838
16933
|
instructions: modelRequirements.systemMessage,
|
|
16934
|
+
/*
|
|
16935
|
+
!!!
|
|
16936
|
+
metadata: {
|
|
16937
|
+
agentModelName: this.modelName,
|
|
16938
|
+
}
|
|
16939
|
+
*/
|
|
16839
16940
|
});
|
|
16840
16941
|
// <- TODO: !!! Cache the assistant in prepareCache
|
|
16841
16942
|
underlyingLlmResult = await assistant.callChatModel(chatPrompt);
|
|
16842
16943
|
}
|
|
16843
16944
|
else {
|
|
16945
|
+
if (this.options.isVerbose) {
|
|
16946
|
+
console.log(`Creating Assistant ${this.title} on generic LLM execution tools...`);
|
|
16947
|
+
}
|
|
16844
16948
|
// Create modified chat prompt with agent system message
|
|
16845
16949
|
const modifiedChatPrompt = {
|
|
16846
16950
|
...chatPrompt,
|
|
@@ -16874,6 +16978,67 @@ class AgentLlmExecutionTools {
|
|
|
16874
16978
|
* TODO: [🧠] Adding parameter substitution support (here or should be responsibility of the underlying LLM Tools)
|
|
16875
16979
|
*/
|
|
16876
16980
|
|
|
16981
|
+
/**
|
|
16982
|
+
* Represents one AI Agent
|
|
16983
|
+
*
|
|
16984
|
+
* Note: [🦖] There are several different things in Promptbook:
|
|
16985
|
+
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
16986
|
+
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
16987
|
+
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
16988
|
+
* - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
|
|
16989
|
+
*
|
|
16990
|
+
* @public exported from `@promptbook/core`
|
|
16991
|
+
*/
|
|
16992
|
+
class Agent {
|
|
16993
|
+
/**
|
|
16994
|
+
* Not used in Agent, always returns empty array
|
|
16995
|
+
*/
|
|
16996
|
+
get parameters() {
|
|
16997
|
+
return [
|
|
16998
|
+
/* [😰] */
|
|
16999
|
+
];
|
|
17000
|
+
}
|
|
17001
|
+
constructor(options) {
|
|
17002
|
+
this.options = options;
|
|
17003
|
+
/**
|
|
17004
|
+
* Name of the agent
|
|
17005
|
+
*/
|
|
17006
|
+
this.agentName = null;
|
|
17007
|
+
/**
|
|
17008
|
+
* Description of the agent
|
|
17009
|
+
*/
|
|
17010
|
+
this.personaDescription = null;
|
|
17011
|
+
/**
|
|
17012
|
+
* Metadata like image or color
|
|
17013
|
+
*/
|
|
17014
|
+
this.meta = {};
|
|
17015
|
+
this.agentSource = asUpdatableSubject(options.agentSource);
|
|
17016
|
+
this.agentSource.subscribe((source) => {
|
|
17017
|
+
const { agentName, personaDescription, meta } = parseAgentSource(source);
|
|
17018
|
+
this.agentName = agentName;
|
|
17019
|
+
this.personaDescription = personaDescription;
|
|
17020
|
+
this.meta = { ...this.meta, ...meta };
|
|
17021
|
+
});
|
|
17022
|
+
}
|
|
17023
|
+
/**
|
|
17024
|
+
* Creates LlmExecutionTools which exposes the agent as a model
|
|
17025
|
+
*/
|
|
17026
|
+
getLlmExecutionTools() {
|
|
17027
|
+
const llmTools = new AgentLlmExecutionTools({
|
|
17028
|
+
isVerbose: this.options.isVerbose,
|
|
17029
|
+
llmTools: getSingleLlmExecutionTools(this.options.executionTools.llm),
|
|
17030
|
+
agentSource: this.agentSource.value, // <- TODO: !!!! Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
|
|
17031
|
+
});
|
|
17032
|
+
// TODO: !!!! Add `Agent` simple "mocked" learning by appending to agent source
|
|
17033
|
+
// TODO: !!!! Add `Agent` learning by promptbookAgent
|
|
17034
|
+
return llmTools;
|
|
17035
|
+
}
|
|
17036
|
+
}
|
|
17037
|
+
/**
|
|
17038
|
+
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
17039
|
+
* TODO: !!! Agent on remote server
|
|
17040
|
+
*/
|
|
17041
|
+
|
|
16877
17042
|
/**
|
|
16878
17043
|
* Creates new AgentLlmExecutionTools that wrap underlying LLM tools with agent-specific behavior
|
|
16879
17044
|
*
|
|
@@ -17440,7 +17605,7 @@ function isValidPipelineString(pipelineString) {
|
|
|
17440
17605
|
*/
|
|
17441
17606
|
function prompt(strings, ...values) {
|
|
17442
17607
|
if (values.length === 0) {
|
|
17443
|
-
return spaceTrim(strings.join(''));
|
|
17608
|
+
return spaceTrim$1(strings.join(''));
|
|
17444
17609
|
}
|
|
17445
17610
|
const stringsWithHiddenParameters = strings.map((stringsItem) =>
|
|
17446
17611
|
// TODO: [0] DRY
|
|
@@ -17451,7 +17616,7 @@ function prompt(strings, ...values) {
|
|
|
17451
17616
|
let pipelineString = stringsWithHiddenParameters.reduce((result, stringsItem, i) => placeholderParameterNames[i] === undefined
|
|
17452
17617
|
? `${result}${stringsItem}`
|
|
17453
17618
|
: `${result}${stringsItem}{${placeholderParameterNames[i]}}`, '');
|
|
17454
|
-
pipelineString = spaceTrim(pipelineString);
|
|
17619
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
17455
17620
|
try {
|
|
17456
17621
|
pipelineString = templateParameters(pipelineString, parameters);
|
|
17457
17622
|
}
|
|
@@ -17460,7 +17625,7 @@ function prompt(strings, ...values) {
|
|
|
17460
17625
|
throw error;
|
|
17461
17626
|
}
|
|
17462
17627
|
console.error({ pipelineString, parameters, placeholderParameterNames, error });
|
|
17463
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
17628
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
17464
17629
|
Internal error in prompt template literal
|
|
17465
17630
|
|
|
17466
17631
|
${block(JSON.stringify({ strings, values }, null, 4))}}
|
|
@@ -17497,7 +17662,7 @@ function book(strings, ...values) {
|
|
|
17497
17662
|
const bookString = prompt(strings, ...values);
|
|
17498
17663
|
if (!isValidPipelineString(bookString)) {
|
|
17499
17664
|
// TODO: Make the CustomError for this
|
|
17500
|
-
throw new Error(spaceTrim(`
|
|
17665
|
+
throw new Error(spaceTrim$1(`
|
|
17501
17666
|
The string is not a valid pipeline string
|
|
17502
17667
|
|
|
17503
17668
|
book\`
|
|
@@ -17507,7 +17672,7 @@ function book(strings, ...values) {
|
|
|
17507
17672
|
}
|
|
17508
17673
|
if (!isValidBook(bookString)) {
|
|
17509
17674
|
// TODO: Make the CustomError for this
|
|
17510
|
-
throw new Error(spaceTrim(`
|
|
17675
|
+
throw new Error(spaceTrim$1(`
|
|
17511
17676
|
The string is not a valid book
|
|
17512
17677
|
|
|
17513
17678
|
book\`
|
|
@@ -17929,7 +18094,7 @@ const OpenAiSdkTranspiler = {
|
|
|
17929
18094
|
});
|
|
17930
18095
|
const KNOWLEDGE_THRESHOLD = 1000;
|
|
17931
18096
|
if (directKnowledge.join('\n').length > KNOWLEDGE_THRESHOLD || knowledgeSources.length > 0) {
|
|
17932
|
-
return spaceTrim((block) => `
|
|
18097
|
+
return spaceTrim$1((block) => `
|
|
17933
18098
|
#!/usr/bin/env node
|
|
17934
18099
|
|
|
17935
18100
|
import * as dotenv from 'dotenv';
|
|
@@ -17994,7 +18159,7 @@ const OpenAiSdkTranspiler = {
|
|
|
17994
18159
|
}
|
|
17995
18160
|
|
|
17996
18161
|
const userMessage = spaceTrim(\`
|
|
17997
|
-
${block(spaceTrim(`
|
|
18162
|
+
${block(spaceTrim$1(`
|
|
17998
18163
|
Here is some additional context to help you answer the question:
|
|
17999
18164
|
\${context}
|
|
18000
18165
|
|
|
@@ -18039,7 +18204,7 @@ const OpenAiSdkTranspiler = {
|
|
|
18039
18204
|
})();
|
|
18040
18205
|
`);
|
|
18041
18206
|
}
|
|
18042
|
-
const source = spaceTrim((block) => `
|
|
18207
|
+
const source = spaceTrim$1((block) => `
|
|
18043
18208
|
|
|
18044
18209
|
#!/usr/bin/env node
|
|
18045
18210
|
|
|
@@ -18106,6 +18271,25 @@ const OpenAiSdkTranspiler = {
|
|
|
18106
18271
|
},
|
|
18107
18272
|
};
|
|
18108
18273
|
|
|
18274
|
+
/**
|
|
18275
|
+
* Returns information about the current runtime environment
|
|
18276
|
+
*
|
|
18277
|
+
* Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environments
|
|
18278
|
+
*
|
|
18279
|
+
* @public exported from `@promptbook/utils`
|
|
18280
|
+
*/
|
|
18281
|
+
function $detectRuntimeEnvironment() {
|
|
18282
|
+
return {
|
|
18283
|
+
isRunningInBrowser: $isRunningInBrowser(),
|
|
18284
|
+
isRunningInJest: $isRunningInJest(),
|
|
18285
|
+
isRunningInNode: $isRunningInNode(),
|
|
18286
|
+
isRunningInWebWorker: $isRunningInWebWorker(),
|
|
18287
|
+
};
|
|
18288
|
+
}
|
|
18289
|
+
/**
|
|
18290
|
+
* TODO: [🎺] Also detect and report node version here
|
|
18291
|
+
*/
|
|
18292
|
+
|
|
18109
18293
|
/**
|
|
18110
18294
|
* Provide information about Promptbook, engine version, book language version, servers, ...
|
|
18111
18295
|
*
|
|
@@ -18115,9 +18299,9 @@ const OpenAiSdkTranspiler = {
|
|
|
18115
18299
|
* @public exported from `@promptbook/core`
|
|
18116
18300
|
*/
|
|
18117
18301
|
function aboutPromptbookInformation(options) {
|
|
18118
|
-
const { isServersInfoIncluded = true } = options || {};
|
|
18302
|
+
const { isServersInfoIncluded = true, isRuntimeEnvironmentInfoIncluded = true } = options || {};
|
|
18119
18303
|
const fullInfoPieces = [];
|
|
18120
|
-
const basicInfo = spaceTrim(`
|
|
18304
|
+
const basicInfo = spaceTrim$1(`
|
|
18121
18305
|
|
|
18122
18306
|
# ${NAME}
|
|
18123
18307
|
|
|
@@ -18129,7 +18313,7 @@ function aboutPromptbookInformation(options) {
|
|
|
18129
18313
|
`);
|
|
18130
18314
|
fullInfoPieces.push(basicInfo);
|
|
18131
18315
|
if (isServersInfoIncluded) {
|
|
18132
|
-
const serversInfo = spaceTrim((block) => `
|
|
18316
|
+
const serversInfo = spaceTrim$1((block) => `
|
|
18133
18317
|
|
|
18134
18318
|
## Servers
|
|
18135
18319
|
|
|
@@ -18139,12 +18323,160 @@ function aboutPromptbookInformation(options) {
|
|
|
18139
18323
|
`);
|
|
18140
18324
|
fullInfoPieces.push(serversInfo);
|
|
18141
18325
|
}
|
|
18142
|
-
|
|
18326
|
+
if (isRuntimeEnvironmentInfoIncluded) {
|
|
18327
|
+
const runtimeEnvironment = $detectRuntimeEnvironment();
|
|
18328
|
+
const environmentInfoRecord = {
|
|
18329
|
+
...runtimeEnvironment,
|
|
18330
|
+
isCostPrevented: IS_COST_PREVENTED,
|
|
18331
|
+
};
|
|
18332
|
+
const environmentInfo = spaceTrim$1((block) => `
|
|
18333
|
+
|
|
18334
|
+
## Environment
|
|
18335
|
+
|
|
18336
|
+
${block(Object.entries(environmentInfoRecord)
|
|
18337
|
+
.map(([key, value]) => `- **${key}:** ${valueToString(value)}`)
|
|
18338
|
+
.join('\n'))}
|
|
18339
|
+
`);
|
|
18340
|
+
fullInfoPieces.push(environmentInfo);
|
|
18341
|
+
}
|
|
18342
|
+
const fullInfo = spaceTrim$1(fullInfoPieces.join('\n\n'));
|
|
18143
18343
|
return fullInfo;
|
|
18144
18344
|
}
|
|
18145
18345
|
/**
|
|
18146
18346
|
* TODO: [🗽] Unite branding and make single place for it
|
|
18147
18347
|
*/
|
|
18148
18348
|
|
|
18149
|
-
|
|
18349
|
+
/**
|
|
18350
|
+
* Pick random item from the received array
|
|
18351
|
+
*
|
|
18352
|
+
* @private internal helper function
|
|
18353
|
+
*/
|
|
18354
|
+
function $randomItem(...items) {
|
|
18355
|
+
if (items.length === 0) {
|
|
18356
|
+
throw new Error(`Not enough items`);
|
|
18357
|
+
}
|
|
18358
|
+
return items[Math.floor(Math.random( /* <- TODO: [🐉] Probably use seed random */) * items.length)];
|
|
18359
|
+
}
|
|
18360
|
+
/**
|
|
18361
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
18362
|
+
*/
|
|
18363
|
+
|
|
18364
|
+
const FIRSTNAMES = [
|
|
18365
|
+
'Paul',
|
|
18366
|
+
'George',
|
|
18367
|
+
'Adam',
|
|
18368
|
+
'Lucy',
|
|
18369
|
+
'Sophia',
|
|
18370
|
+
'Emma',
|
|
18371
|
+
'Olivia',
|
|
18372
|
+
'Noah',
|
|
18373
|
+
'Liam',
|
|
18374
|
+
'Ethan',
|
|
18375
|
+
'Ava',
|
|
18376
|
+
'Mia',
|
|
18377
|
+
'Isabella',
|
|
18378
|
+
'James',
|
|
18379
|
+
'Benjamin',
|
|
18380
|
+
'Elijah',
|
|
18381
|
+
'Sophia',
|
|
18382
|
+
'Charlotte',
|
|
18383
|
+
'Amelia',
|
|
18384
|
+
'Harper',
|
|
18385
|
+
'Alexander',
|
|
18386
|
+
'William',
|
|
18387
|
+
'Michael',
|
|
18388
|
+
'Daniel',
|
|
18389
|
+
'Matthew',
|
|
18390
|
+
'Joseph',
|
|
18391
|
+
'David',
|
|
18392
|
+
'Samuel',
|
|
18393
|
+
'Henry',
|
|
18394
|
+
'Jack',
|
|
18395
|
+
'Sebastian',
|
|
18396
|
+
'Gabriel',
|
|
18397
|
+
'Anthony',
|
|
18398
|
+
'Christopher',
|
|
18399
|
+
];
|
|
18400
|
+
const LASTNAMES_WITH_COLORS = [
|
|
18401
|
+
{ lastname: 'Green', color: '#008000' },
|
|
18402
|
+
{ lastname: 'Brown', color: '#A52A2A' },
|
|
18403
|
+
{ lastname: 'Black', color: '#000000' },
|
|
18404
|
+
{ lastname: 'White', color: '#FFFFFF' },
|
|
18405
|
+
{ lastname: 'Gray', color: '#808080' },
|
|
18406
|
+
{ lastname: 'Blue', color: '#0000FF' },
|
|
18407
|
+
];
|
|
18408
|
+
/**
|
|
18409
|
+
*
|
|
18410
|
+
* @private internal helper function
|
|
18411
|
+
*/
|
|
18412
|
+
function $randomFullnameWithColor() {
|
|
18413
|
+
const firstname = $randomItem(...FIRSTNAMES);
|
|
18414
|
+
const { lastname, color } = $randomItem(...LASTNAMES_WITH_COLORS);
|
|
18415
|
+
return {
|
|
18416
|
+
fullname: `${firstname} ${lastname}`,
|
|
18417
|
+
color,
|
|
18418
|
+
};
|
|
18419
|
+
}
|
|
18420
|
+
/**
|
|
18421
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
18422
|
+
*/
|
|
18423
|
+
|
|
18424
|
+
const PERSONALITIES = [
|
|
18425
|
+
'Friendly and helpful AI agent.',
|
|
18426
|
+
'Professional and efficient virtual assistant.',
|
|
18427
|
+
'Creative and imaginative digital companion.',
|
|
18428
|
+
'Knowledgeable and informative AI guide.',
|
|
18429
|
+
'Empathetic and understanding support bot.',
|
|
18430
|
+
'Energetic and enthusiastic conversational partner.',
|
|
18431
|
+
'Calm and patient virtual helper.',
|
|
18432
|
+
'Curious and inquisitive AI explorer.',
|
|
18433
|
+
'Witty and humorous digital friend.',
|
|
18434
|
+
'Serious and focused AI consultant.',
|
|
18435
|
+
];
|
|
18436
|
+
/**
|
|
18437
|
+
* @@@@
|
|
18438
|
+
*
|
|
18439
|
+
* @private internal helper function
|
|
18440
|
+
*/
|
|
18441
|
+
function $randomAgentPersona() {
|
|
18442
|
+
return $randomItem(...PERSONALITIES);
|
|
18443
|
+
}
|
|
18444
|
+
/**
|
|
18445
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
18446
|
+
*/
|
|
18447
|
+
|
|
18448
|
+
/**
|
|
18449
|
+
* Generates boilerplate for a new agent book
|
|
18450
|
+
*
|
|
18451
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
18452
|
+
* Note: This function is using cryptographically secure components internally
|
|
18453
|
+
*
|
|
18454
|
+
* @public exported from `@promptbook/core`
|
|
18455
|
+
*/
|
|
18456
|
+
function $generateBookBoilerplate(options) {
|
|
18457
|
+
// eslint-disable-next-line prefer-const
|
|
18458
|
+
let { agentName, parentAgentName = 'Adam', personaDescription, meta } = options || {};
|
|
18459
|
+
// eslint-disable-next-line prefer-const
|
|
18460
|
+
let { image, color, ...restMeta } = meta || {};
|
|
18461
|
+
if (!agentName) {
|
|
18462
|
+
const randomFullnameWithColor = $randomFullnameWithColor();
|
|
18463
|
+
agentName = randomFullnameWithColor.fullname;
|
|
18464
|
+
color = color || randomFullnameWithColor.color;
|
|
18465
|
+
}
|
|
18466
|
+
if (!personaDescription) {
|
|
18467
|
+
personaDescription = $randomAgentPersona();
|
|
18468
|
+
}
|
|
18469
|
+
const agentSource = validateBook(spaceTrim$1((block) => `
|
|
18470
|
+
${agentName}
|
|
18471
|
+
|
|
18472
|
+
META COLOR ${color || '#3498db' /* <- TODO: !!!! Best default color */}
|
|
18473
|
+
PERSONA ${block(personaDescription)}
|
|
18474
|
+
`));
|
|
18475
|
+
return agentSource;
|
|
18476
|
+
}
|
|
18477
|
+
/**
|
|
18478
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
18479
|
+
*/
|
|
18480
|
+
|
|
18481
|
+
export { $bookTranspilersRegister, $generateBookBoilerplate, $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, API_REQUEST_TIMEOUT, AbstractFormatError, Agent, AgentCollectionInSupabase, AgentLlmExecutionTools, AuthenticationError, BIG_DATASET_TRESHOLD, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CompletionFormfactorDefinition, CsvFormatError, CsvFormatParser, DEFAULT_AGENTS_DIRNAME, DEFAULT_BOOK, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_MAX_REQUESTS_PER_MINUTE, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_SIMULATED_DURATION_MS, DEFAULT_TASK_TITLE, DatabaseError, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FAILED_VALUE_PLACEHOLDER, FORMFACTOR_DEFINITIONS, FormattedBookInMarkdownTranspiler, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_ORDERS, MODEL_TRUST_LEVELS, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotAllowed, NotFoundError, NotYetImplementedCommitmentDefinition, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, OpenAiSdkTranspiler, PADDING_LINES, PENDING_VALUE_PLACEHOLDER, PLAYGROUND_APP_ID, PROMPTBOOK_CHAT_COLOR, PROMPTBOOK_COLOR, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, PROMPTBOOK_LOGO_URL, PROMPTBOOK_SYNTAX_COLORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, REMOTE_SERVER_URLS, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatParser, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, USER_CHAT_COLOR, UnexpectedError, WrappedError, ZERO_USAGE, ZERO_VALUE, _AgentMetadata, _AgentRegistration, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OllamaMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, aboutPromptbookInformation, addUsage, book, cacheLlmTools, compilePipeline, computeCosineSimilarity, countUsage, createAgentLlmExecutionTools, createAgentModelRequirements, createAgentModelRequirementsWithCommitments, createBasicAgentModelRequirements, createEmptyAgentModelRequirements, createLlmToolsFromConfiguration, createPipelineCollectionFromJson, createPipelineCollectionFromPromise, createPipelineCollectionFromUrl, createPipelineExecutor, createPipelineSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, generatePlaceholderAgentProfileImageUrl, getAllCommitmentDefinitions, getAllCommitmentTypes, getCommitmentDefinition, getPipelineInterface, getSingleLlmExecutionTools, identificationToPromptbookToken, isCommitmentSupported, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidBook, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, migratePipeline, padBook, parseAgentSource, parseParameters, parsePipeline, pipelineCollectionToJson, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validateBook, validatePipeline, validatePipelineString };
|
|
18150
18482
|
//# sourceMappingURL=index.es.js.map
|