@promptbook/components 0.104.0-13 → 0.104.0-14

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 CHANGED
@@ -35,7 +35,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
35
35
  * @generated
36
36
  * @see https://github.com/webgptorg/promptbook
37
37
  */
38
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-13';
38
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-14';
39
39
  /**
40
40
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
41
41
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2236,8 +2236,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
2236
2236
  */
2237
2237
  function removeDiacritics(input) {
2238
2238
  /*eslint no-control-regex: "off"*/
2239
- return input.replace(/[^\u0000-\u007E]/g, (a) => {
2240
- return DIACRITIC_VARIANTS_LETTERS[a] || a;
2239
+ return input.replace(/[^\u0000-\u007E]/g, (character) => {
2240
+ return DIACRITIC_VARIANTS_LETTERS[character] || character;
2241
2241
  });
2242
2242
  }
2243
2243
  /**
@@ -2765,7 +2765,7 @@ async function forEachAsync(array, options, callbackfunction) {
2765
2765
  tasks.push(task);
2766
2766
  runningTasks.push(task);
2767
2767
  /* not await */ Promise.resolve(task).then(() => {
2768
- runningTasks = runningTasks.filter((t) => t !== task);
2768
+ runningTasks = runningTasks.filter((runningTask) => runningTask !== task);
2769
2769
  });
2770
2770
  if (maxParallelCount < runningTasks.length) {
2771
2771
  await Promise.race(runningTasks);
@@ -3469,7 +3469,7 @@ function serializeToPromptbookJavascript(value) {
3469
3469
  if (serializedValue === undefined) {
3470
3470
  throw new UnexpectedError(`Serialization resulted in undefined value`);
3471
3471
  }
3472
- const uniqueImports = Array.from(new Set(imports)).filter((imp) => !!imp && imp.trim().length > 0);
3472
+ const uniqueImports = Array.from(new Set(imports)).filter((importStatement) => !!importStatement && importStatement.trim().length > 0);
3473
3473
  return { imports: uniqueImports, value: serializedValue };
3474
3474
  }
3475
3475
  /**
@@ -3631,8 +3631,8 @@ function createDefaultAgentName(agentSource) {
3631
3631
  */
3632
3632
  function createCommitmentRegex(commitment, aliases = [], requiresContent = true) {
3633
3633
  const allCommitments = [commitment, ...aliases];
3634
- const patterns = allCommitments.map((c) => {
3635
- const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
3634
+ const patterns = allCommitments.map((commitment) => {
3635
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
3636
3636
  return escapedCommitment.split(/\s+/).join('\\s+');
3637
3637
  });
3638
3638
  const keywordPattern = patterns.join('|');
@@ -3654,8 +3654,8 @@ function createCommitmentRegex(commitment, aliases = [], requiresContent = true)
3654
3654
  */
3655
3655
  function createCommitmentTypeRegex(commitment, aliases = []) {
3656
3656
  const allCommitments = [commitment, ...aliases];
3657
- const patterns = allCommitments.map((c) => {
3658
- const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
3657
+ const patterns = allCommitments.map((commitment) => {
3658
+ const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
3659
3659
  return escapedCommitment.split(/\s+/).join('\\s+');
3660
3660
  });
3661
3661
  const keywordPattern = patterns.join('|');
@@ -7309,8 +7309,8 @@ function parseParameters(text) {
7309
7309
  return match;
7310
7310
  });
7311
7311
  // Remove duplicates based on name (keep the first occurrence)
7312
- const uniqueParameters = parameters.filter((param, index, array) => {
7313
- return array.findIndex((p) => p.name === param.name) === index;
7312
+ const uniqueParameters = parameters.filter((parameter, index, array) => {
7313
+ return array.findIndex((parameterItem) => parameterItem.name === parameter.name) === index;
7314
7314
  });
7315
7315
  return uniqueParameters;
7316
7316
  }
@@ -8066,8 +8066,12 @@ function AboutPromptbookInformation(props) {
8066
8066
  }
8067
8067
 
8068
8068
  /**
8069
- * Renders an about icon
8069
+ * Renders an information/about icon.
8070
8070
  *
8071
+ * This icon is typically used in UI elements that provide additional information
8072
+ * or "about" details to the user.
8073
+ *
8074
+ * @param props - SVG properties augmented with an optional `size`
8071
8075
  * @private internal subcomponent used by various components
8072
8076
  */
8073
8077
  function AboutIcon(props) {
@@ -8076,26 +8080,38 @@ function AboutIcon(props) {
8076
8080
  }
8077
8081
 
8078
8082
  /**
8079
- * Renders an attachment icon
8083
+ * Renders an attachment icon.
8080
8084
  *
8081
- * @public exported from `@promptbook/components`
8085
+ * This icon is typically used in chat interfaces to indicate the ability to
8086
+ * upload or view files associated with a message.
8087
+ *
8088
+ * @param props - SVG properties augmented with an optional `size`
8089
+ * @private internal subcomponent used by various components
8082
8090
  */
8083
8091
  function AttachmentIcon({ size = 24, color = 'currentColor' }) {
8084
8092
  return (jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: jsx("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66L9.64 16.2a2 2 0 01-2.83-2.83l8.49-8.49", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
8085
8093
  }
8086
8094
 
8087
8095
  /**
8088
- * Renders a camera icon
8096
+ * Renders a camera icon.
8089
8097
  *
8090
- * @public exported from `@promptbook/components`
8098
+ * This icon is typically used in buttons or inputs that trigger image capture
8099
+ * or selection.
8100
+ *
8101
+ * @param props - SVG properties augmented with an optional `size`
8102
+ * @private internal subcomponent used by various components
8091
8103
  */
8092
8104
  function CameraIcon({ size = 24, color = 'currentColor' }) {
8093
8105
  return (jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("path", { d: "M23 19C23 19.5304 22.7893 20.0391 22.4142 20.4142C22.0391 20.7893 21.5304 21 21 21H3C2.46957 21 1.96086 20.7893 1.58579 20.4142C1.21071 20.0391 1 19.5304 1 19V8C1 7.46957 1.21071 6.96086 1.58579 6.58579C1.96086 6.21071 2.46957 6 3 6H7L9 3H15L17 6H21C21.5304 6 22.0391 6.21071 22.4142 6.58579C22.7893 6.96086 23 7.46957 23 8V19Z", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M12 17C14.2091 17 16 15.2091 16 13C16 10.7909 14.2091 9 12 9C9.79086 9 8 10.7909 8 13C8 15.2091 9.79086 17 12 17Z", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }));
8094
8106
  }
8095
8107
 
8096
8108
  /**
8097
- * Renders a download icon
8109
+ * Renders a download icon.
8098
8110
  *
8111
+ * This icon is typically used in buttons or links that trigger the downloading
8112
+ * of files or assets.
8113
+ *
8114
+ * @param props - SVG properties augmented with an optional `size`
8099
8115
  * @private internal subcomponent used by various components
8100
8116
  */
8101
8117
  function DownloadIcon(props) {
@@ -8190,6 +8206,10 @@ styleInject(css_248z$5);
8190
8206
  /**
8191
8207
  * An animated hamburger menu button component.
8192
8208
  *
8209
+ * This component renders a 3-bar hamburger icon that animates into an "X" when
8210
+ * the menu is open.
8211
+ *
8212
+ * @param props - Contains the open state, an optional click handler, and optional className
8193
8213
  * @private Internal component
8194
8214
  */
8195
8215
  function HamburgerMenu({ isOpen, onClick, className }) {
@@ -8201,8 +8221,12 @@ var styles$3 = {"dropdown":"Dropdown-module_dropdown__ZShv1","button":"Dropdown-
8201
8221
  styleInject(css_248z$4);
8202
8222
 
8203
8223
  /**
8204
- * A dropdown menu component that displays a list of actions triggered by a hamburger menu button.
8224
+ * A dropdown menu component that displays a list of actions.
8205
8225
  *
8226
+ * The menu is toggled by a hamburger menu button. When an action is selected,
8227
+ * the menu automatically closes.
8228
+ *
8229
+ * @param props - Contains an array of actions with icons, names, and click handlers
8206
8230
  * @private internal subcomponent used by various components
8207
8231
  */
8208
8232
  function Dropdown({ actions }) {
@@ -8836,7 +8860,7 @@ function colorDistanceSquared(color1, color2) {
8836
8860
  */
8837
8861
  function nearest(...colors) {
8838
8862
  return (color) => {
8839
- const distances = colors.map((c) => colorDistanceSquared(c, color));
8863
+ const distances = colors.map((currentColor) => colorDistanceSquared(currentColor, color));
8840
8864
  const minDistance = Math.min(...distances);
8841
8865
  const minIndex = distances.indexOf(minDistance);
8842
8866
  const nearestColor = colors[minIndex];
@@ -9124,9 +9148,13 @@ const MicIcon = ({ size }) => (jsxs("svg", { width: size, height: size, viewBox:
9124
9148
  const ResetIcon = () => (jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: jsx("path", { d: "M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4L17.65,6.35z" }) }));
9125
9149
 
9126
9150
  /**
9127
- * Renders a save icon
9151
+ * Renders a save icon.
9128
9152
  *
9129
- * @public exported from `@promptbook/components`
9153
+ * This icon is typically used in buttons that trigger the saving of data,
9154
+ * configurations, or agent sources.
9155
+ *
9156
+ * @param props - SVG properties augmented with an optional `size`
9157
+ * @private internal subcomponent used by various components
9130
9158
  */
9131
9159
  function SaveIcon({ size = 20, color = 'currentColor', ...props }) {
9132
9160
  return (jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", ...props, children: [jsx("path", { d: "M4 17V7a3 3 0 0 1 3-3h10a3 3 0 0 1 3 3v7a3 3 0 0 1-3 3H7l-3 3z", fill: color, fillOpacity: "0.08", stroke: color }), jsx("path", { d: "M12 9v5", stroke: color }), jsx("path", { d: "M9.5 12.5L12 15l2.5-2.5", stroke: color })] }));
@@ -11427,17 +11455,21 @@ class MultipleLlmExecutionTools {
11427
11455
  */
11428
11456
 
11429
11457
  /**
11430
- * Joins multiple LLM Execution Tools into one
11458
+ * Joins multiple LLM Execution Tools into one.
11431
11459
  *
11432
- * @returns {LlmExecutionTools} Single wrapper for multiple LlmExecutionTools
11460
+ * This function takes a list of `LlmExecutionTools` and returns a single unified
11461
+ * `MultipleLlmExecutionTools` object. It provides failover and aggregation logic:
11433
11462
  *
11434
- * 0) If there is no LlmExecutionTools, it warns and returns valid but empty LlmExecutionTools
11435
- * 1) If there is only one LlmExecutionTools, it returns it wrapped in a proxy object
11436
- * 2) If there are multiple LlmExecutionTools, first will be used first, second will be used if the first hasn`t defined model variant or fails, etc.
11437
- * 3) When all LlmExecutionTools fail, it throws an error with a list of all errors merged into one
11463
+ * 1. **Failover**: When a model call is made, it tries providers in the order they were provided.
11464
+ * If the first provider doesn't support the requested model or fails, it tries the next one.
11465
+ * 2. **Aggregation**: `listModels` returns a combined list of all models available from all providers.
11466
+ * 3. **Empty case**: If no tools are provided, it logs a warning (as Promptbook requires LLMs to function).
11438
11467
  *
11468
+ * @param title - A descriptive title for this collection of joined tools
11469
+ * @param llmExecutionTools - An array of execution tools to be joined
11470
+ * @returns A single unified execution tool wrapper
11439
11471
  *
11440
- * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`
11472
+ * Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`.
11441
11473
  *
11442
11474
  * @public exported from `@promptbook/core`
11443
11475
  */
@@ -12488,10 +12520,14 @@ function addUsage(...usageItems) {
12488
12520
  }
12489
12521
 
12490
12522
  /**
12491
- * Intercepts LLM tools and counts total usage of the tools
12523
+ * Intercepts LLM tools and counts total usage of the tools.
12524
+ *
12525
+ * This function wraps the provided `LlmExecutionTools` with a proxy that tracks the cumulative
12526
+ * usage (tokens, cost, etc.) across all model calls. It provides a way to monitor spending
12527
+ * in real-time through an observable.
12492
12528
  *
12493
- * @param llmTools LLM tools to be intercepted with usage counting
12494
- * @returns LLM tools with same functionality with added total cost counting
12529
+ * @param llmTools - The LLM tools to be intercepted and tracked
12530
+ * @returns An augmented version of the tools that includes usage tracking capabilities
12495
12531
  * @public exported from `@promptbook/core`
12496
12532
  */
12497
12533
  function countUsage(llmTools) {
@@ -14563,7 +14599,7 @@ async function getKnowledgeForTask(options) {
14563
14599
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
14564
14600
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
14565
14601
  const { index } = knowledgePiece;
14566
- const knowledgePieceIndex = index.find((i) => i.modelName === firstKnowledgeIndex.modelName);
14602
+ const knowledgePieceIndex = index.find((knowledgePieceIndex) => knowledgePieceIndex.modelName === firstKnowledgeIndex.modelName);
14567
14603
  // <- TODO: Do not use just first knowledge piece and first index to determine embedding model
14568
14604
  if (knowledgePieceIndex === undefined) {
14569
14605
  return {
@@ -15011,7 +15047,7 @@ async function executePipeline(options) {
15011
15047
  resovedParameterNames = [...resovedParameterNames, currentTask.resultingParameterName];
15012
15048
  })
15013
15049
  .then(() => {
15014
- resolving = resolving.filter((w) => w !== work);
15050
+ resolving = resolving.filter((workItem) => workItem !== work);
15015
15051
  });
15016
15052
  // <- Note: Errors are catched here [3]
15017
15053
  // TODO: BUT if in multiple tasks are errors, only the first one is catched so maybe we should catch errors here and save them to errors array here
@@ -15177,7 +15213,7 @@ function createPipelineExecutor(options) {
15177
15213
  // Calculate and update tldr based on pipeline progress
15178
15214
  const cv = newOngoingResult;
15179
15215
  // Calculate progress based on parameters resolved vs total parameters
15180
- const totalParameters = pipeline.parameters.filter((p) => !p.isInput).length;
15216
+ const totalParameters = pipeline.parameters.filter((parameter) => !parameter.isInput).length;
15181
15217
  let resolvedParameters = 0;
15182
15218
  let currentTaskTitle = '';
15183
15219
  // Get the resolved parameters from output parameters
@@ -15381,7 +15417,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
15381
15417
  commitment.type === 'DISCARD' ||
15382
15418
  commitment.type === 'REMOVE') {
15383
15419
  const targets = parseParameters(commitment.content)
15384
- .map((p) => p.name.trim().toLowerCase())
15420
+ .map((parameter) => parameter.name.trim().toLowerCase())
15385
15421
  .filter(Boolean);
15386
15422
  if (targets.length === 0) {
15387
15423
  // Ignore DELETE with no targets; also don't pass the DELETE further
@@ -15390,8 +15426,8 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
15390
15426
  // Drop prior kept commitments that contain any of the targeted tags
15391
15427
  for (let i = filteredCommitments.length - 1; i >= 0; i--) {
15392
15428
  const prev = filteredCommitments[i];
15393
- const prevParams = parseParameters(prev.content).map((p) => p.name.trim().toLowerCase());
15394
- const hasIntersection = prevParams.some((n) => targets.includes(n));
15429
+ const prevParams = parseParameters(prev.content).map((parameter) => parameter.name.trim().toLowerCase());
15430
+ const hasIntersection = prevParams.some((parameterName) => targets.includes(parameterName));
15395
15431
  if (hasIntersection) {
15396
15432
  filteredCommitments.splice(i, 1);
15397
15433
  }
@@ -17935,7 +17971,7 @@ class Agent extends AgentLlmExecutionTools {
17935
17971
  const modelRequirements = await this.getAgentModelRequirements();
17936
17972
  if (modelRequirements.samples) {
17937
17973
  const normalizedPrompt = normalizeMessageText(prompt.content);
17938
- const sample = modelRequirements.samples.find((s) => normalizeMessageText(s.question) === normalizedPrompt);
17974
+ const sample = modelRequirements.samples.find((sample) => normalizeMessageText(sample.question) === normalizedPrompt);
17939
17975
  if (sample) {
17940
17976
  const now = new Date().toISOString();
17941
17977
  const result = {
@@ -18629,5 +18665,5 @@ function injectCssModuleIntoShadowRoot(options) {
18629
18665
  }
18630
18666
  }
18631
18667
 
18632
- export { AboutPromptbookInformation, AgentChat, ArrowIcon, AttachmentIcon, AvatarChip, AvatarChipFromSource, AvatarProfile, AvatarProfileFromSource, BLOCKY_FLOW, BOOK_LANGUAGE_VERSION, BookEditor, BrandedQrCode, CHAT_SAVE_FORMATS, CameraIcon, Chat, DEFAULT_BOOK_EDITOR_HEIGHT, FAST_FLOW, GenericQrCode, LlmChat, MOCKED_CHAT_DELAY_CONFIGS, MarkdownContent, MicIcon, MockedChat, NORMAL_FLOW, PROMPTBOOK_ENGINE_VERSION, PauseIcon, PlayIcon, PromptbookAgentIntegration, PromptbookQrCode, RANDOM_FLOW, ResetIcon, SLOW_FLOW, SaveIcon, SendIcon, TemplateIcon, getChatSaveFormatDefinitions, htmlSaveFormatDefinition, injectCssModuleIntoShadowRoot, jsonSaveFormatDefinition, mdSaveFormatDefinition, parseMessageButtons, pdfSaveFormatDefinition, reactSaveFormatDefinition, txtSaveFormatDefinition, useChatAutoScroll, useSendMessageToLlmChat };
18668
+ export { AboutPromptbookInformation, AgentChat, ArrowIcon, AvatarChip, AvatarChipFromSource, AvatarProfile, AvatarProfileFromSource, BLOCKY_FLOW, BOOK_LANGUAGE_VERSION, BookEditor, BrandedQrCode, CHAT_SAVE_FORMATS, Chat, DEFAULT_BOOK_EDITOR_HEIGHT, FAST_FLOW, GenericQrCode, LlmChat, MOCKED_CHAT_DELAY_CONFIGS, MarkdownContent, MicIcon, MockedChat, NORMAL_FLOW, PROMPTBOOK_ENGINE_VERSION, PauseIcon, PlayIcon, PromptbookAgentIntegration, PromptbookQrCode, RANDOM_FLOW, ResetIcon, SLOW_FLOW, SendIcon, TemplateIcon, getChatSaveFormatDefinitions, htmlSaveFormatDefinition, injectCssModuleIntoShadowRoot, jsonSaveFormatDefinition, mdSaveFormatDefinition, parseMessageButtons, pdfSaveFormatDefinition, reactSaveFormatDefinition, txtSaveFormatDefinition, useChatAutoScroll, useSendMessageToLlmChat };
18633
18669
  //# sourceMappingURL=index.es.js.map