@discomedia/utils 1.0.75 → 1.0.77

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/dist/index.mjs CHANGED
@@ -1701,7 +1701,7 @@ const safeJSON = (text) => {
1701
1701
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1702
1702
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1703
1703
 
1704
- const VERSION = '6.39.0'; // x-release-please-version
1704
+ const VERSION = '6.44.0'; // x-release-please-version
1705
1705
 
1706
1706
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1707
1707
  const isRunningInBrowser = () => {
@@ -4087,7 +4087,12 @@ _AbstractChatCompletionRunner_instances = new WeakSet(), _AbstractChatCompletion
4087
4087
  for (let i = this.messages.length - 1; i >= 0; i--) {
4088
4088
  const message = this.messages[i];
4089
4089
  if (isAssistantMessage(message) && message?.tool_calls?.length) {
4090
- return message.tool_calls.filter((x) => x.type === 'function').at(-1)?.function;
4090
+ for (let j = message.tool_calls.length - 1; j >= 0; j--) {
4091
+ const toolCall = message.tool_calls[j];
4092
+ if (toolCall?.type === 'function') {
4093
+ return toolCall.function;
4094
+ }
4095
+ }
4091
4096
  }
4092
4097
  }
4093
4098
  return;
@@ -5465,6 +5470,23 @@ let SpendAlerts$1 = class SpendAlerts extends APIResource {
5465
5470
  __security: { adminAPIKeyAuth: true },
5466
5471
  });
5467
5472
  }
5473
+ /**
5474
+ * Retrieves an organization spend alert.
5475
+ *
5476
+ * @example
5477
+ * ```ts
5478
+ * const organizationSpendAlert =
5479
+ * await client.admin.organization.spendAlerts.retrieve(
5480
+ * 'alert_id',
5481
+ * );
5482
+ * ```
5483
+ */
5484
+ retrieve(alertID, options) {
5485
+ return this._client.get(path `/organization/spend_alerts/${alertID}`, {
5486
+ ...options,
5487
+ __security: { adminAPIKeyAuth: true },
5488
+ });
5489
+ }
5468
5490
  /**
5469
5491
  * Updates an organization spend alert.
5470
5492
  *
@@ -6496,6 +6518,25 @@ class SpendAlerts extends APIResource {
6496
6518
  __security: { adminAPIKeyAuth: true },
6497
6519
  });
6498
6520
  }
6521
+ /**
6522
+ * Retrieves a project spend alert.
6523
+ *
6524
+ * @example
6525
+ * ```ts
6526
+ * const projectSpendAlert =
6527
+ * await client.admin.organization.projects.spendAlerts.retrieve(
6528
+ * 'alert_id',
6529
+ * { project_id: 'project_id' },
6530
+ * );
6531
+ * ```
6532
+ */
6533
+ retrieve(alertID, params, options) {
6534
+ const { project_id } = params;
6535
+ return this._client.get(path `/organization/projects/${project_id}/spend_alerts/${alertID}`, {
6536
+ ...options,
6537
+ __security: { adminAPIKeyAuth: true },
6538
+ });
6539
+ }
6499
6540
  /**
6500
6541
  * Updates a project spend alert.
6501
6542
  *
@@ -11313,7 +11354,10 @@ class OpenAI {
11313
11354
  if (isTimeout) {
11314
11355
  throw new APIConnectionTimeoutError();
11315
11356
  }
11316
- throw new APIConnectionError({ cause: response });
11357
+ throw new APIConnectionError({
11358
+ message: getConnectionErrorMessage(response),
11359
+ cause: response,
11360
+ });
11317
11361
  }
11318
11362
  const specialHeaders = [...response.headers.entries()]
11319
11363
  .filter(([name]) => name === 'x-request-id')
@@ -11645,6 +11689,25 @@ OpenAI.Evals = Evals;
11645
11689
  OpenAI.Containers = Containers;
11646
11690
  OpenAI.Skills = Skills;
11647
11691
  OpenAI.Videos = Videos;
11692
+ function getConnectionErrorMessage(error) {
11693
+ if (isUndiciDispatcherVersionMismatchError(error)) {
11694
+ return `Connection error. This may be caused by passing an undici dispatcher, such as ProxyAgent, that is incompatible with the fetch implementation. If you are using undici's ProxyAgent, pass the fetch implementation from the same undici package: import { fetch, ProxyAgent } from 'undici'; new OpenAI({ fetch, fetchOptions: { dispatcher: new ProxyAgent(...) } });`;
11695
+ }
11696
+ return undefined;
11697
+ }
11698
+ function isUndiciDispatcherVersionMismatchError(error) {
11699
+ let current = error;
11700
+ for (let i = 0; i < 8 && current && typeof current === 'object'; i++) {
11701
+ const err = current;
11702
+ if (err.code === 'UND_ERR_INVALID_ARG' &&
11703
+ typeof err.message === 'string' &&
11704
+ err.message.includes('invalid onRequestStart method')) {
11705
+ return true;
11706
+ }
11707
+ current = err.cause;
11708
+ }
11709
+ return false;
11710
+ }
11648
11711
 
11649
11712
  function getEnumValues(entries) {
11650
11713
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");