@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.
@@ -346,7 +346,7 @@ const safeJSON = (text) => {
346
346
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
347
347
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
348
348
 
349
- const VERSION = '6.39.0'; // x-release-please-version
349
+ const VERSION = '6.44.0'; // x-release-please-version
350
350
 
351
351
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
352
352
  const isRunningInBrowser = () => {
@@ -2732,7 +2732,12 @@ _AbstractChatCompletionRunner_instances = new WeakSet(), _AbstractChatCompletion
2732
2732
  for (let i = this.messages.length - 1; i >= 0; i--) {
2733
2733
  const message = this.messages[i];
2734
2734
  if (isAssistantMessage(message) && message?.tool_calls?.length) {
2735
- return message.tool_calls.filter((x) => x.type === 'function').at(-1)?.function;
2735
+ for (let j = message.tool_calls.length - 1; j >= 0; j--) {
2736
+ const toolCall = message.tool_calls[j];
2737
+ if (toolCall?.type === 'function') {
2738
+ return toolCall.function;
2739
+ }
2740
+ }
2736
2741
  }
2737
2742
  }
2738
2743
  return;
@@ -4110,6 +4115,23 @@ let SpendAlerts$1 = class SpendAlerts extends APIResource {
4110
4115
  __security: { adminAPIKeyAuth: true },
4111
4116
  });
4112
4117
  }
4118
+ /**
4119
+ * Retrieves an organization spend alert.
4120
+ *
4121
+ * @example
4122
+ * ```ts
4123
+ * const organizationSpendAlert =
4124
+ * await client.admin.organization.spendAlerts.retrieve(
4125
+ * 'alert_id',
4126
+ * );
4127
+ * ```
4128
+ */
4129
+ retrieve(alertID, options) {
4130
+ return this._client.get(path `/organization/spend_alerts/${alertID}`, {
4131
+ ...options,
4132
+ __security: { adminAPIKeyAuth: true },
4133
+ });
4134
+ }
4113
4135
  /**
4114
4136
  * Updates an organization spend alert.
4115
4137
  *
@@ -5141,6 +5163,25 @@ class SpendAlerts extends APIResource {
5141
5163
  __security: { adminAPIKeyAuth: true },
5142
5164
  });
5143
5165
  }
5166
+ /**
5167
+ * Retrieves a project spend alert.
5168
+ *
5169
+ * @example
5170
+ * ```ts
5171
+ * const projectSpendAlert =
5172
+ * await client.admin.organization.projects.spendAlerts.retrieve(
5173
+ * 'alert_id',
5174
+ * { project_id: 'project_id' },
5175
+ * );
5176
+ * ```
5177
+ */
5178
+ retrieve(alertID, params, options) {
5179
+ const { project_id } = params;
5180
+ return this._client.get(path `/organization/projects/${project_id}/spend_alerts/${alertID}`, {
5181
+ ...options,
5182
+ __security: { adminAPIKeyAuth: true },
5183
+ });
5184
+ }
5144
5185
  /**
5145
5186
  * Updates a project spend alert.
5146
5187
  *
@@ -9958,7 +9999,10 @@ class OpenAI {
9958
9999
  if (isTimeout) {
9959
10000
  throw new APIConnectionTimeoutError();
9960
10001
  }
9961
- throw new APIConnectionError({ cause: response });
10002
+ throw new APIConnectionError({
10003
+ message: getConnectionErrorMessage(response),
10004
+ cause: response,
10005
+ });
9962
10006
  }
9963
10007
  const specialHeaders = [...response.headers.entries()]
9964
10008
  .filter(([name]) => name === 'x-request-id')
@@ -10290,6 +10334,25 @@ OpenAI.Evals = Evals;
10290
10334
  OpenAI.Containers = Containers;
10291
10335
  OpenAI.Skills = Skills;
10292
10336
  OpenAI.Videos = Videos;
10337
+ function getConnectionErrorMessage(error) {
10338
+ if (isUndiciDispatcherVersionMismatchError(error)) {
10339
+ 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(...) } });`;
10340
+ }
10341
+ return undefined;
10342
+ }
10343
+ function isUndiciDispatcherVersionMismatchError(error) {
10344
+ let current = error;
10345
+ for (let i = 0; i < 8 && current && typeof current === 'object'; i++) {
10346
+ const err = current;
10347
+ if (err.code === 'UND_ERR_INVALID_ARG' &&
10348
+ typeof err.message === 'string' &&
10349
+ err.message.includes('invalid onRequestStart method')) {
10350
+ return true;
10351
+ }
10352
+ current = err.cause;
10353
+ }
10354
+ return false;
10355
+ }
10293
10356
 
10294
10357
  function getEnumValues(entries) {
10295
10358
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");