@discomedia/utils 1.0.46 → 1.0.50

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.
@@ -7,6 +7,10 @@ function isOpenRouterModel(model) {
7
7
  'openai/gpt-5-mini',
8
8
  'openai/gpt-5-nano',
9
9
  'openai/gpt-5.1',
10
+ 'openai/gpt-5.2',
11
+ 'openai/gpt-5.2-pro',
12
+ 'openai/gpt-5.1-codex',
13
+ 'openai/gpt-5.1-codex-max',
10
14
  'openai/gpt-oss-120b',
11
15
  'z.ai/glm-4.5',
12
16
  'z.ai/glm-4.5-air',
@@ -254,7 +258,7 @@ const safeJSON = (text) => {
254
258
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
255
259
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
256
260
 
257
- const VERSION = '6.9.1'; // x-release-please-version
261
+ const VERSION = '6.10.0'; // x-release-please-version
258
262
 
259
263
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
260
264
  const isRunningInBrowser = () => {
@@ -6095,6 +6099,17 @@ class Responses extends APIResource {
6095
6099
  cancel(responseID, options) {
6096
6100
  return this._client.post(path `/responses/${responseID}/cancel`, options);
6097
6101
  }
6102
+ /**
6103
+ * Compact conversation
6104
+ *
6105
+ * @example
6106
+ * ```ts
6107
+ * const compactedResponse = await client.responses.compact();
6108
+ * ```
6109
+ */
6110
+ compact(body = {}, options) {
6111
+ return this._client.post('/responses/compact', { body, ...options });
6112
+ }
6098
6113
  }
6099
6114
  Responses.InputItems = InputItems;
6100
6115
  Responses.InputTokens = InputTokens;
@@ -7237,6 +7252,22 @@ const openAiModelCosts = {
7237
7252
  inputCost: 1.25 / 1_000_000,
7238
7253
  outputCost: 10 / 1_000_000,
7239
7254
  },
7255
+ 'gpt-5.2': {
7256
+ inputCost: 1.5 / 1_000_000,
7257
+ outputCost: 12 / 1_000_000,
7258
+ },
7259
+ 'gpt-5.2-pro': {
7260
+ inputCost: 3 / 1_000_000,
7261
+ outputCost: 24 / 1_000_000,
7262
+ },
7263
+ 'gpt-5.1-codex': {
7264
+ inputCost: 1.1 / 1_000_000,
7265
+ outputCost: 8.8 / 1_000_000,
7266
+ },
7267
+ 'gpt-5.1-codex-max': {
7268
+ inputCost: 1.8 / 1_000_000,
7269
+ outputCost: 14.4 / 1_000_000,
7270
+ },
7240
7271
  'o4-mini': {
7241
7272
  inputCost: 1.1 / 1_000_000,
7242
7273
  outputCost: 4.4 / 1_000_000,
@@ -7698,6 +7729,10 @@ const isSupportedModel = (model) => {
7698
7729
  'gpt-5-mini',
7699
7730
  'gpt-5-nano',
7700
7731
  'gpt-5.1',
7732
+ 'gpt-5.2',
7733
+ 'gpt-5.2-pro',
7734
+ 'gpt-5.1-codex',
7735
+ 'gpt-5.1-codex-max',
7701
7736
  'o4-mini',
7702
7737
  'o3',
7703
7738
  ].includes(model);
@@ -7710,7 +7745,21 @@ const isSupportedModel = (model) => {
7710
7745
  function supportsTemperature(model) {
7711
7746
  // Reasoning models don't support temperature
7712
7747
  // GPT-5 models also do not support temperature
7713
- const reasoningAndGPT5Models = ['o1', 'o1-mini', 'o3-mini', 'o4-mini', 'o3', 'gpt-5', 'gpt-5-mini', 'gpt-5-nano', 'gpt-5.1'];
7748
+ const reasoningAndGPT5Models = [
7749
+ 'o1',
7750
+ 'o1-mini',
7751
+ 'o3-mini',
7752
+ 'o4-mini',
7753
+ 'o3',
7754
+ 'gpt-5',
7755
+ 'gpt-5-mini',
7756
+ 'gpt-5-nano',
7757
+ 'gpt-5.1',
7758
+ 'gpt-5.2',
7759
+ 'gpt-5.2-pro',
7760
+ 'gpt-5.1-codex',
7761
+ 'gpt-5.1-codex-max',
7762
+ ];
7714
7763
  return !reasoningAndGPT5Models.includes(model);
7715
7764
  }
7716
7765
  /**
@@ -7728,7 +7777,16 @@ function isReasoningModel(model) {
7728
7777
  * @returns True if the model is a GPT-5 model, false otherwise.
7729
7778
  */
7730
7779
  function isGPT5Model(model) {
7731
- const gpt5Models = ['gpt-5', 'gpt-5-mini', 'gpt-5-nano', 'gpt-5.1'];
7780
+ const gpt5Models = [
7781
+ 'gpt-5',
7782
+ 'gpt-5-mini',
7783
+ 'gpt-5-nano',
7784
+ 'gpt-5.1',
7785
+ 'gpt-5.2',
7786
+ 'gpt-5.2-pro',
7787
+ 'gpt-5.1-codex',
7788
+ 'gpt-5.1-codex-max',
7789
+ ];
7732
7790
  return gpt5Models.includes(model);
7733
7791
  }
7734
7792
  /**
@@ -7969,6 +8027,18 @@ async function makeLLMCall(input, options = {}) {
7969
8027
  return await makeResponsesAPICall(processedInput, responsesOptions);
7970
8028
  }
7971
8029
 
8030
+ const MULTIMODAL_VISION_MODELS = new Set([
8031
+ 'gpt-4o-mini',
8032
+ 'gpt-4o',
8033
+ 'gpt-5',
8034
+ 'gpt-5-mini',
8035
+ 'gpt-5-nano',
8036
+ 'gpt-5.1',
8037
+ 'gpt-5.2',
8038
+ 'gpt-5.2-pro',
8039
+ 'gpt-5.1-codex',
8040
+ 'gpt-5.1-codex-max',
8041
+ ]);
7972
8042
  /**
7973
8043
  * Makes a call to the OpenAI Images API to generate images based on a text prompt.
7974
8044
  *
@@ -8005,7 +8075,11 @@ async function makeLLMCall(input, options = {}) {
8005
8075
  * @throws Error if the API call fails or invalid parameters are provided
8006
8076
  */
8007
8077
  async function makeImagesCall(prompt, options = {}) {
8008
- const { size = 'auto', outputFormat = 'webp', compression = 50, quality = 'high', count = 1, background = 'auto', moderation = 'auto', apiKey } = options;
8078
+ const { size = 'auto', outputFormat = 'webp', compression = 50, quality = 'high', count = 1, background = 'auto', moderation = 'auto', apiKey, visionModel, } = options;
8079
+ const supportedVisionModel = visionModel && MULTIMODAL_VISION_MODELS.has(visionModel) ? visionModel : undefined;
8080
+ if (visionModel && !supportedVisionModel) {
8081
+ console.warn(`Vision model ${visionModel} is not recognized as a multimodal OpenAI model. Ignoring for image usage metadata.`);
8082
+ }
8009
8083
  // Get API key
8010
8084
  const effectiveApiKey = apiKey || process.env.OPENAI_API_KEY;
8011
8085
  if (!effectiveApiKey) {
@@ -8065,6 +8139,7 @@ async function makeImagesCall(prompt, options = {}) {
8065
8139
  provider: 'openai',
8066
8140
  model: 'gpt-image-1',
8067
8141
  cost,
8142
+ ...(supportedVisionModel ? { visionModel: supportedVisionModel } : {}),
8068
8143
  },
8069
8144
  };
8070
8145
  return enhancedResponse;
@@ -8765,9 +8840,10 @@ function getLastFullTradingDateImpl(currentDate = new Date()) {
8765
8840
  if (calendar.isEarlyCloseDay(prevMarketDay)) {
8766
8841
  prevCloseMinutes = MARKET_CONFIG.TIMES.EARLY_CLOSE.hour * 60 + MARKET_CONFIG.TIMES.EARLY_CLOSE.minute;
8767
8842
  }
8768
- const year = prevMarketDay.getUTCFullYear();
8769
- const month = prevMarketDay.getUTCMonth();
8770
- const day = prevMarketDay.getUTCDate();
8843
+ const prevNYDate = toNYTime(prevMarketDay);
8844
+ const year = prevNYDate.getUTCFullYear();
8845
+ const month = prevNYDate.getUTCMonth();
8846
+ const day = prevNYDate.getUTCDate();
8771
8847
  const closeHour = Math.floor(prevCloseMinutes / 60);
8772
8848
  const closeMinute = prevCloseMinutes % 60;
8773
8849
  return fromNYTime(new Date(Date.UTC(year, month, day, closeHour, closeMinute, 0, 0)));