@vscode/chat-lib 0.4.1-2 → 0.4.1-20
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.
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.d.ts +2 -1
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.js +6 -7
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.js.map +1 -1
- package/dist/src/_internal/extension/common/constants.d.ts +0 -1
- package/dist/src/_internal/extension/common/constants.d.ts.map +1 -1
- package/dist/src/_internal/extension/common/constants.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/completionsFromNetwork.js +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/completionsFromNetwork.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/model.d.ts +4 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/model.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/model.js +4 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/model.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/delay.d.ts +3 -1
- package/dist/src/_internal/extension/inlineEdits/common/delay.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/delay.js +6 -0
- package/dist/src/_internal/extension/inlineEdits/common/delay.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/editRebase.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/editRebase.js +2 -35
- package/dist/src/_internal/extension/inlineEdits/common/editRebase.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.d.ts +6 -0
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.js +19 -35
- package/dist/src/_internal/extension/inlineEdits/common/userInteractionMonitor.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.d.ts +1 -0
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts +21 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js +218 -106
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts +7 -0
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js +18 -3
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditResult.d.ts +2 -0
- package/dist/src/_internal/extension/inlineEdits/node/nextEditResult.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditResult.js.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts +19 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js +367 -98
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.d.ts +6 -3
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.js +9 -3
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/diffHistoryForPrompt.d.ts +6 -1
- package/dist/src/_internal/extension/xtab/common/diffHistoryForPrompt.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/diffHistoryForPrompt.js +3 -1
- package/dist/src/_internal/extension/xtab/common/diffHistoryForPrompt.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/lintErrors.js +2 -1
- package/dist/src/_internal/extension/xtab/common/lintErrors.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts +6 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js +43 -6
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/recentFilesForPrompt.d.ts +22 -0
- package/dist/src/_internal/extension/xtab/common/recentFilesForPrompt.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/recentFilesForPrompt.js +116 -17
- package/dist/src/_internal/extension/xtab/common/recentFilesForPrompt.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/similarFilesContextService.d.ts +10 -0
- package/dist/src/_internal/extension/xtab/common/similarFilesContextService.d.ts.map +1 -0
- package/dist/src/_internal/extension/xtab/common/similarFilesContextService.js +10 -0
- package/dist/src/_internal/extension/xtab/common/similarFilesContextService.js.map +1 -0
- package/dist/src/_internal/extension/xtab/common/tags.d.ts +1 -0
- package/dist/src/_internal/extension/xtab/common/tags.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/tags.js +1 -0
- package/dist/src/_internal/extension/xtab/common/tags.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.js +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.d.ts +2 -1
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.js +6 -3
- package/dist/src/_internal/extension/xtab/node/xtabEndpoint.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.js +3 -2
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts +6 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js +105 -20
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js.map +1 -1
- package/dist/src/_internal/platform/authentication/common/copilotToken.d.ts +4 -0
- package/dist/src/_internal/platform/authentication/common/copilotToken.d.ts.map +1 -1
- package/dist/src/_internal/platform/authentication/common/copilotToken.js +6 -0
- package/dist/src/_internal/platform/authentication/common/copilotToken.js.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.d.ts +2 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.d.ts.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.js +61 -17
- package/dist/src/_internal/platform/chat/common/commonTypes.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +35 -48
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +57 -66
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/capiClient.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/capiClient.js +1 -0
- package/dist/src/_internal/platform/endpoint/common/capiClient.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts +2 -0
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js +32 -5
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts +3 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.js +1 -0
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/autoChatEndpoint.d.ts +2 -1
- package/dist/src/_internal/platform/endpoint/node/autoChatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/autoChatEndpoint.js +6 -3
- package/dist/src/_internal/platform/endpoint/node/autoChatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts +6 -2
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js +36 -14
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.d.ts +2 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.js +5 -3
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js +62 -13
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/proxyXtabEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/proxyXtabEndpoint.js +1 -0
- package/dist/src/_internal/platform/endpoint/node/proxyXtabEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts +1 -0
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js +14 -10
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
- package/dist/src/_internal/platform/git/common/gitService.d.ts +4 -0
- package/dist/src/_internal/platform/git/common/gitService.d.ts.map +1 -1
- package/dist/src/_internal/platform/git/common/gitService.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubAPI.d.ts +1 -0
- package/dist/src/_internal/platform/github/common/githubAPI.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubAPI.js +2 -0
- package/dist/src/_internal/platform/github/common/githubAPI.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.d.ts +10 -0
- package/dist/src/_internal/platform/github/common/githubService.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.js +38 -0
- package/dist/src/_internal/platform/github/common/githubService.js.map +1 -1
- package/dist/src/_internal/platform/github/common/nullOctokitServiceImpl.d.ts +2 -1
- package/dist/src/_internal/platform/github/common/nullOctokitServiceImpl.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/nullOctokitServiceImpl.js +3 -0
- package/dist/src/_internal/platform/github/common/nullOctokitServiceImpl.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/triggerOptions.d.ts +8 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/triggerOptions.d.ts.map +1 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/triggerOptions.js +17 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/triggerOptions.js.map +1 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts +44 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.js +71 -2
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js +5 -5
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts +15 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js +22 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/node/inlineEditsModelService.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/node/inlineEditsModelService.js +9 -44
- package/dist/src/_internal/platform/inlineEdits/node/inlineEditsModelService.js.map +1 -1
- package/dist/src/_internal/platform/nesFetch/common/responseStream.js +2 -35
- package/dist/src/_internal/platform/nesFetch/common/responseStream.js.map +1 -1
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.js +3 -36
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/anthropic.d.ts +14 -12
- package/dist/src/_internal/platform/networking/common/anthropic.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/anthropic.js +38 -23
- package/dist/src/_internal/platform/networking/common/anthropic.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts +60 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.js +56 -5
- package/dist/src/_internal/platform/networking/common/fetcherService.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.d.ts +42 -4
- package/dist/src/_internal/platform/networking/common/networking.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.js +20 -6
- package/dist/src/_internal/platform/networking/common/networking.js.map +1 -1
- package/dist/src/_internal/platform/networking/node/chatWebSocketManager.d.ts +83 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketManager.d.ts.map +1 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketManager.js +496 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketManager.js.map +1 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.d.ts +89 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.d.ts.map +1 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.js +269 -0
- package/dist/src/_internal/platform/networking/node/chatWebSocketTelemetry.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiAttributes.d.ts +85 -0
- package/dist/src/_internal/platform/otel/common/genAiAttributes.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiAttributes.js +105 -0
- package/dist/src/_internal/platform/otel/common/genAiAttributes.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiEvents.d.ts +28 -0
- package/dist/src/_internal/platform/otel/common/genAiEvents.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiEvents.js +91 -0
- package/dist/src/_internal/platform/otel/common/genAiEvents.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiMetrics.d.ts +30 -0
- package/dist/src/_internal/platform/otel/common/genAiMetrics.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/genAiMetrics.js +68 -0
- package/dist/src/_internal/platform/otel/common/genAiMetrics.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/index.d.ts +8 -0
- package/dist/src/_internal/platform/otel/common/index.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/index.js +35 -0
- package/dist/src/_internal/platform/otel/common/index.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/messageFormatters.d.ts +85 -0
- package/dist/src/_internal/platform/otel/common/messageFormatters.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/messageFormatters.js +122 -0
- package/dist/src/_internal/platform/otel/common/messageFormatters.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/noopOtelService.d.ts +23 -0
- package/dist/src/_internal/platform/otel/common/noopOtelService.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/noopOtelService.js +46 -0
- package/dist/src/_internal/platform/otel/common/noopOtelService.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/otelConfig.d.ts +35 -0
- package/dist/src/_internal/platform/otel/common/otelConfig.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/otelConfig.js +140 -0
- package/dist/src/_internal/platform/otel/common/otelConfig.js.map +1 -0
- package/dist/src/_internal/platform/otel/common/otelService.d.ts +100 -0
- package/dist/src/_internal/platform/otel/common/otelService.d.ts.map +1 -0
- package/dist/src/_internal/platform/otel/common/otelService.js +10 -0
- package/dist/src/_internal/platform/otel/common/otelService.js.map +1 -0
- package/dist/src/_internal/platform/proxyModels/node/proxyModelsService.js +4 -37
- package/dist/src/_internal/platform/proxyModels/node/proxyModelsService.js.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.d.ts +1 -0
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.d.ts.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.js +3 -0
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.js.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.d.ts +2 -0
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.d.ts.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.d.ts +9 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.js +33 -15
- package/dist/src/_internal/platform/telemetry/common/telemetry.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/node/azureInsightsReporter.d.ts +1 -1
- package/dist/src/_internal/platform/telemetry/node/azureInsightsReporter.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/node/azureInsightsReporter.js +3 -2
- package/dist/src/_internal/platform/telemetry/node/azureInsightsReporter.js.map +1 -1
- package/dist/src/_internal/util/common/errors.d.ts +4 -2
- package/dist/src/_internal/util/common/errors.d.ts.map +1 -1
- package/dist/src/_internal/util/common/errors.js +16 -12
- package/dist/src/_internal/util/common/errors.js.map +1 -1
- package/dist/src/_internal/util/common/result.js +4 -37
- package/dist/src/_internal/util/common/result.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +14 -2
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js +17 -3
- package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +17 -0
- package/dist/src/main.js.map +1 -1
- package/dist/src/package.json +385 -234
- package/package.json +5 -4
|
@@ -3,48 +3,16 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
6
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
23
7
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
8
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
9
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
10
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
11
|
};
|
|
28
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
-
var ownKeys = function(o) {
|
|
30
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
-
var ar = [];
|
|
32
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
-
return ar;
|
|
34
|
-
};
|
|
35
|
-
return ownKeys(o);
|
|
36
|
-
};
|
|
37
|
-
return function (mod) {
|
|
38
|
-
if (mod && mod.__esModule) return mod;
|
|
39
|
-
var result = {};
|
|
40
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
-
__setModuleDefault(result, mod);
|
|
42
|
-
return result;
|
|
43
|
-
};
|
|
44
|
-
})();
|
|
45
12
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
46
13
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
47
14
|
};
|
|
15
|
+
var ChatMLFetcherImpl_1;
|
|
48
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
17
|
exports.ChatMLFetcherImpl = exports.AbstractChatMLFetcher = void 0;
|
|
50
18
|
exports.createTelemetryData = createTelemetryData;
|
|
@@ -68,21 +36,24 @@ const fetcherService_1 = require("../../../platform/networking/common/fetcherSer
|
|
|
68
36
|
const networking_1 = require("../../../platform/networking/common/networking");
|
|
69
37
|
const openai_1 = require("../../../platform/networking/common/openai");
|
|
70
38
|
const chatStream_1 = require("../../../platform/networking/node/chatStream");
|
|
39
|
+
const chatWebSocketManager_1 = require("../../../platform/networking/node/chatWebSocketManager");
|
|
71
40
|
const stream_1 = require("../../../platform/networking/node/stream");
|
|
72
41
|
const fetch_2 = require("../../../platform/openai/node/fetch");
|
|
42
|
+
const index_1 = require("../../../platform/otel/common/index");
|
|
43
|
+
const otelService_1 = require("../../../platform/otel/common/otelService");
|
|
73
44
|
const requestLogger_1 = require("../../../platform/requestLogger/node/requestLogger");
|
|
74
45
|
const nullExperimentationService_1 = require("../../../platform/telemetry/common/nullExperimentationService");
|
|
75
46
|
const telemetry_1 = require("../../../platform/telemetry/common/telemetry");
|
|
76
47
|
const telemetryData_1 = require("../../../platform/telemetry/common/telemetryData");
|
|
77
48
|
const anomalyDetection_1 = require("../../../util/common/anomalyDetection");
|
|
78
|
-
const
|
|
79
|
-
const errorsUtil = __importStar(require("../../../util/common/errors"));
|
|
49
|
+
const errors_1 = require("../../../util/common/errors");
|
|
80
50
|
const async_1 = require("../../../util/vs/base/common/async");
|
|
81
|
-
const
|
|
51
|
+
const errors_2 = require("../../../util/vs/base/common/errors");
|
|
82
52
|
const event_1 = require("../../../util/vs/base/common/event");
|
|
83
53
|
const lifecycle_1 = require("../../../util/vs/base/common/lifecycle");
|
|
84
54
|
const strings_1 = require("../../../util/vs/base/common/strings");
|
|
85
55
|
const uuid_1 = require("../../../util/vs/base/common/uuid");
|
|
56
|
+
const instantiation_1 = require("../../../util/vs/platform/instantiation/common/instantiation");
|
|
86
57
|
const openAIEndpoint_1 = require("../../byok/node/openAIEndpoint");
|
|
87
58
|
const constants_1 = require("../../common/constants");
|
|
88
59
|
const powerService_1 = require("../../power/common/powerService");
|
|
@@ -116,7 +87,9 @@ class AbstractChatMLFetcher extends lifecycle_1.Disposable {
|
|
|
116
87
|
}
|
|
117
88
|
exports.AbstractChatMLFetcher = AbstractChatMLFetcher;
|
|
118
89
|
let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
119
|
-
|
|
90
|
+
static { ChatMLFetcherImpl_1 = this; }
|
|
91
|
+
static { this._maxConsecutiveWebSocketFallbacks = 3; }
|
|
92
|
+
constructor(_fetcherService, _telemetryService, _requestLogger, _logService, _authenticationService, _interactionService, _chatQuotaService, _capiClientService, options, _configurationService, _experimentationService, _powerService, _instantiationService, _webSocketManager, _otelService) {
|
|
120
93
|
super(options);
|
|
121
94
|
this._fetcherService = _fetcherService;
|
|
122
95
|
this._telemetryService = _telemetryService;
|
|
@@ -129,23 +102,37 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
129
102
|
this._configurationService = _configurationService;
|
|
130
103
|
this._experimentationService = _experimentationService;
|
|
131
104
|
this._powerService = _powerService;
|
|
105
|
+
this._instantiationService = _instantiationService;
|
|
106
|
+
this._webSocketManager = _webSocketManager;
|
|
107
|
+
this._otelService = _otelService;
|
|
132
108
|
/**
|
|
133
109
|
* Delays (in ms) between connectivity check attempts before retrying a failed request.
|
|
134
110
|
* Configurable for testing purposes.
|
|
135
111
|
*/
|
|
136
112
|
this.connectivityCheckDelays = [1000, 10000, 10000];
|
|
113
|
+
/**
|
|
114
|
+
* Tracks consecutive WebSocket request failures where the HTTP retry succeeded.
|
|
115
|
+
* After {@link _maxConsecutiveWebSocketFallbacks} such failures, WebSocket requests are disabled entirely.
|
|
116
|
+
*/
|
|
117
|
+
this._consecutiveWebSocketRetryFallbacks = 0;
|
|
137
118
|
}
|
|
138
119
|
/**
|
|
139
120
|
* Note: the returned array of strings may be less than `n` (e.g., in case there were errors during streaming)
|
|
140
121
|
*/
|
|
141
122
|
async fetchMany(opts, token) {
|
|
142
|
-
let { debugName, endpoint: chatEndpoint, finishedCb, location, messages, requestOptions, source, telemetryProperties, userInitiatedRequest } = opts;
|
|
123
|
+
let { debugName, endpoint: chatEndpoint, finishedCb, location, messages, requestOptions, source, telemetryProperties, userInitiatedRequest, requestKindOptions, conversationId, turnId, useWebSocket, ignoreStatefulMarker } = opts;
|
|
124
|
+
if (useWebSocket && this._consecutiveWebSocketRetryFallbacks >= ChatMLFetcherImpl_1._maxConsecutiveWebSocketFallbacks) {
|
|
125
|
+
this._logService.debug(`[ChatWebSocketManager] Disabling WebSocket for request due to ${this._consecutiveWebSocketRetryFallbacks} consecutive WebSocket failures with successful HTTP fallback.`);
|
|
126
|
+
useWebSocket = false;
|
|
127
|
+
ignoreStatefulMarker = true;
|
|
128
|
+
}
|
|
143
129
|
if (!telemetryProperties) {
|
|
144
130
|
telemetryProperties = {};
|
|
145
131
|
}
|
|
146
132
|
if (!telemetryProperties.messageSource) {
|
|
147
133
|
telemetryProperties.messageSource = debugName;
|
|
148
134
|
}
|
|
135
|
+
const transport = useWebSocket ? 'websocket' : 'http';
|
|
149
136
|
// TODO @lramos15 telemetry should not drive request ids
|
|
150
137
|
const ourRequestId = telemetryProperties.requestId ?? telemetryProperties.messageId ?? (0, uuid_1.generateUuid)();
|
|
151
138
|
const maxResponseTokens = chatEndpoint.maxOutputTokens;
|
|
@@ -159,6 +146,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
159
146
|
const postOptions = this.preparePostOptions(requestOptions);
|
|
160
147
|
const requestBody = chatEndpoint.createRequestBody({
|
|
161
148
|
...opts,
|
|
149
|
+
ignoreStatefulMarker,
|
|
162
150
|
requestId: ourRequestId,
|
|
163
151
|
postOptions
|
|
164
152
|
});
|
|
@@ -173,7 +161,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
173
161
|
ourRequestId,
|
|
174
162
|
location: opts.location,
|
|
175
163
|
body: requestBody,
|
|
176
|
-
ignoreStatefulMarker
|
|
164
|
+
ignoreStatefulMarker,
|
|
177
165
|
isConversationRequest: opts.isConversationRequest,
|
|
178
166
|
customMetadata: opts.customMetadata
|
|
179
167
|
});
|
|
@@ -187,6 +175,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
187
175
|
let actualStatusCode;
|
|
188
176
|
let suspendEventSeen;
|
|
189
177
|
let resumeEventSeen;
|
|
178
|
+
let otelInferenceSpan;
|
|
190
179
|
try {
|
|
191
180
|
let response;
|
|
192
181
|
const payloadValidationResult = isValidChatPayload(opts.messages, postOptions, chatEndpoint, this._configurationService, this._experimentationService);
|
|
@@ -201,13 +190,31 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
201
190
|
else {
|
|
202
191
|
const copilotToken = await this._authenticationService.getCopilotToken();
|
|
203
192
|
usernameToScrub = copilotToken.username;
|
|
204
|
-
const fetchResult = await this._fetchAndStreamChat(chatEndpoint, requestBody, baseTelemetry, streamRecorder.callback, requestOptions.secretKey, copilotToken, opts.location, ourRequestId, postOptions.n, token, userInitiatedRequest, telemetryProperties, opts.useFetcher, canRetryOnce);
|
|
193
|
+
const fetchResult = await this._fetchAndStreamChat(chatEndpoint, requestBody, baseTelemetry, streamRecorder.callback, requestOptions.secretKey, copilotToken, opts.location, ourRequestId, postOptions.n, token, userInitiatedRequest, useWebSocket, turnId, conversationId, telemetryProperties, opts.useFetcher, canRetryOnce, requestKindOptions);
|
|
205
194
|
response = fetchResult.result;
|
|
206
195
|
actualFetcher = fetchResult.fetcher;
|
|
207
196
|
actualBytesReceived = fetchResult.bytesReceived;
|
|
208
197
|
actualStatusCode = fetchResult.statusCode;
|
|
209
198
|
suspendEventSeen = fetchResult.suspendEventSeen;
|
|
210
199
|
resumeEventSeen = fetchResult.resumeEventSeen;
|
|
200
|
+
otelInferenceSpan = fetchResult.otelSpan;
|
|
201
|
+
// Tag span with debug name so orphaned spans (title, progressMessages, etc.) are identifiable
|
|
202
|
+
otelInferenceSpan?.setAttribute(index_1.GenAiAttr.AGENT_NAME, debugName);
|
|
203
|
+
// Capture request content when enabled
|
|
204
|
+
if (this._otelService.config.captureContent && otelInferenceSpan) {
|
|
205
|
+
const capiMessages = requestBody.messages;
|
|
206
|
+
if (capiMessages) {
|
|
207
|
+
otelInferenceSpan.setAttribute(index_1.GenAiAttr.INPUT_MESSAGES, (0, index_1.truncateForOTel)(JSON.stringify((0, index_1.toInputMessages)(capiMessages))));
|
|
208
|
+
}
|
|
209
|
+
// Capture system instructions (first system message)
|
|
210
|
+
const systemMsg = capiMessages?.find(m => m.role === 'system');
|
|
211
|
+
if (systemMsg?.content) {
|
|
212
|
+
const sysInstructions = (0, index_1.toSystemInstructions)(systemMsg.content);
|
|
213
|
+
if (sysInstructions) {
|
|
214
|
+
otelInferenceSpan.setAttribute(index_1.GenAiAttr.SYSTEM_INSTRUCTIONS, (0, index_1.truncateForOTel)(JSON.stringify(sysInstructions)));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
211
218
|
tokenCount = await chatEndpoint.acquireTokenizer().countMessagesTokens(messages);
|
|
212
219
|
const extensionId = source?.extensionId ?? constants_1.EXTENSION_ID;
|
|
213
220
|
this._onDidMakeChatMLRequest.fire({
|
|
@@ -221,7 +228,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
221
228
|
pendingLoggedChatRequest?.markTimeToFirstToken(timeToFirstToken);
|
|
222
229
|
switch (response.type) {
|
|
223
230
|
case fetch_2.FetchResponseKind.Success: {
|
|
224
|
-
const result = await this.processSuccessfulResponse(response, messages, requestBody, ourRequestId, maxResponseTokens, tokenCount, timeToFirstToken, streamRecorder, baseTelemetry, chatEndpoint, userInitiatedRequest, actualFetcher, actualBytesReceived, suspendEventSeen, resumeEventSeen);
|
|
231
|
+
const result = await this.processSuccessfulResponse(response, messages, requestBody, ourRequestId, maxResponseTokens, tokenCount, timeToFirstToken, streamRecorder, baseTelemetry, chatEndpoint, userInitiatedRequest, transport, actualFetcher, actualBytesReceived, suspendEventSeen, resumeEventSeen);
|
|
225
232
|
// Handle FilteredRetry case with augmented messages
|
|
226
233
|
if (result.type === commonTypes_1.ChatFetchResponseType.FilteredRetry) {
|
|
227
234
|
if (opts.enableRetryOnFilter) {
|
|
@@ -269,6 +276,72 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
269
276
|
};
|
|
270
277
|
}
|
|
271
278
|
pendingLoggedChatRequest?.resolve(result, streamRecorder.deltas);
|
|
279
|
+
// Record OTel token usage metrics if available
|
|
280
|
+
if (result.type === commonTypes_1.ChatFetchResponseType.Success && result.usage) {
|
|
281
|
+
const metricAttrs = {
|
|
282
|
+
operationName: index_1.GenAiOperationName.CHAT,
|
|
283
|
+
providerName: index_1.GenAiProviderName.GITHUB,
|
|
284
|
+
requestModel: chatEndpoint.model,
|
|
285
|
+
responseModel: result.resolvedModel,
|
|
286
|
+
};
|
|
287
|
+
if (result.usage.prompt_tokens) {
|
|
288
|
+
index_1.GenAiMetrics.recordTokenUsage(this._otelService, result.usage.prompt_tokens, 'input', metricAttrs);
|
|
289
|
+
}
|
|
290
|
+
if (result.usage.completion_tokens) {
|
|
291
|
+
index_1.GenAiMetrics.recordTokenUsage(this._otelService, result.usage.completion_tokens, 'output', metricAttrs);
|
|
292
|
+
}
|
|
293
|
+
// Set token usage and response details on the chat span before ending it
|
|
294
|
+
otelInferenceSpan?.setAttributes({
|
|
295
|
+
[index_1.GenAiAttr.USAGE_INPUT_TOKENS]: result.usage.prompt_tokens ?? 0,
|
|
296
|
+
[index_1.GenAiAttr.USAGE_OUTPUT_TOKENS]: result.usage.completion_tokens ?? 0,
|
|
297
|
+
[index_1.GenAiAttr.RESPONSE_MODEL]: result.resolvedModel ?? chatEndpoint.model,
|
|
298
|
+
[index_1.GenAiAttr.RESPONSE_ID]: result.requestId,
|
|
299
|
+
[index_1.GenAiAttr.RESPONSE_FINISH_REASONS]: ['stop'],
|
|
300
|
+
...(result.usage.prompt_tokens_details?.cached_tokens
|
|
301
|
+
? { [index_1.GenAiAttr.USAGE_CACHE_READ_INPUT_TOKENS]: result.usage.prompt_tokens_details.cached_tokens }
|
|
302
|
+
: {}),
|
|
303
|
+
[index_1.CopilotChatAttr.TIME_TO_FIRST_TOKEN]: timeToFirstToken,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
// Capture response content when enabled
|
|
307
|
+
if (this._otelService.config.captureContent && otelInferenceSpan && result.type === commonTypes_1.ChatFetchResponseType.Success) {
|
|
308
|
+
const responseText = streamRecorder.deltas.map(d => d.text).join('');
|
|
309
|
+
const toolCalls = streamRecorder.deltas
|
|
310
|
+
.filter(d => d.copilotToolCalls?.length)
|
|
311
|
+
.flatMap(d => d.copilotToolCalls.map(tc => ({
|
|
312
|
+
type: 'tool_call', id: tc.id, name: tc.name, arguments: tc.arguments
|
|
313
|
+
})));
|
|
314
|
+
const parts = [];
|
|
315
|
+
if (responseText) {
|
|
316
|
+
parts.push({ type: 'text', content: responseText });
|
|
317
|
+
}
|
|
318
|
+
parts.push(...toolCalls);
|
|
319
|
+
if (parts.length > 0) {
|
|
320
|
+
otelInferenceSpan.setAttribute(index_1.GenAiAttr.OUTPUT_MESSAGES, (0, index_1.truncateForOTel)(JSON.stringify([{ role: 'assistant', parts }])));
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// Emit OTel inference details event BEFORE ending the span
|
|
324
|
+
// so the log record inherits the active trace context
|
|
325
|
+
(0, index_1.emitInferenceDetailsEvent)(this._otelService, {
|
|
326
|
+
model: chatEndpoint.model,
|
|
327
|
+
temperature: requestOptions?.temperature,
|
|
328
|
+
maxTokens: requestOptions?.max_tokens,
|
|
329
|
+
}, result.type === commonTypes_1.ChatFetchResponseType.Success ? {
|
|
330
|
+
id: result.requestId,
|
|
331
|
+
model: result.resolvedModel,
|
|
332
|
+
finishReasons: ['stop'],
|
|
333
|
+
inputTokens: result.usage?.prompt_tokens,
|
|
334
|
+
outputTokens: result.usage?.completion_tokens,
|
|
335
|
+
} : undefined);
|
|
336
|
+
otelInferenceSpan?.end();
|
|
337
|
+
otelInferenceSpan = undefined;
|
|
338
|
+
// Record OTel time-to-first-token metric
|
|
339
|
+
if (timeToFirstToken > 0) {
|
|
340
|
+
index_1.GenAiMetrics.recordTimeToFirstToken(this._otelService, chatEndpoint.model, timeToFirstToken / 1000);
|
|
341
|
+
}
|
|
342
|
+
if (useWebSocket && result.type === commonTypes_1.ChatFetchResponseType.Success) {
|
|
343
|
+
this._consecutiveWebSocketRetryFallbacks = 0;
|
|
344
|
+
}
|
|
272
345
|
return result;
|
|
273
346
|
}
|
|
274
347
|
case fetch_2.FetchResponseKind.Canceled:
|
|
@@ -277,6 +350,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
277
350
|
requestId: ourRequestId,
|
|
278
351
|
model: chatEndpoint.model,
|
|
279
352
|
apiType: chatEndpoint.apiType,
|
|
353
|
+
transport,
|
|
280
354
|
associatedRequestId: telemetryProperties.associatedRequestId,
|
|
281
355
|
retryAfterError: telemetryProperties.retryAfterError,
|
|
282
356
|
retryAfterErrorGitHubRequestId: telemetryProperties.retryAfterErrorGitHubRequestId,
|
|
@@ -308,7 +382,9 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
308
382
|
const statusCodesToRetry = retryServerErrorStatusCodes
|
|
309
383
|
.split(',')
|
|
310
384
|
.map(s => parseInt(s.trim(), 10));
|
|
311
|
-
|
|
385
|
+
const retryAfterServerError = enableRetryOnError && actualStatusCode !== undefined && statusCodesToRetry.includes(actualStatusCode);
|
|
386
|
+
const retryWithoutWebSocket = enableRetryOnError && useWebSocket;
|
|
387
|
+
if (retryAfterServerError || retryWithoutWebSocket) {
|
|
312
388
|
const { retryResult } = await this._retryAfterError({
|
|
313
389
|
opts,
|
|
314
390
|
processed,
|
|
@@ -317,6 +393,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
317
393
|
tokenCount,
|
|
318
394
|
maxResponseTokens,
|
|
319
395
|
timeToError: timeToFirstToken,
|
|
396
|
+
transport,
|
|
320
397
|
actualFetcher,
|
|
321
398
|
bytesReceived: actualBytesReceived,
|
|
322
399
|
baseTelemetry,
|
|
@@ -342,6 +419,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
342
419
|
maxResponseTokens,
|
|
343
420
|
timeToFirstToken,
|
|
344
421
|
isVisionRequest: this.filterImageMessages(messages),
|
|
422
|
+
transport,
|
|
345
423
|
fetcher: actualFetcher,
|
|
346
424
|
bytesReceived: actualBytesReceived,
|
|
347
425
|
issuedTime: baseTelemetry.issuedTime,
|
|
@@ -355,6 +433,8 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
355
433
|
}
|
|
356
434
|
}
|
|
357
435
|
catch (err) {
|
|
436
|
+
// End OTel inference span on error if not already ended
|
|
437
|
+
otelInferenceSpan?.end();
|
|
358
438
|
const timeToError = Date.now() - baseTelemetry.issuedTime;
|
|
359
439
|
if (err.fetcherId) {
|
|
360
440
|
actualFetcher = err.fetcherId;
|
|
@@ -366,34 +446,34 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
366
446
|
resumeEventSeen = true;
|
|
367
447
|
}
|
|
368
448
|
const processed = this.processError(err, ourRequestId, err.gitHubRequestId, usernameToScrub);
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
telemetryProperties = { ...telemetryProperties, connectivityTestError, connectivityTestErrorGitHubRequestId };
|
|
449
|
+
const retryNetworkError = enableRetryOnError && processed.type === commonTypes_1.ChatFetchResponseType.NetworkError && this._configurationService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.RetryNetworkErrors, this._experimentationService);
|
|
450
|
+
const retryWithoutWebSocket = enableRetryOnError && useWebSocket && (processed.type === commonTypes_1.ChatFetchResponseType.NetworkError || processed.type === commonTypes_1.ChatFetchResponseType.Failed);
|
|
451
|
+
if (retryNetworkError || retryWithoutWebSocket) {
|
|
452
|
+
const { retryResult, connectivityTestError, connectivityTestErrorGitHubRequestId } = await this._retryAfterError({
|
|
453
|
+
opts,
|
|
454
|
+
processed,
|
|
455
|
+
telemetryProperties,
|
|
456
|
+
requestBody,
|
|
457
|
+
tokenCount,
|
|
458
|
+
maxResponseTokens,
|
|
459
|
+
timeToError,
|
|
460
|
+
transport,
|
|
461
|
+
actualFetcher,
|
|
462
|
+
bytesReceived: err.bytesReceived,
|
|
463
|
+
baseTelemetry,
|
|
464
|
+
streamRecorder,
|
|
465
|
+
retryReason: 'network_error',
|
|
466
|
+
debugNamePrefix: 'retry-error-',
|
|
467
|
+
pendingLoggedChatRequest,
|
|
468
|
+
token,
|
|
469
|
+
usernameToScrub,
|
|
470
|
+
suspendEventSeen,
|
|
471
|
+
resumeEventSeen,
|
|
472
|
+
});
|
|
473
|
+
if (retryResult) {
|
|
474
|
+
return retryResult;
|
|
396
475
|
}
|
|
476
|
+
telemetryProperties = { ...telemetryProperties, connectivityTestError, connectivityTestErrorGitHubRequestId };
|
|
397
477
|
}
|
|
398
478
|
if (processed.type === commonTypes_1.ChatFetchResponseType.Canceled) {
|
|
399
479
|
chatMLFetcherTelemetry_1.ChatMLFetcherTelemetrySender.sendCancellationTelemetry(this._telemetryService, {
|
|
@@ -401,6 +481,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
401
481
|
requestId: ourRequestId,
|
|
402
482
|
model: chatEndpoint.model,
|
|
403
483
|
apiType: chatEndpoint.apiType,
|
|
484
|
+
transport,
|
|
404
485
|
associatedRequestId: telemetryProperties.associatedRequestId,
|
|
405
486
|
retryAfterError: telemetryProperties.retryAfterError,
|
|
406
487
|
retryAfterErrorGitHubRequestId: telemetryProperties.retryAfterErrorGitHubRequestId,
|
|
@@ -433,6 +514,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
433
514
|
maxResponseTokens,
|
|
434
515
|
timeToFirstToken: timeToError,
|
|
435
516
|
isVisionRequest: this.filterImageMessages(messages),
|
|
517
|
+
transport,
|
|
436
518
|
fetcher: actualFetcher,
|
|
437
519
|
bytesReceived: err.bytesReceived,
|
|
438
520
|
issuedTime: baseTelemetry.issuedTime,
|
|
@@ -500,7 +582,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
500
582
|
return authHeaders;
|
|
501
583
|
}
|
|
502
584
|
async _retryAfterError(params) {
|
|
503
|
-
const { opts, processed, telemetryProperties, requestBody, tokenCount, maxResponseTokens, timeToError, actualFetcher, bytesReceived, baseTelemetry, streamRecorder, retryReason, debugNamePrefix, pendingLoggedChatRequest, token, usernameToScrub, suspendEventSeen, resumeEventSeen, } = params;
|
|
585
|
+
const { opts, processed, telemetryProperties, requestBody, tokenCount, maxResponseTokens, timeToError, transport, actualFetcher, bytesReceived, baseTelemetry, streamRecorder, retryReason, debugNamePrefix, pendingLoggedChatRequest, token, usernameToScrub, suspendEventSeen, resumeEventSeen, } = params;
|
|
504
586
|
// net::ERR_NETWORK_CHANGED: https://github.com/microsoft/vscode/issues/260297
|
|
505
587
|
const isNetworkChangedError = ['darwin', 'linux'].includes(process.platform) && processed.reason.indexOf('net::ERR_NETWORK_CHANGED') !== -1;
|
|
506
588
|
// When Electron's network process crashes, all requests through it fail permanently.
|
|
@@ -527,6 +609,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
527
609
|
maxResponseTokens,
|
|
528
610
|
timeToFirstToken: timeToError,
|
|
529
611
|
isVisionRequest: this.filterImageMessages(opts.messages),
|
|
612
|
+
transport,
|
|
530
613
|
fetcher: actualFetcher,
|
|
531
614
|
bytesReceived,
|
|
532
615
|
issuedTime: baseTelemetry.issuedTime,
|
|
@@ -537,6 +620,8 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
537
620
|
streamRecorder.callback('', 0, { text: '', retryReason });
|
|
538
621
|
const retryResult = await this.fetchMany({
|
|
539
622
|
...opts,
|
|
623
|
+
useWebSocket: false,
|
|
624
|
+
ignoreStatefulMarker: opts.useWebSocket || opts.ignoreStatefulMarker,
|
|
540
625
|
debugName: debugNamePrefix + opts.debugName,
|
|
541
626
|
userInitiatedRequest: false, // do not mark the retry as user initiated
|
|
542
627
|
telemetryProperties: {
|
|
@@ -550,9 +635,17 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
550
635
|
useFetcher,
|
|
551
636
|
}, token);
|
|
552
637
|
pendingLoggedChatRequest?.resolve(retryResult, streamRecorder.deltas);
|
|
638
|
+
if (opts.useWebSocket && retryResult.type === commonTypes_1.ChatFetchResponseType.Success) {
|
|
639
|
+
this._consecutiveWebSocketRetryFallbacks++;
|
|
640
|
+
this._logService.info(`[ChatWebSocketManager] WebSocket request failed with successful HTTP fallback (${this._consecutiveWebSocketRetryFallbacks} consecutive).`);
|
|
641
|
+
if (opts.conversationId && opts.turnId) {
|
|
642
|
+
// Closing here because the retry is transparent.
|
|
643
|
+
this._webSocketManager.closeConnection(opts.conversationId, opts.turnId);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
553
646
|
return { retryResult, connectivityTestError, connectivityTestErrorGitHubRequestId };
|
|
554
647
|
}
|
|
555
|
-
async _fetchAndStreamChat(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, copilotToken, location, ourRequestId, nChoices, cancellationToken, userInitiatedRequest, telemetryProperties, useFetcher, canRetryOnce) {
|
|
648
|
+
async _fetchAndStreamChat(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, copilotToken, location, ourRequestId, nChoices, cancellationToken, userInitiatedRequest, useWebSocket, turnId, conversationId, telemetryProperties, useFetcher, canRetryOnce, requestKindOptions) {
|
|
556
649
|
const isPowerSaveBlockerEnabled = this._configurationService.getExperimentBasedConfig(configurationService_1.ConfigKey.TeamInternal.ChatRequestPowerSaveBlocker, this._experimentationService);
|
|
557
650
|
const blockerHandle = isPowerSaveBlockerEnabled && location !== commonTypes_1.ChatLocation.Other ? this._powerService.acquirePowerSaveBlocker() : undefined;
|
|
558
651
|
let suspendEventSeen = false;
|
|
@@ -566,7 +659,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
566
659
|
this._logService.info(`System resumed during streaming request ${ourRequestId} (${commonTypes_1.ChatLocation.toString(location)})`);
|
|
567
660
|
});
|
|
568
661
|
try {
|
|
569
|
-
const fetchResult = await this._doFetchAndStreamChat(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, copilotToken, location, ourRequestId, nChoices, cancellationToken, userInitiatedRequest, telemetryProperties, useFetcher, canRetryOnce);
|
|
662
|
+
const fetchResult = await this._doFetchAndStreamChat(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, copilotToken, location, ourRequestId, nChoices, cancellationToken, userInitiatedRequest, useWebSocket, turnId, conversationId, telemetryProperties, useFetcher, canRetryOnce, requestKindOptions);
|
|
570
663
|
return { ...fetchResult, suspendEventSeen: suspendEventSeen || undefined, resumeEventSeen: resumeEventSeen || undefined };
|
|
571
664
|
}
|
|
572
665
|
catch (err) {
|
|
@@ -584,31 +677,190 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
584
677
|
blockerHandle?.dispose();
|
|
585
678
|
}
|
|
586
679
|
}
|
|
587
|
-
async _doFetchAndStreamChat(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, copilotToken, location, ourRequestId, nChoices, cancellationToken, userInitiatedRequest, telemetryProperties, useFetcher, canRetryOnce) {
|
|
680
|
+
async _doFetchAndStreamChat(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, copilotToken, location, ourRequestId, nChoices, cancellationToken, userInitiatedRequest, useWebSocket, turnId, conversationId, telemetryProperties, useFetcher, canRetryOnce, requestKindOptions) {
|
|
588
681
|
if (cancellationToken.isCancellationRequested) {
|
|
589
682
|
return { result: { type: fetch_2.FetchResponseKind.Canceled, reason: 'before fetch request' } };
|
|
590
683
|
}
|
|
591
|
-
this
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
684
|
+
// OTel inference span for this LLM call
|
|
685
|
+
const serverAddress = typeof chatEndpointInfo.urlOrRequestMetadata === 'string'
|
|
686
|
+
? (() => { try {
|
|
687
|
+
return new URL(chatEndpointInfo.urlOrRequestMetadata).hostname;
|
|
688
|
+
}
|
|
689
|
+
catch {
|
|
690
|
+
return undefined;
|
|
691
|
+
} })()
|
|
692
|
+
: undefined;
|
|
693
|
+
const otelSpan = this._otelService.startSpan(`chat ${chatEndpointInfo.model}`, {
|
|
694
|
+
kind: 2 /* SpanKind.CLIENT */,
|
|
695
|
+
attributes: {
|
|
696
|
+
[index_1.GenAiAttr.OPERATION_NAME]: index_1.GenAiOperationName.CHAT,
|
|
697
|
+
[index_1.GenAiAttr.PROVIDER_NAME]: index_1.GenAiProviderName.GITHUB,
|
|
698
|
+
[index_1.GenAiAttr.REQUEST_MODEL]: chatEndpointInfo.model,
|
|
699
|
+
[index_1.GenAiAttr.CONVERSATION_ID]: telemetryProperties?.requestId ?? ourRequestId,
|
|
700
|
+
[index_1.GenAiAttr.REQUEST_MAX_TOKENS]: request.max_tokens ?? request.max_output_tokens ?? request.max_completion_tokens ?? 2048,
|
|
701
|
+
...(request.temperature !== undefined ? { [index_1.GenAiAttr.REQUEST_TEMPERATURE]: request.temperature } : {}),
|
|
702
|
+
...(request.top_p !== undefined ? { [index_1.GenAiAttr.REQUEST_TOP_P]: request.top_p } : {}),
|
|
703
|
+
[index_1.CopilotChatAttr.MAX_PROMPT_TOKENS]: chatEndpointInfo.modelMaxPromptTokens,
|
|
704
|
+
...(serverAddress ? { [index_1.StdAttr.SERVER_ADDRESS]: serverAddress } : {}),
|
|
705
|
+
},
|
|
706
|
+
});
|
|
707
|
+
const otelStartTime = Date.now();
|
|
708
|
+
try {
|
|
709
|
+
this._logService.debug(`modelMaxPromptTokens ${chatEndpointInfo.modelMaxPromptTokens}`);
|
|
710
|
+
this._logService.debug(`modelMaxResponseTokens ${request.max_tokens ?? 2048}`);
|
|
711
|
+
this._logService.debug(`chat model ${chatEndpointInfo.model}`);
|
|
712
|
+
secretKey ??= copilotToken.token;
|
|
713
|
+
if (!secretKey) {
|
|
714
|
+
// If no key is set we error
|
|
715
|
+
const urlOrRequestMetadata = (0, networking_1.stringifyUrlOrRequestMetadata)(chatEndpointInfo.urlOrRequestMetadata);
|
|
716
|
+
this._logService.error(`Failed to send request to ${urlOrRequestMetadata} due to missing key`);
|
|
717
|
+
(0, stream_1.sendCommunicationErrorTelemetry)(this._telemetryService, `Failed to send request to ${urlOrRequestMetadata} due to missing key`);
|
|
718
|
+
return {
|
|
719
|
+
result: {
|
|
720
|
+
type: fetch_2.FetchResponseKind.Failed,
|
|
721
|
+
modelRequestId: undefined,
|
|
722
|
+
failKind: fetch_2.ChatFailKind.TokenExpiredOrInvalid,
|
|
723
|
+
reason: 'key is missing'
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
// WebSocket path: use persistent WebSocket connection for Responses API endpoints
|
|
728
|
+
if (useWebSocket && turnId && conversationId) {
|
|
729
|
+
const wsResult = await this._doFetchViaWebSocket(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, location, ourRequestId, turnId, conversationId, cancellationToken, userInitiatedRequest, telemetryProperties, requestKindOptions);
|
|
730
|
+
return { ...wsResult, otelSpan };
|
|
731
|
+
}
|
|
732
|
+
const httpResult = await this._doFetchViaHttp(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, location, ourRequestId, nChoices, cancellationToken, userInitiatedRequest, telemetryProperties, useFetcher, canRetryOnce, requestKindOptions);
|
|
733
|
+
return { ...httpResult, otelSpan };
|
|
608
734
|
}
|
|
735
|
+
catch (err) {
|
|
736
|
+
otelSpan.setStatus(2 /* SpanStatusCode.ERROR */, err instanceof Error ? err.message : String(err));
|
|
737
|
+
otelSpan.setAttribute(index_1.StdAttr.ERROR_TYPE, err instanceof Error ? err.constructor.name : 'Error');
|
|
738
|
+
otelSpan.recordException(err);
|
|
739
|
+
throw err;
|
|
740
|
+
}
|
|
741
|
+
finally {
|
|
742
|
+
const durationSec = (Date.now() - otelStartTime) / 1000;
|
|
743
|
+
index_1.GenAiMetrics.recordOperationDuration(this._otelService, durationSec, {
|
|
744
|
+
operationName: index_1.GenAiOperationName.CHAT,
|
|
745
|
+
providerName: index_1.GenAiProviderName.GITHUB,
|
|
746
|
+
requestModel: chatEndpointInfo.model,
|
|
747
|
+
});
|
|
748
|
+
// Span is NOT ended here — caller (fetchMany) will set token attributes and end it
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Sends a chat request via a persistent WebSocket connection instead of HTTP POST.
|
|
753
|
+
* Events are the same Responses API streaming events, processed by OpenAIResponsesProcessor.
|
|
754
|
+
*/
|
|
755
|
+
async _doFetchViaWebSocket(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, location, ourRequestId, turnId, conversationId, cancellationToken, userInitiatedRequest, telemetryProperties, requestKindOptions) {
|
|
756
|
+
const intent = locationToIntent(location);
|
|
757
|
+
const agentInteractionType = requestKindOptions?.kind === 'subagent' ?
|
|
758
|
+
'conversation-subagent' :
|
|
759
|
+
requestKindOptions?.kind === 'background' ?
|
|
760
|
+
'conversation-background' :
|
|
761
|
+
intent === 'conversation-agent' ? intent : undefined;
|
|
762
|
+
const additionalHeaders = {
|
|
763
|
+
'Authorization': `Bearer ${secretKey}`,
|
|
764
|
+
'X-Request-Id': ourRequestId,
|
|
765
|
+
'OpenAI-Intent': intent,
|
|
766
|
+
'X-GitHub-Api-Version': '2025-05-01',
|
|
767
|
+
'X-Interaction-Id': this._interactionService.interactionId,
|
|
768
|
+
'X-Initiator': userInitiatedRequest ? 'user' : 'agent',
|
|
769
|
+
...(chatEndpointInfo.getExtraHeaders ? chatEndpointInfo.getExtraHeaders(location) : {}),
|
|
770
|
+
};
|
|
771
|
+
if (agentInteractionType) {
|
|
772
|
+
additionalHeaders['X-Interaction-Type'] = agentInteractionType;
|
|
773
|
+
additionalHeaders['X-Agent-Task-Id'] = ourRequestId;
|
|
774
|
+
}
|
|
775
|
+
if (request.messages?.some((m) => Array.isArray(m.content) ? m.content.some(c => 'image_url' in c) : false) && chatEndpointInfo.supportsVision) {
|
|
776
|
+
additionalHeaders['Copilot-Vision-Request'] = 'true';
|
|
777
|
+
}
|
|
778
|
+
const connection = await this._webSocketManager.getOrCreateConnection(conversationId, turnId, additionalHeaders);
|
|
779
|
+
// Generate unique ID to link input and output messages
|
|
780
|
+
const modelCallId = (0, uuid_1.generateUuid)();
|
|
781
|
+
const telemetryData = telemetryData_1.TelemetryData.createAndMarkAsIssued({
|
|
782
|
+
endpoint: 'completions',
|
|
783
|
+
engineName: 'chat',
|
|
784
|
+
uiKind: commonTypes_1.ChatLocation.toString(location),
|
|
785
|
+
transport: 'websocket',
|
|
786
|
+
...{ ...telemetryProperties, modelCallId },
|
|
787
|
+
}, {
|
|
788
|
+
maxTokenWindow: chatEndpointInfo.modelMaxPromptTokens
|
|
789
|
+
});
|
|
790
|
+
const modelRequestId = (0, fetch_1.getRequestId)(connection.responseHeaders);
|
|
791
|
+
telemetryData.extendWithRequestId(modelRequestId);
|
|
792
|
+
for (const [key, value] of Object.entries(request)) {
|
|
793
|
+
if (key === 'messages' || key === 'input') {
|
|
794
|
+
continue;
|
|
795
|
+
} // Skip messages (PII)
|
|
796
|
+
telemetryData.properties[`request.option.${key}`] = JSON.stringify(value) ?? 'undefined';
|
|
797
|
+
}
|
|
798
|
+
telemetryData.properties['headerRequestId'] = ourRequestId;
|
|
799
|
+
this._telemetryService.sendGHTelemetryEvent('request.sent', telemetryData.properties, telemetryData.measurements);
|
|
800
|
+
const requestStart = Date.now();
|
|
801
|
+
const handle = connection.sendRequest(request, cancellationToken);
|
|
802
|
+
const extendedBaseTelemetryData = baseTelemetryData.extendedBy({ modelCallId });
|
|
803
|
+
const processor = this._instantiationService.createInstance(responsesApi_1.OpenAIResponsesProcessor, extendedBaseTelemetryData, modelRequestId.headerRequestId, modelRequestId.gitHubRequestId);
|
|
804
|
+
const chatCompletions = new async_1.AsyncIterableObject(async (emitter) => {
|
|
805
|
+
try {
|
|
806
|
+
await new Promise((resolve, reject) => {
|
|
807
|
+
handle.onEvent(event => {
|
|
808
|
+
const completion = processor.push(event, finishedCb);
|
|
809
|
+
if (completion) {
|
|
810
|
+
(0, responsesApi_1.sendCompletionOutputTelemetry)(this._telemetryService, this._logService, completion, extendedBaseTelemetryData);
|
|
811
|
+
emitter.emitOne(completion);
|
|
812
|
+
}
|
|
813
|
+
});
|
|
814
|
+
handle.onError(error => {
|
|
815
|
+
error.gitHubRequestId = modelRequestId.gitHubRequestId;
|
|
816
|
+
if ((0, errors_2.isCancellationError)(error)) {
|
|
817
|
+
reject(error);
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
const warningTelemetry = telemetryData.extendedBy({ error: error.message });
|
|
821
|
+
this._telemetryService.sendGHTelemetryEvent('request.shownWarning', warningTelemetry.properties, warningTelemetry.measurements);
|
|
822
|
+
const totalTimeMs = Date.now() - requestStart;
|
|
823
|
+
telemetryData.measurements.totalTimeMs = totalTimeMs;
|
|
824
|
+
telemetryData.properties.error = error.message;
|
|
825
|
+
this._logService.debug(`request.error: [websocket], took ${totalTimeMs} ms`);
|
|
826
|
+
this._telemetryService.sendGHTelemetryEvent('request.error', telemetryData.properties, telemetryData.measurements);
|
|
827
|
+
reject(error);
|
|
828
|
+
});
|
|
829
|
+
handle.onComplete(() => {
|
|
830
|
+
const totalTimeMs = Date.now() - requestStart;
|
|
831
|
+
telemetryData.measurements.totalTimeMs = totalTimeMs;
|
|
832
|
+
this._logService.debug(`request.response: [websocket], took ${totalTimeMs} ms`);
|
|
833
|
+
this._telemetryService.sendGHTelemetryEvent('request.response', telemetryData.properties, telemetryData.measurements);
|
|
834
|
+
resolve();
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
finally {
|
|
839
|
+
let messagesToLog = request.messages;
|
|
840
|
+
if ((!messagesToLog || messagesToLog.length === 0) && request.input) {
|
|
841
|
+
try {
|
|
842
|
+
const rawMessages = (0, responsesApi_1.responseApiInputToRawMessagesForLogging)(request);
|
|
843
|
+
messagesToLog = (0, openai_1.rawMessageToCAPI)(rawMessages);
|
|
844
|
+
}
|
|
845
|
+
catch (e) {
|
|
846
|
+
this._logService.error(`Failed to convert Response API input to messages for telemetry:`, e);
|
|
847
|
+
messagesToLog = [];
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
(0, chatStream_1.sendEngineMessagesTelemetry)(this._telemetryService, messagesToLog ?? [], telemetryData, false, this._logService);
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
return {
|
|
854
|
+
result: {
|
|
855
|
+
type: fetch_2.FetchResponseKind.Success,
|
|
856
|
+
chatCompletions,
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
async _doFetchViaHttp(chatEndpointInfo, request, baseTelemetryData, finishedCb, secretKey, location, ourRequestId, nChoices, cancellationToken, userInitiatedRequest, telemetryProperties, useFetcher, canRetryOnce, requestKindOptions) {
|
|
609
861
|
// Generate unique ID to link input and output messages
|
|
610
862
|
const modelCallId = (0, uuid_1.generateUuid)();
|
|
611
|
-
const response = await this._fetchWithInstrumentation(chatEndpointInfo, ourRequestId, request, secretKey, location, cancellationToken, userInitiatedRequest, { ...telemetryProperties, modelCallId }, useFetcher, canRetryOnce);
|
|
863
|
+
const response = await this._fetchWithInstrumentation(chatEndpointInfo, ourRequestId, request, secretKey, location, cancellationToken, userInitiatedRequest, { ...telemetryProperties, modelCallId }, useFetcher, canRetryOnce, requestKindOptions);
|
|
612
864
|
if (cancellationToken.isCancellationRequested) {
|
|
613
865
|
try {
|
|
614
866
|
// Destroy the stream so that the server is hopefully notified we don't want any more data
|
|
@@ -679,7 +931,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
679
931
|
bytesReceived: response.bytesReceived
|
|
680
932
|
};
|
|
681
933
|
}
|
|
682
|
-
async _fetchWithInstrumentation(chatEndpoint, ourRequestId, request, secretKey, location, cancellationToken, userInitiatedRequest, telemetryProperties, useFetcher, canRetryOnce) {
|
|
934
|
+
async _fetchWithInstrumentation(chatEndpoint, ourRequestId, request, secretKey, location, cancellationToken, userInitiatedRequest, telemetryProperties, useFetcher, canRetryOnce, requestKindOptions) {
|
|
683
935
|
// If request contains an image, we include this header.
|
|
684
936
|
const additionalHeaders = {
|
|
685
937
|
'X-Interaction-Id': this._interactionService.interactionId,
|
|
@@ -692,6 +944,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
692
944
|
endpoint: 'completions',
|
|
693
945
|
engineName: 'chat',
|
|
694
946
|
uiKind: commonTypes_1.ChatLocation.toString(location),
|
|
947
|
+
transport: 'http',
|
|
695
948
|
...telemetryProperties // This includes the modelCallId from fetchAndStreamChat
|
|
696
949
|
}, {
|
|
697
950
|
maxTokenWindow: chatEndpoint.modelMaxPromptTokens
|
|
@@ -710,7 +963,19 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
710
963
|
const requestStart = Date.now();
|
|
711
964
|
const intent = locationToIntent(location);
|
|
712
965
|
// Wrap the Promise with success/error callbacks so we can log/measure it
|
|
713
|
-
return
|
|
966
|
+
return this._instantiationService.invokeFunction(networking_1.postRequest, {
|
|
967
|
+
endpointOrUrl: chatEndpoint,
|
|
968
|
+
secretKey,
|
|
969
|
+
intent,
|
|
970
|
+
requestId: ourRequestId,
|
|
971
|
+
body: request,
|
|
972
|
+
additionalHeaders,
|
|
973
|
+
cancelToken: cancellationToken,
|
|
974
|
+
useFetcher,
|
|
975
|
+
canRetryOnce,
|
|
976
|
+
location,
|
|
977
|
+
requestKindOptions,
|
|
978
|
+
}).then(response => {
|
|
714
979
|
const apim = response.headers.get('apim-request-id');
|
|
715
980
|
if (apim) {
|
|
716
981
|
this._logService.debug(`APIM request id: ${apim}`);
|
|
@@ -966,7 +1231,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
966
1231
|
reason: `Request Failed: ${response.status} ${text}`
|
|
967
1232
|
};
|
|
968
1233
|
}
|
|
969
|
-
async processSuccessfulResponse(response, messages, requestBody, requestId, maxResponseTokens, promptTokenCount, timeToFirstToken, streamRecorder, baseTelemetry, chatEndpointInfo, userInitiatedRequest, fetcher, bytesReceived, suspendEventSeen, resumeEventSeen) {
|
|
1234
|
+
async processSuccessfulResponse(response, messages, requestBody, requestId, maxResponseTokens, promptTokenCount, timeToFirstToken, streamRecorder, baseTelemetry, chatEndpointInfo, userInitiatedRequest, transport, fetcher, bytesReceived, suspendEventSeen, resumeEventSeen) {
|
|
970
1235
|
const completions = [];
|
|
971
1236
|
for await (const chatCompletion of response.chatCompletions) {
|
|
972
1237
|
chatMLFetcherTelemetry_1.ChatMLFetcherTelemetrySender.sendSuccessTelemetry(this._telemetryService, {
|
|
@@ -980,6 +1245,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
980
1245
|
timeToFirstToken,
|
|
981
1246
|
timeToFirstTokenEmitted: (baseTelemetry && streamRecorder.firstTokenEmittedTime) ? streamRecorder.firstTokenEmittedTime - baseTelemetry.issuedTime : -1,
|
|
982
1247
|
hasImageMessages: this.filterImageMessages(messages),
|
|
1248
|
+
transport,
|
|
983
1249
|
fetcher,
|
|
984
1250
|
bytesReceived,
|
|
985
1251
|
suspendEventSeen,
|
|
@@ -1184,7 +1450,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
1184
1450
|
serverRequestId: gitHubRequestId,
|
|
1185
1451
|
};
|
|
1186
1452
|
}
|
|
1187
|
-
if ((0,
|
|
1453
|
+
if ((0, errors_2.isCancellationError)(err)) {
|
|
1188
1454
|
return {
|
|
1189
1455
|
type: commonTypes_1.ChatFetchResponseType.Canceled,
|
|
1190
1456
|
reason: 'Got a cancellation error',
|
|
@@ -1201,7 +1467,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
1201
1467
|
serverRequestId: gitHubRequestId,
|
|
1202
1468
|
};
|
|
1203
1469
|
}
|
|
1204
|
-
this._logService.error(
|
|
1470
|
+
this._logService.error(errors_1.ErrorUtils.fromUnknown(err), `Error on conversation request`);
|
|
1205
1471
|
this._telemetryService.sendGHTelemetryException(err, 'Error on conversation request');
|
|
1206
1472
|
const userMessage = fetcher.getUserMessageForFetcherError(err);
|
|
1207
1473
|
const errorDetail = (0, logService_1.collectSingleLineErrorMessage)(err, true);
|
|
@@ -1245,7 +1511,7 @@ let ChatMLFetcherImpl = class ChatMLFetcherImpl extends AbstractChatMLFetcher {
|
|
|
1245
1511
|
}
|
|
1246
1512
|
};
|
|
1247
1513
|
exports.ChatMLFetcherImpl = ChatMLFetcherImpl;
|
|
1248
|
-
exports.ChatMLFetcherImpl = ChatMLFetcherImpl = __decorate([
|
|
1514
|
+
exports.ChatMLFetcherImpl = ChatMLFetcherImpl = ChatMLFetcherImpl_1 = __decorate([
|
|
1249
1515
|
__param(0, fetcherService_1.IFetcherService),
|
|
1250
1516
|
__param(1, telemetry_1.ITelemetryService),
|
|
1251
1517
|
__param(2, requestLogger_1.IRequestLogger),
|
|
@@ -1257,7 +1523,10 @@ exports.ChatMLFetcherImpl = ChatMLFetcherImpl = __decorate([
|
|
|
1257
1523
|
__param(8, conversationOptions_1.IConversationOptions),
|
|
1258
1524
|
__param(9, configurationService_1.IConfigurationService),
|
|
1259
1525
|
__param(10, nullExperimentationService_1.IExperimentationService),
|
|
1260
|
-
__param(11, powerService_1.IPowerService)
|
|
1526
|
+
__param(11, powerService_1.IPowerService),
|
|
1527
|
+
__param(12, instantiation_1.IInstantiationService),
|
|
1528
|
+
__param(13, chatWebSocketManager_1.IChatWebSocketManager),
|
|
1529
|
+
__param(14, otelService_1.IOTelService)
|
|
1261
1530
|
], ChatMLFetcherImpl);
|
|
1262
1531
|
/**
|
|
1263
1532
|
* Validates a chat request payload to ensure it is valid
|