@juspay/neurolink 12.41.8 → 12.41.10
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.
|
@@ -1923,19 +1923,28 @@ export class OpenAIChatCompletionsProvider extends BaseProvider {
|
|
|
1923
1923
|
}
|
|
1924
1924
|
}
|
|
1925
1925
|
};
|
|
1926
|
+
// Captured now, as before, so deferring the analytics below does not
|
|
1927
|
+
// change the response time they report.
|
|
1928
|
+
const analyticsResponseTime = Date.now() - startTime;
|
|
1926
1929
|
const result = {
|
|
1927
1930
|
stream: transformedStream(),
|
|
1928
1931
|
provider: this.providerName,
|
|
1929
1932
|
model: modelId,
|
|
1930
|
-
analytics
|
|
1933
|
+
// Created once the turn has finished so that `analytics.model` (and the
|
|
1934
|
+
// cost priced from it) names the model the server actually echoed, the
|
|
1935
|
+
// same value `result.model` reports below, rather than the requested
|
|
1936
|
+
// one. `finishPromise` is settled by every exit path of the loop and is
|
|
1937
|
+
// never rejected, and the collector already waited on it, so deferring
|
|
1938
|
+
// adds no new way for this promise to stay pending.
|
|
1939
|
+
analytics: finishPromise.then(() => streamAnalyticsCollector.createAnalytics(this.providerName, observedServerModel ?? modelId, {
|
|
1931
1940
|
textStream: (async function* () { })(),
|
|
1932
1941
|
usage: usagePromise,
|
|
1933
1942
|
finishReason: finishPromise,
|
|
1934
|
-
},
|
|
1943
|
+
}, analyticsResponseTime, {
|
|
1935
1944
|
requestId: options.requestId ??
|
|
1936
1945
|
`${this.providerName}-stream-${Date.now()}`,
|
|
1937
1946
|
streamingMode: true,
|
|
1938
|
-
}),
|
|
1947
|
+
})),
|
|
1939
1948
|
toolsUsed,
|
|
1940
1949
|
metadata: streamMetadata,
|
|
1941
1950
|
};
|