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