@promptbook/cli 0.72.0-33 → 0.72.0-34

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 CHANGED
@@ -109,15 +109,15 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
109
109
 
110
110
 
111
111
 
112
- If you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama 2, or whatever, it doesn't matter how you integrate it. Whether it's calling a REST API directly, using the SDK, hardcoding the prompt into the source code, or importing a text file, the process remains the same.
112
+ If you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama 3, or whatever, it doesn't matter how you integrate it. Whether it's calling a REST API directly, using the SDK, hardcoding the prompt into the source code, or importing a text file, the process remains the same.
113
113
 
114
- But often you will struggle with the limitations of LLMs, such as hallucinations, off-topic responses, poor quality output, language drift, word repetition repetition repetition repetition or misuse, lack of context, or just plain w𝒆𝐢rd responses. When this happens, you generally have three options:
114
+ But often you will struggle with the **limitations of LLMs**, such as **hallucinations, off-topic responses, poor quality output, language and prompt drift, word repetition repetition repetition repetition or misuse, lack of context, or just plain w𝒆𝐢rd responses**. When this happens, you generally have three options:
115
115
 
116
116
  1. **Fine-tune** the model to your specifications or even train your own.
117
117
  2. **Prompt-engineer** the prompt to the best shape you can achieve.
118
118
  3. Orchestrate **multiple prompts** in a [pipeline](https://github.com/webgptorg/promptbook/discussions/64) to get the best result.
119
119
 
120
- In all of these situations, but especially in 3., the Promptbook library can make your life easier.
120
+ In all of these situations, but especially in 3., the **✨ Promptbook can make your life waaaaaaaaaay easier**.
121
121
 
122
122
  - [**Separates concerns**](https://github.com/webgptorg/promptbook/discussions/32) between prompt-engineer and programmer, between code files and prompt files, and between prompts and their execution logic.
123
123
  - Establishes a [**common format `.ptbk.md`**](https://github.com/webgptorg/promptbook/discussions/85) that can be used to describe your prompt business logic without having to write code or deal with the technicalities of LLMs.
package/esm/index.es.js CHANGED
@@ -27,7 +27,7 @@ import { Converter } from 'showdown';
27
27
  /**
28
28
  * The version of the Promptbook library
29
29
  */
30
- var PROMPTBOOK_VERSION = '0.72.0-32';
30
+ var PROMPTBOOK_VERSION = '0.72.0-33';
31
31
  // TODO: [main] !!!! List here all the versions and annotate + put into script
32
32
 
33
33
  /*! *****************************************************************************
@@ -8381,16 +8381,25 @@ var exec$1 = promisify(exec$2);
8381
8381
  function locateAppOnLinux(_a) {
8382
8382
  var appName = _a.appName, linuxWhich = _a.linuxWhich;
8383
8383
  return __awaiter(this, void 0, void 0, function () {
8384
- var _b, stderr, stdout;
8384
+ var _b, stderr, stdout, error_1;
8385
8385
  return __generator(this, function (_c) {
8386
8386
  switch (_c.label) {
8387
- case 0: return [4 /*yield*/, exec$1("which ".concat(linuxWhich))];
8387
+ case 0:
8388
+ _c.trys.push([0, 2, , 3]);
8389
+ return [4 /*yield*/, exec$1("which ".concat(linuxWhich))];
8388
8390
  case 1:
8389
8391
  _b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
8390
8392
  if (!stderr && stdout) {
8391
8393
  return [2 /*return*/, stdout.trim()];
8392
8394
  }
8393
8395
  throw new Error("Can not locate app ".concat(appName, " on Linux.\n ").concat(stderr));
8396
+ case 2:
8397
+ error_1 = _c.sent();
8398
+ if (!(error_1 instanceof Error)) {
8399
+ throw error_1;
8400
+ }
8401
+ return [2 /*return*/, null];
8402
+ case 3: return [2 /*return*/];
8394
8403
  }
8395
8404
  });
8396
8405
  });
