@promptbook/core 0.98.0-8 → 0.98.0

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
@@ -25,10 +25,6 @@ Write AI applications using plain human language across multiple models and plat
25
25
 
26
26
 
27
27
 
28
- <blockquote style="color: #ff8811">
29
- <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
30
- </blockquote>
31
-
32
28
  ## 📦 Package `@promptbook/core`
33
29
 
34
30
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
package/esm/index.es.js CHANGED
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.98.0-8';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.98.0';
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
@@ -10529,6 +10529,24 @@ const $llmToolsRegister = new $Register('llm_execution_tools_constructors');
10529
10529
  * TODO: [®] DRY Register logic
10530
10530
  */
10531
10531
 
10532
+ /**
10533
+ * Detects if the code is running in a browser environment in main thread (Not in a web worker)
10534
+ *
10535
+ * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
10536
+ *
10537
+ * @public exported from `@promptbook/utils`
10538
+ */
10539
+ const $isRunningInBrowser = new Function(`
10540
+ try {
10541
+ return this === window;
10542
+ } catch (e) {
10543
+ return false;
10544
+ }
10545
+ `);
10546
+ /**
10547
+ * TODO: [🎺]
10548
+ */
10549
+
10532
10550
  /**
10533
10551
  * Detects if the code is running in a Node.js environment
10534
10552
  *
@@ -10547,6 +10565,28 @@ const $isRunningInNode = new Function(`
10547
10565
  * TODO: [🎺]
10548
10566
  */
10549
10567
 
10568
+ /**
10569
+ * Detects if the code is running in a web worker
10570
+ *
10571
+ * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
10572
+ *
10573
+ * @public exported from `@promptbook/utils`
10574
+ */
10575
+ const $isRunningInWebWorker = new Function(`
10576
+ try {
10577
+ if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
10578
+ return true;
10579
+ } else {
10580
+ return false;
10581
+ }
10582
+ } catch (e) {
10583
+ return false;
10584
+ }
10585
+ `);
10586
+ /**
10587
+ * TODO: [🎺]
10588
+ */
10589
+
10550
10590
  /**
10551
10591
  * Creates a message with all registered LLM tools
10552
10592
  *
@@ -10691,8 +10731,10 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
10691
10731
  .list()
10692
10732
  .find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
10693
10733
  if (registeredItem === undefined) {
10734
+ // console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
10694
10735
  throw new Error(spaceTrim((block) => `
10695
10736
  There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
10737
+ Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
10696
10738
 
10697
10739
  You have probably forgotten install and import the provider package.
10698
10740
  To fix this issue, you can:
@@ -11409,6 +11451,7 @@ const _OpenAiCompatibleMetadataRegistration = $llmToolsMetadataRegister.register
11409
11451
  options: {
11410
11452
  apiKey: 'sk-',
11411
11453
  baseURL: 'https://api.openai.com/v1',
11454
+ defaultModelName: 'gpt-4-turbo',
11412
11455
  isProxied: false,
11413
11456
  remoteServerUrl: DEFAULT_REMOTE_SERVER_URL,
11414
11457
  maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
@@ -11416,27 +11459,6 @@ const _OpenAiCompatibleMetadataRegistration = $llmToolsMetadataRegister.register
11416
11459
  };
11417
11460
  },
11418
11461
  createConfigurationFromEnv(env) {
11419
- // Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be instantiated directly
11420
- // However, we can provide configuration for users who want to manually instantiate it
11421
- if (typeof env.OPENAI_API_KEY === 'string') {
11422
- const options = {
11423
- apiKey: env.OPENAI_API_KEY,
11424
- isProxied: false,
11425
- remoteServerUrl: DEFAULT_REMOTE_SERVER_URL,
11426
- maxRequestsPerMinute: DEFAULT_MAX_REQUESTS_PER_MINUTE,
11427
- defaultModelName: 'gpt-4-turbo',
11428
- };
11429
- // Add baseURL if provided in environment
11430
- if (typeof env.OPENAI_BASE_URL === 'string') {
11431
- options.baseURL = env.OPENAI_BASE_URL;
11432
- }
11433
- return {
11434
- title: 'Open AI Compatible (from env)',
11435
- packageName: '@promptbook/openai',
11436
- className: 'OpenAiCompatibleExecutionTools',
11437
- options,
11438
- };
11439
- }
11440
11462
  return null;
11441
11463
  },
11442
11464
  });