@promptbook/legacy-documents 0.103.0-42 → 0.103.0-43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +40 -113
- 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 +14 -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 +1 -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 +11 -12
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +55 -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 +9 -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/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 +2 -2
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.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/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 +22 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +1 -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 +2 -2
- package/umd/index.umd.js +40 -113
- 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/execution/utils/logLlmCall.d.ts +0 -8
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-43';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -707,6 +707,23 @@ class Color {
|
|
|
707
707
|
* TODO: Maybe connect with textures
|
|
708
708
|
*/
|
|
709
709
|
|
|
710
|
+
/**
|
|
711
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
712
|
+
*
|
|
713
|
+
* @param amount from 0 to 1
|
|
714
|
+
*
|
|
715
|
+
* @public exported from `@promptbook/color`
|
|
716
|
+
*/
|
|
717
|
+
function grayscale(amount) {
|
|
718
|
+
return ({ red, green, blue, alpha }) => {
|
|
719
|
+
const average = (red + green + blue) / 3;
|
|
720
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
721
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
722
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
723
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
|
|
710
727
|
/**
|
|
711
728
|
* Converts HSL values to RGB values
|
|
712
729
|
*
|
|
@@ -822,102 +839,6 @@ function lighten(amount) {
|
|
|
822
839
|
* TODO: Maybe implement by mix+hsl
|
|
823
840
|
*/
|
|
824
841
|
|
|
825
|
-
/**
|
|
826
|
-
* Calculates distance between two colors
|
|
827
|
-
*
|
|
828
|
-
* @param color1 first color
|
|
829
|
-
* @param color2 second color
|
|
830
|
-
*
|
|
831
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
832
|
-
*
|
|
833
|
-
* @public exported from `@promptbook/color`
|
|
834
|
-
*/
|
|
835
|
-
/**
|
|
836
|
-
* Calculates distance between two colors without square root
|
|
837
|
-
*
|
|
838
|
-
* @param color1 first color
|
|
839
|
-
* @param color2 second color
|
|
840
|
-
*
|
|
841
|
-
* @public exported from `@promptbook/color`
|
|
842
|
-
*/
|
|
843
|
-
function colorDistanceSquared(color1, color2) {
|
|
844
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
845
|
-
const r = color1.red - color2.red;
|
|
846
|
-
const g = color1.green - color2.green;
|
|
847
|
-
const b = color1.blue - color2.blue;
|
|
848
|
-
const weightR = 2 + rmean / 256;
|
|
849
|
-
const weightG = 4.0;
|
|
850
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
851
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
852
|
-
return distance;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
/**
|
|
856
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
857
|
-
*
|
|
858
|
-
* @param colors array of colors to choose from
|
|
859
|
-
*
|
|
860
|
-
* @public exported from `@promptbook/color`
|
|
861
|
-
*/
|
|
862
|
-
function nearest(...colors) {
|
|
863
|
-
return (color) => {
|
|
864
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
865
|
-
const minDistance = Math.min(...distances);
|
|
866
|
-
const minIndex = distances.indexOf(minDistance);
|
|
867
|
-
const nearestColor = colors[minIndex];
|
|
868
|
-
return nearestColor;
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Color transformer which returns the negative color
|
|
874
|
-
*
|
|
875
|
-
* @public exported from `@promptbook/color`
|
|
876
|
-
*/
|
|
877
|
-
function negative(color) {
|
|
878
|
-
const r = 255 - color.red;
|
|
879
|
-
const g = 255 - color.green;
|
|
880
|
-
const b = 255 - color.blue;
|
|
881
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
/**
|
|
885
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
886
|
-
*
|
|
887
|
-
* @param colors array of colors to choose from
|
|
888
|
-
*
|
|
889
|
-
* @public exported from `@promptbook/color`
|
|
890
|
-
*/
|
|
891
|
-
function furthest(...colors) {
|
|
892
|
-
return (color) => {
|
|
893
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
894
|
-
return furthestColor;
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
/**
|
|
898
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
899
|
-
*
|
|
900
|
-
* @public exported from `@promptbook/color`
|
|
901
|
-
*/
|
|
902
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
903
|
-
|
|
904
|
-
/**
|
|
905
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
906
|
-
*
|
|
907
|
-
* @param amount from 0 to 1
|
|
908
|
-
*
|
|
909
|
-
* @public exported from `@promptbook/color`
|
|
910
|
-
*/
|
|
911
|
-
function grayscale(amount) {
|
|
912
|
-
return ({ red, green, blue, alpha }) => {
|
|
913
|
-
const average = (red + green + blue) / 3;
|
|
914
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
915
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
916
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
917
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
|
|
921
842
|
/**
|
|
922
843
|
* Makes color transformer which saturate the given color
|
|
923
844
|
*
|
|
@@ -3200,6 +3121,7 @@ function createPipelineCollectionFromJson(...promptbooks) {
|
|
|
3200
3121
|
/**
|
|
3201
3122
|
* Generates random token
|
|
3202
3123
|
*
|
|
3124
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
3203
3125
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
3204
3126
|
*
|
|
3205
3127
|
* @private internal helper function
|
|
@@ -3327,6 +3249,19 @@ class CollectionError extends Error {
|
|
|
3327
3249
|
}
|
|
3328
3250
|
}
|
|
3329
3251
|
|
|
3252
|
+
/**
|
|
3253
|
+
* This error indicates error from the database
|
|
3254
|
+
*
|
|
3255
|
+
* @public exported from `@promptbook/core`
|
|
3256
|
+
*/
|
|
3257
|
+
class DatabaseError extends Error {
|
|
3258
|
+
constructor(message) {
|
|
3259
|
+
super(message);
|
|
3260
|
+
this.name = 'DatabaseError';
|
|
3261
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
|
|
3330
3265
|
/**
|
|
3331
3266
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
3332
3267
|
*
|
|
@@ -3430,6 +3365,7 @@ const PROMPTBOOK_ERRORS = {
|
|
|
3430
3365
|
UnexpectedError,
|
|
3431
3366
|
WrappedError,
|
|
3432
3367
|
NotAllowed,
|
|
3368
|
+
DatabaseError,
|
|
3433
3369
|
// TODO: [🪑]> VersionMismatchError,
|
|
3434
3370
|
};
|
|
3435
3371
|
/**
|
|
@@ -5857,18 +5793,6 @@ function templateParameters(template, parameters) {
|
|
|
5857
5793
|
return replacedTemplates;
|
|
5858
5794
|
}
|
|
5859
5795
|
|
|
5860
|
-
/**
|
|
5861
|
-
* Logs an LLM call with the given report.
|
|
5862
|
-
*
|
|
5863
|
-
* @private internal utility of `createPipelineExecutor`
|
|
5864
|
-
*/
|
|
5865
|
-
function logLlmCall(logLlmCall, report) {
|
|
5866
|
-
logLlmCall({
|
|
5867
|
-
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
5868
|
-
report,
|
|
5869
|
-
});
|
|
5870
|
-
}
|
|
5871
|
-
|
|
5872
5796
|
/**
|
|
5873
5797
|
* Extracts all code blocks from markdown.
|
|
5874
5798
|
*
|
|
@@ -6214,7 +6138,7 @@ function validatePromptResult(options) {
|
|
|
6214
6138
|
*/
|
|
6215
6139
|
async function executeAttempts(options) {
|
|
6216
6140
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
6217
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall
|
|
6141
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
|
|
6218
6142
|
const $ongoingTaskResult = {
|
|
6219
6143
|
$result: null,
|
|
6220
6144
|
$resultString: null,
|
|
@@ -6476,8 +6400,11 @@ async function executeAttempts(options) {
|
|
|
6476
6400
|
: serializeError($ongoingTaskResult.$expectError),
|
|
6477
6401
|
};
|
|
6478
6402
|
$executionReport.promptExecutions.push(executionPromptReport);
|
|
6479
|
-
if (logLlmCall
|
|
6480
|
-
logLlmCall(
|
|
6403
|
+
if (logLlmCall) {
|
|
6404
|
+
logLlmCall({
|
|
6405
|
+
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
6406
|
+
report: executionPromptReport,
|
|
6407
|
+
});
|
|
6481
6408
|
}
|
|
6482
6409
|
}
|
|
6483
6410
|
}
|
|
@@ -6751,7 +6678,7 @@ async function getKnowledgeForTask(options) {
|
|
|
6751
6678
|
},
|
|
6752
6679
|
content: task.content,
|
|
6753
6680
|
parameters,
|
|
6754
|
-
};
|
|
6681
|
+
}; /* <- Note: [🤛] */
|
|
6755
6682
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6756
6683
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6757
6684
|
const { index } = knowledgePiece;
|