@@ -8466,10 +8475,11 @@ var exec = promisify(exec$2);
8466
8475
  function locateAppOnMacOs(_a) {
8467
8476
  var appName = _a.appName, macOsName = _a.macOsName;
8468
8477
  return __awaiter(this, void 0, void 0, function () {
8469
- var toExec, regPath, altPath, _b, stderr, stdout;
8478
+ var toExec, regPath, altPath, _b, stderr, stdout, error_1;
8470
8479
  return __generator(this, function (_c) {
8471
8480
  switch (_c.label) {
8472
8481
  case 0:
8482
+ _c.trys.push([0, 6, , 7]);
8473
8483
  toExec = "/Contents/MacOS/".concat(macOsName);
8474
8484
  regPath = "/Applications/".concat(macOsName, ".app") + toExec;
8475
8485
  altPath = userhome(regPath.slice(1));
@@ -8490,6 +8500,13 @@ function locateAppOnMacOs(_a) {
8490
8500
  return [2 /*return*/, stdout.trim() + toExec];
8491
8501
  }
8492
8502
  throw new Error("Can not locate app ".concat(appName, " on macOS.\n ").concat(stderr));
8503
+ case 6:
8504
+ error_1 = _c.sent();
8505
+ if (!(error_1 instanceof Error)) {
8506
+ throw error_1;
8507
+ }
8508
+ return [2 /*return*/, null];
8509
+ case 7: return [2 /*return*/];
8493
8510
  }
8494
8511
  });
8495
8512
  });
@@ -8507,11 +8524,12 @@ function locateAppOnMacOs(_a) {
8507
8524
  function locateAppOnWindows(_a) {
8508
8525
  var appName = _a.appName, windowsSuffix = _a.windowsSuffix;
8509
8526
  return __awaiter(this, void 0, void 0, function () {
8510
- var prefixes, prefixes_1, prefixes_1_1, prefix, path, e_1_1;
8527
+ var prefixes, prefixes_1, prefixes_1_1, prefix, path, e_1_1, error_1;
8511
8528
  var e_1, _b;
8512
8529
  return __generator(this, function (_c) {
8513
8530
  switch (_c.label) {
8514
8531
  case 0:
8532
+ _c.trys.push([0, 9, , 10]);
8515
8533
  prefixes = [
8516
8534
  process.env.LOCALAPPDATA,
8517
8535
  join(process.env.LOCALAPPDATA || '', 'Programs'),
@@ -8548,6 +8566,13 @@ function locateAppOnWindows(_a) {
8548
8566
  finally { if (e_1) throw e_1.error; }
8549
8567
  return [7 /*endfinally*/];
8550
8568
  case 8: throw new Error("Can not locate app ".concat(appName, " on Windows."));
8569
+ case 9:
8570
+ error_1 = _c.sent();
8571
+ if (!(error_1 instanceof Error)) {
8572
+ throw error_1;
8573
+ }
8574
+ return [2 /*return*/, null];
8575
+ case 10: return [2 /*return*/];
8551
8576
  }
8552
8577
  });
8553
8578
  });
@@ -8654,9 +8679,9 @@ function $provideExecutablesForNode(options) {
8654
8679
  _d = {};
8655
8680
  return [4 /*yield*/, locatePandoc()];
8656
8681
  case 1:
8657
- _d.pandocPath = _e.sent();
8682
+ _d.pandocPath = (_e.sent()) || undefined;
8658
8683
  return [4 /*yield*/, locateLibreoffice()];
8659
- case 2: return [2 /*return*/, (_d.libreOfficePath = _e.sent(),
8684
+ case 2: return [2 /*return*/, (_d.libreOfficePath = (_e.sent()) || undefined,
8660
8685
  _d)];
8661
8686
  }
8662
8687
  });
@@ -12976,11 +13001,11 @@ var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
12976
13001
  assistant_id: this.assistantId,
12977
13002
  thread: {
12978
13003
  messages: [
12979
- // TODO: [🗯] !!!!!! Allow threads to be passed
13004
+ // TODO: [🗯] !! Allow threads to be passed
12980
13005
  { role: 'user', content: rawPromptContent },
12981
13006
  ],
12982
13007
  },
12983
- // !!!!!! user: this.options.user,
13008
+ // <- TODO: Add user identification here> user: this.options.user,
12984
13009
  };
12985
13010
  start = getCurrentIsoDate();
12986
13011
  if (this.options.isVerbose) {
@@ -13031,7 +13056,7 @@ var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
13031
13056
  throw new PipelineExecutionError("There is NOT 'text' BUT ".concat((_b = rawResponse[0].content[0]) === null || _b === void 0 ? void 0 : _b.type, " finalMessages content type from OpenAI"));
13032
13057
  }
13033
13058
  resultContent = (_c = rawResponse[0].content[0]) === null || _c === void 0 ? void 0 : _c.text.value;
13034
- // <- TODO: !!!!!! There are also annotations, maybe use them
13059
+ // <- TODO: [🧠] There are also annotations, maybe use them
13035
13060
  // eslint-disable-next-line prefer-const
13036
13061
  complete = getCurrentIsoDate();
13037
13062
  usage = UNCERTAIN_USAGE;
@@ -14139,25 +14164,6 @@ var WebsiteScraper = /** @class */ (function () {
14139
14164
  this.options = options;
14140
14165
  this.markdownScraper = new MarkdownScraper(tools, options);
14141
14166
  this.showdownConverter = createShowdownConverter();
14142
- /**/
14143
- // TODO: [🏄] !!!!!! Remove or describe why it is here
14144
- TODO_USE(Readability);
14145
- TODO_USE(Converter);
14146
- TODO_USE(JSDOM);
14147
- TODO_USE(createShowdownConverter);
14148
- /**/
14149
- /**/
14150
- var jsdom = new JSDOM();
14151
- var reader = new Readability(jsdom.window.document);
14152
- keepUnused(reader);
14153
- /**/
14154
- /**/
14155
- keepUnused(DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_VERBOSE, DEFAULT_SCRAPE_CACHE_DIRNAME);
14156
- keepUnused(EnvironmentMismatchError);
14157
- keepUnused(KnowledgeScrapeError);
14158
- keepUnused(getScraperIntermediateSource);
14159
- keepUnused();
14160
- /**/
14161
14167
  }
14162
14168
  Object.defineProperty(WebsiteScraper.prototype, "metadata", {
14163
14169
  /**
@@ -14183,8 +14189,6 @@ var WebsiteScraper = /** @class */ (function () {
14183
14189
  switch (_g.label) {
14184
14190
  case 0:
14185
14191
  _a = this.options, _b = _a.rootDirname, rootDirname = _b === void 0 ? process.cwd() : _b, _c = _a.cacheDirname, cacheDirname = _c === void 0 ? DEFAULT_SCRAPE_CACHE_DIRNAME : _c, _d = _a.intermediateFilesStrategy, intermediateFilesStrategy = _d === void 0 ? DEFAULT_INTERMEDIATE_FILES_STRATEGY : _d, _e = _a.isVerbose, isVerbose = _e === void 0 ? DEFAULT_IS_VERBOSE : _e;
14186
- // [🏄] !!!!!!!
14187
- keepUnused(rootDirname, cacheDirname, intermediateFilesStrategy, isVerbose);
14188
14192
  if (source.url === null) {
14189
14193
  throw new KnowledgeScrapeError('Website scraper requires URL');
14190
14194
  }
@@ -14195,11 +14199,8 @@ var WebsiteScraper = /** @class */ (function () {
14195
14199
  return [4 /*yield*/, source.asText()];
14196
14200
  case 1:
14197
14201
  jsdom = new (_f.apply(JSDOM, [void 0, _g.sent(), {
14198
- // <- TODO: !!!!!!! Problem with build is probbably in `new JSDOM();`
14199
14202
  url: source.url,
14200
14203
  }]))();
14201
- // [🏄] !!!!!!!
14202
- keepUnused(jsdom);
14203
14204
  reader = new Readability(jsdom.window.document);
14204
14205
  article = reader.parse();
14205
14206
  html = (article === null || article === void 0 ? void 0 : article.content) || (article === null || article === void 0 ? void 0 : article.textContent) || jsdom.window.document.body.innerHTML;