@posthog/ai 8.16.3 → 8.17.1

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.
@@ -548,7 +548,7 @@ function formatOpenAIResponsesInput(input, instructions) {
548
548
  }
549
549
  //#endregion
550
550
  //#region package.json
551
- var version = "8.16.3";
551
+ var version = "8.17.1";
552
552
  //#endregion
553
553
  //#region src/serializeError.ts
554
554
  const DEFAULT_MAX_DEPTH = 3;
@@ -1767,6 +1767,16 @@ var WrappedCompletions$1 = class extends AzureOpenAI.Chat.Completions {
1767
1767
  return stream2;
1768
1768
  }
1769
1769
  return value;
1770
+ }).catch(async (error) => {
1771
+ await captureAiGeneration(this.phClient, buildChatErrorOptions({
1772
+ client: this.phClient,
1773
+ provider: "azure",
1774
+ baseURL: this.baseURL,
1775
+ params: openAIParams,
1776
+ monitoring: posthogParams,
1777
+ modelParametersSource: body
1778
+ }, error, { latency: (Date.now() - startTime) / 1e3 }));
1779
+ throw error;
1770
1780
  }));
1771
1781
  else return preserveProviderPromise(parentPromise, parentPromise.then(async (result) => {
1772
1782
  if ("choices" in result) await captureAiGenerationAfterSuccess(this.phClient, buildChatSuccessOptions({
@@ -1885,6 +1895,16 @@ var WrappedResponses$1 = class extends AzureOpenAI.Responses {
1885
1895
  return stream2;
1886
1896
  }
1887
1897
  return value;
1898
+ }).catch(async (error) => {
1899
+ await captureAiGeneration(this.phClient, buildResponsesErrorOptions({
1900
+ client: this.phClient,
1901
+ provider: "azure",
1902
+ baseURL: this.baseURL,
1903
+ params: openAIParams,
1904
+ monitoring: posthogParams,
1905
+ modelParametersSource: body
1906
+ }, error, { latency: (Date.now() - startTime) / 1e3 }));
1907
+ throw error;
1888
1908
  }));
1889
1909
  else return preserveProviderPromise(parentPromise, parentPromise.then(async (result) => {
1890
1910
  if ("output" in result) {
@@ -2095,6 +2115,16 @@ var WrappedCompletions = class extends Completions {
2095
2115
  return stream2;
2096
2116
  }
2097
2117
  return value;
2118
+ }).catch(async (error) => {
2119
+ await captureAiGeneration(this.phClient, buildChatErrorOptions({
2120
+ client: this.phClient,
2121
+ provider: "openai",
2122
+ baseURL: this.baseURL,
2123
+ params: openAIParams,
2124
+ monitoring: posthogParams,
2125
+ modelParametersSource: body
2126
+ }, error, { latency: (Date.now() - startTime) / 1e3 }));
2127
+ throw error;
2098
2128
  }));
2099
2129
  else return preserveProviderPromise(parentPromise, parentPromise.then(async (result) => {
2100
2130
  if ("choices" in result) await captureAiGenerationAfterSuccess(this.phClient, buildChatSuccessOptions({
@@ -2213,6 +2243,16 @@ var WrappedResponses = class extends Responses {
2213
2243
  return stream2;
2214
2244
  }
2215
2245
  return value;
2246
+ }).catch(async (error) => {
2247
+ await captureAiGeneration(this.phClient, buildResponsesErrorOptions({
2248
+ client: this.phClient,
2249
+ provider: "openai",
2250
+ baseURL: this.baseURL,
2251
+ params: openAIParams,
2252
+ monitoring: posthogParams,
2253
+ modelParametersSource: body
2254
+ }, error, { latency: (Date.now() - startTime) / 1e3 }));
2255
+ throw error;
2216
2256
  }));
2217
2257
  else return preserveProviderPromise(parentPromise, parentPromise.then(async (result) => {
2218
2258
  if ("output" in result) {