@promptbook/remote-client 0.103.0-16 → 0.103.0-17

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
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  * @generated
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-16';
23
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-17';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1053,17 +1053,6 @@ function lighten(amount) {
1053
1053
  * TODO: Maybe implement by mix+hsl
1054
1054
  */
1055
1055
 
1056
- /**
1057
- * Makes color transformer which darker the given color
1058
- *
1059
- * @param amount from 0 to 1
1060
- *
1061
- * @public exported from `@promptbook/color`
1062
- */
1063
- function darken(amount) {
1064
- return lighten(-amount);
1065
- }
1066
-
1067
1056
  /**
1068
1057
  * Calculates distance between two colors
1069
1058
  *
@@ -1238,7 +1227,8 @@ const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1238
1227
  * @public exported from `@promptbook/core`
1239
1228
  */
1240
1229
  ({
1241
- TITLE: PROMPTBOOK_COLOR.then(darken(0.5)),
1230
+ TITLE: Color.fromHex('#244EA8'),
1231
+ LINE: Color.fromHex('#DA0F78'),
1242
1232
  COMMITMENT: Color.fromHex('#DA0F78'),
1243
1233
  PARAMETER: Color.fromHex('#8e44ad'),
1244
1234
  });
@@ -5586,6 +5576,44 @@ function validatePipelineString(pipelineString) {
5586
5576
  const SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
5587
5577
  // <- TODO: [🏥] DRY
5588
5578
 
5579
+ /**
5580
+ * @private constant for `padBookContent`
5581
+ */
5582
+ const PADDING_LINES = 5;
5583
+ /**
5584
+ * A function that adds padding to the book content
5585
+ *
5586
+ * @private utility function
5587
+ */
5588
+ function padBookContent(content) {
5589
+ if (!content) {
5590
+ return '\n'.repeat(PADDING_LINES);
5591
+ }
5592
+ const lines = content.split('\n');
5593
+ let trailingEmptyLines = 0;
5594
+ for (let i = lines.length - 1; i >= 0; i--) {
5595
+ const line = lines[i];
5596
+ if (line === undefined) {
5597
+ // Note: This should not happen in reality, but it's here to satisfy TypeScript's noUncheckedIndexedAccess option
5598
+ continue;
5599
+ }
5600
+ if (line.trim() === '') {
5601
+ trailingEmptyLines++;
5602
+ }
5603
+ else {
5604
+ break;
5605
+ }
5606
+ }
5607
+ if (trailingEmptyLines >= PADDING_LINES) {
5608
+ return content;
5609
+ }
5610
+ const linesToAdd = PADDING_LINES - trailingEmptyLines;
5611
+ return (content + '\n'.repeat(linesToAdd));
5612
+ }
5613
+ /**
5614
+ * TODO: [🧠] Maybe export
5615
+ */
5616
+
5589
5617
  /**
5590
5618
  * Removes Markdown (or HTML) comments
5591
5619
  *
@@ -5631,6 +5659,7 @@ function deflatePipeline(pipelineString) {
5631
5659
  if (!isFlatPipeline(pipelineString)) {
5632
5660
  return pipelineString;
5633
5661
  }
5662
+ pipelineString = spaceTrim$1(pipelineString);
5634
5663
  const pipelineStringLines = pipelineString.split('\n');
5635
5664
  const potentialReturnStatement = pipelineStringLines.pop();
5636
5665
  let returnStatement;
@@ -5665,7 +5694,7 @@ function deflatePipeline(pipelineString) {
5665
5694
  ${returnStatement}
5666
5695
  `));
5667
5696
  // <- TODO: Maybe use book` notation
5668
- return pipelineString;
5697
+ return padBookContent(pipelineString);
5669
5698
  }
5670
5699
  /**
5671
5700
  * TODO: Unit test