@vscode/chat-lib 0.0.1 → 0.0.3
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/inlineEdits/node/nextEditProvider.d.ts +2 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js +70 -28
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts +4 -3
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js +85 -109
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.js.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js +14 -6
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js +6 -5
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts +1 -0
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js +44 -42
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js.map +1 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.d.ts.map +1 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.js +8 -4
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +8 -0
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +11 -3
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/capiClient.d.ts +1 -1
- package/dist/src/_internal/platform/endpoint/common/capiClient.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/capiClient.js +2 -2
- package/dist/src/_internal/platform/endpoint/common/capiClient.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts +4 -0
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js +7 -0
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/capiClientImpl.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/capiClientImpl.js +1 -1
- package/dist/src/_internal/platform/endpoint/node/capiClientImpl.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js +10 -4
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.d.ts +5 -0
- package/dist/src/_internal/platform/env/common/envService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/envService.js +2 -1
- package/dist/src/_internal/platform/env/common/envService.js.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts +3 -0
- package/dist/src/_internal/platform/env/common/nullEnvService.d.ts.map +1 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.js +8 -1
- package/dist/src/_internal/platform/env/common/nullEnvService.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.d.ts +3 -3
- package/dist/src/_internal/platform/github/common/githubService.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts +0 -3
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js +0 -5
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts +2 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts +7 -0
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js +1 -0
- package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.d.ts +1 -0
- package/dist/src/_internal/platform/telemetry/common/telemetry.d.ts.map +1 -1
- package/dist/src/_internal/platform/telemetry/common/telemetry.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +8 -0
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js +19 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/enums.d.ts +6 -0
- package/dist/src/_internal/util/common/test/shims/enums.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/enums.js +8 -1
- package/dist/src/_internal/util/common/test/shims/enums.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +9 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
- package/dist/src/_internal/vscodeTypes.d.ts +5 -0
- package/dist/src/_internal/vscodeTypes.d.ts.map +1 -1
- package/dist/src/_internal/vscodeTypes.js +6 -1
- package/dist/src/_internal/vscodeTypes.js.map +1 -1
- package/dist/src/main.d.ts +15 -1
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +73 -13
- package/dist/src/main.js.map +1 -1
- package/dist/src/package.json +70 -31
- package/package.json +7 -9
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.d.ts +0 -42
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.d.ts.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.js +0 -125
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.js.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.d.ts +0 -60
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.d.ts.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.js +0 -416
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.js.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.d.ts +0 -30
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.d.ts.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.js +0 -64
- package/dist/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.js.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/visualization.d.ts +0 -26
- package/dist/src/_internal/extension/prompts/node/inline/visualization.d.ts.map +0 -1
- package/dist/src/_internal/extension/prompts/node/inline/visualization.js +0 -41
- package/dist/src/_internal/extension/prompts/node/inline/visualization.js.map +0 -1
- package/dist/src/_internal/platform/editing/common/abstractText.d.ts +0 -58
- package/dist/src/_internal/platform/editing/common/abstractText.d.ts.map +0 -1
- package/dist/src/_internal/platform/editing/common/abstractText.js +0 -129
- package/dist/src/_internal/platform/editing/common/abstractText.js.map +0 -1
- package/dist/src/_internal/platform/parser/node/nodes.d.ts +0 -93
- package/dist/src/_internal/platform/parser/node/nodes.d.ts.map +0 -1
- package/dist/src/_internal/platform/parser/node/nodes.js +0 -133
- package/dist/src/_internal/platform/parser/node/nodes.js.map +0 -1
- package/dist/src/_internal/platform/telemetry/common/nullTelemetryService.d.ts +0 -18
- package/dist/src/_internal/platform/telemetry/common/nullTelemetryService.d.ts.map +0 -1
- package/dist/src/_internal/platform/telemetry/common/nullTelemetryService.js +0 -50
- package/dist/src/_internal/platform/telemetry/common/nullTelemetryService.js.map +0 -1
- package/dist/src/_internal/util/common/arrays.d.ts +0 -18
- package/dist/src/_internal/util/common/arrays.d.ts.map +0 -1
- package/dist/src/_internal/util/common/arrays.js +0 -80
- package/dist/src/_internal/util/common/arrays.js.map +0 -1
- package/src/_internal/extension/byok/node/openAIEndpoint.ts +0 -171
- package/src/_internal/extension/common/constants.ts +0 -90
- package/src/_internal/extension/inlineEdits/common/delayer.ts +0 -108
- package/src/_internal/extension/inlineEdits/common/editRebase.ts +0 -268
- package/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.tsx +0 -163
- package/src/_internal/extension/inlineEdits/common/nearbyCursorInlineEditProvider.ts +0 -225
- package/src/_internal/extension/inlineEdits/common/rejectionCollector.ts +0 -164
- package/src/_internal/extension/inlineEdits/node/debugRecorder.ts +0 -205
- package/src/_internal/extension/inlineEdits/node/importFiltering.ts +0 -25
- package/src/_internal/extension/inlineEdits/node/nesConfigs.ts +0 -12
- package/src/_internal/extension/inlineEdits/node/nextEditCache.ts +0 -278
- package/src/_internal/extension/inlineEdits/node/nextEditProvider.ts +0 -778
- package/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.ts +0 -983
- package/src/_internal/extension/inlineEdits/node/nextEditResult.ts +0 -40
- package/src/_internal/extension/prompt/common/importStatement.ts +0 -25
- package/src/_internal/extension/prompt/node/chatMLFetcher.ts +0 -706
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.ts +0 -146
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.ts +0 -527
- package/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.ts +0 -76
- package/src/_internal/extension/prompts/node/inline/visualization.ts +0 -65
- package/src/_internal/extension/vscode.proposed.activeComment.d.ts +0 -23
- package/src/_internal/extension/vscode.proposed.aiRelatedInformation.d.ts +0 -49
- package/src/_internal/extension/vscode.proposed.aiSettingsSearch.d.ts +0 -31
- package/src/_internal/extension/vscode.proposed.aiTextSearchProvider.d.ts +0 -41
- package/src/_internal/extension/vscode.proposed.authLearnMore.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.chatBinaryReferenceData.d.ts +0 -41
- package/src/_internal/extension/vscode.proposed.chatEditing.d.ts +0 -29
- package/src/_internal/extension/vscode.proposed.chatParticipantAdditions.d.ts +0 -636
- package/src/_internal/extension/vscode.proposed.chatParticipantPrivate.d.ts +0 -276
- package/src/_internal/extension/vscode.proposed.chatProvider.d.ts +0 -62
- package/src/_internal/extension/vscode.proposed.chatReadonlyPromptReference.d.ts +0 -17
- package/src/_internal/extension/vscode.proposed.chatReferenceDiagnostic.d.ts +0 -23
- package/src/_internal/extension/vscode.proposed.chatSessionsProvider.d.ts +0 -218
- package/src/_internal/extension/vscode.proposed.chatStatusItem.d.ts +0 -61
- package/src/_internal/extension/vscode.proposed.codeActionAI.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.commentReveal.d.ts +0 -32
- package/src/_internal/extension/vscode.proposed.contribCommentThreadAdditionalMenu.d.ts +0 -8
- package/src/_internal/extension/vscode.proposed.contribCommentsViewThreadMenus.d.ts +0 -6
- package/src/_internal/extension/vscode.proposed.contribSourceControlInputBoxMenu.d.ts +0 -7
- package/src/_internal/extension/vscode.proposed.dataChannels.d.ts +0 -19
- package/src/_internal/extension/vscode.proposed.defaultChatParticipant.d.ts +0 -52
- package/src/_internal/extension/vscode.proposed.documentFiltersExclusive.d.ts +0 -13
- package/src/_internal/extension/vscode.proposed.embeddings.d.ts +0 -33
- package/src/_internal/extension/vscode.proposed.extensionsAny.d.ts +0 -40
- package/src/_internal/extension/vscode.proposed.findFiles2.d.ts +0 -125
- package/src/_internal/extension/vscode.proposed.findTextInFiles.d.ts +0 -104
- package/src/_internal/extension/vscode.proposed.findTextInFiles2.d.ts +0 -144
- package/src/_internal/extension/vscode.proposed.inlineCompletionsAdditions.d.ts +0 -202
- package/src/_internal/extension/vscode.proposed.interactive.d.ts +0 -11
- package/src/_internal/extension/vscode.proposed.languageModelCapabilities.d.ts +0 -25
- package/src/_internal/extension/vscode.proposed.languageModelDataPart.d.ts +0 -163
- package/src/_internal/extension/vscode.proposed.languageModelSystem.d.ts +0 -17
- package/src/_internal/extension/vscode.proposed.languageModelThinkingPart.d.ts +0 -49
- package/src/_internal/extension/vscode.proposed.languageModelToolResultAudience.d.ts +0 -36
- package/src/_internal/extension/vscode.proposed.mappedEditsProvider.d.ts +0 -110
- package/src/_internal/extension/vscode.proposed.newSymbolNamesProvider.d.ts +0 -47
- package/src/_internal/extension/vscode.proposed.readonlyMessage.d.ts +0 -14
- package/src/_internal/extension/vscode.proposed.resolvers.d.ts +0 -475
- package/src/_internal/extension/vscode.proposed.scmInputBoxValueProvider.d.ts +0 -25
- package/src/_internal/extension/vscode.proposed.taskProblemMatcherStatus.d.ts +0 -42
- package/src/_internal/extension/vscode.proposed.terminalDataWriteEvent.d.ts +0 -32
- package/src/_internal/extension/vscode.proposed.terminalExecuteCommandEvent.d.ts +0 -48
- package/src/_internal/extension/vscode.proposed.terminalQuickFixProvider.d.ts +0 -87
- package/src/_internal/extension/vscode.proposed.terminalSelection.d.ts +0 -16
- package/src/_internal/extension/vscode.proposed.testObserver.d.ts +0 -199
- package/src/_internal/extension/vscode.proposed.textDocumentChangeReason.d.ts +0 -30
- package/src/_internal/extension/vscode.proposed.textSearchProvider.d.ts +0 -281
- package/src/_internal/extension/vscode.proposed.textSearchProvider2.d.ts +0 -297
- package/src/_internal/extension/xtab/common/promptCrafting.ts +0 -670
- package/src/_internal/extension/xtab/node/xtabEndpoint.ts +0 -102
- package/src/_internal/extension/xtab/node/xtabProvider.ts +0 -976
- package/src/_internal/extension/xtab/node/xtabUtils.ts +0 -62
- package/src/_internal/platform/authentication/common/authentication.ts +0 -309
- package/src/_internal/platform/authentication/common/copilotToken.ts +0 -300
- package/src/_internal/platform/authentication/common/copilotTokenManager.ts +0 -59
- package/src/_internal/platform/authentication/common/copilotTokenStore.ts +0 -40
- package/src/_internal/platform/authentication/common/staticGitHubAuthenticationService.ts +0 -96
- package/src/_internal/platform/authentication/node/copilotTokenManager.ts +0 -303
- package/src/_internal/platform/chat/common/chatMLFetcher.ts +0 -124
- package/src/_internal/platform/chat/common/chatQuotaService.ts +0 -63
- package/src/_internal/platform/chat/common/chatQuotaServiceImpl.ts +0 -96
- package/src/_internal/platform/chat/common/commonTypes.ts +0 -353
- package/src/_internal/platform/chat/common/conversationOptions.ts +0 -16
- package/src/_internal/platform/chat/common/globalStringUtils.ts +0 -54
- package/src/_internal/platform/chat/common/interactionService.ts +0 -35
- package/src/_internal/platform/configuration/common/configurationService.ts +0 -803
- package/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.ts +0 -39
- package/src/_internal/platform/configuration/common/jsonSchema.ts +0 -139
- package/src/_internal/platform/configuration/common/validator.ts +0 -242
- package/src/_internal/platform/diff/common/diffService.ts +0 -41
- package/src/_internal/platform/diff/common/diffWorker.ts +0 -83
- package/src/_internal/platform/diff/node/diffServiceImpl.ts +0 -85
- package/src/_internal/platform/editing/common/abstractText.ts +0 -177
- package/src/_internal/platform/editing/common/notebookDocumentSnapshot.ts +0 -122
- package/src/_internal/platform/editing/common/positionOffsetTransformer.ts +0 -202
- package/src/_internal/platform/editing/common/textDocumentSnapshot.ts +0 -274
- package/src/_internal/platform/endpoint/common/capiClient.ts +0 -37
- package/src/_internal/platform/endpoint/common/chatModelCapabilities.ts +0 -115
- package/src/_internal/platform/endpoint/common/domainService.ts +0 -27
- package/src/_internal/platform/endpoint/common/endpointProvider.ts +0 -104
- package/src/_internal/platform/endpoint/common/endpointTypes.ts +0 -12
- package/src/_internal/platform/endpoint/common/licenseAgreement.ts +0 -11
- package/src/_internal/platform/endpoint/common/statefulMarkerContainer.tsx +0 -85
- package/src/_internal/platform/endpoint/common/thinkingDataContainer.tsx +0 -44
- package/src/_internal/platform/endpoint/node/capiClientImpl.ts +0 -18
- package/src/_internal/platform/endpoint/node/chatEndpoint.ts +0 -435
- package/src/_internal/platform/endpoint/node/domainServiceImpl.ts +0 -80
- package/src/_internal/platform/endpoint/node/proxyXtabEndpoint.ts +0 -43
- package/src/_internal/platform/endpoint/node/responsesApi.ts +0 -326
- package/src/_internal/platform/env/common/envService.ts +0 -134
- package/src/_internal/platform/env/common/nullEnvService.ts +0 -68
- package/src/_internal/platform/env/common/packagejson.ts +0 -49
- package/src/_internal/platform/git/common/gitExtensionService.ts +0 -21
- package/src/_internal/platform/git/common/nullGitExtensionService.ts +0 -20
- package/src/_internal/platform/git/vscode/git.d.ts +0 -414
- package/src/_internal/platform/github/common/githubAPI.ts +0 -44
- package/src/_internal/platform/github/common/githubService.ts +0 -87
- package/src/_internal/platform/github/common/nullOctokitServiceImpl.ts +0 -21
- package/src/_internal/platform/ignore/common/ignoreService.ts +0 -72
- package/src/_internal/platform/inlineCompletions/common/api.ts +0 -198
- package/src/_internal/platform/inlineEdits/common/dataTypes/diagnosticData.ts +0 -32
- package/src/_internal/platform/inlineEdits/common/dataTypes/documentId.ts +0 -52
- package/src/_internal/platform/inlineEdits/common/dataTypes/edit.ts +0 -165
- package/src/_internal/platform/inlineEdits/common/dataTypes/editUtils.ts +0 -74
- package/src/_internal/platform/inlineEdits/common/dataTypes/fetchCancellationError.ts +0 -14
- package/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.ts +0 -107
- package/src/_internal/platform/inlineEdits/common/dataTypes/languageId.ts +0 -14
- package/src/_internal/platform/inlineEdits/common/dataTypes/permutation.ts +0 -69
- package/src/_internal/platform/inlineEdits/common/dataTypes/rootedLineEdit.ts +0 -49
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLength.ts +0 -74
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/combineTextEditInfos.ts +0 -132
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/length.ts +0 -184
- package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/textEditInfo.ts +0 -32
- package/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts +0 -89
- package/src/_internal/platform/inlineEdits/common/debugRecorderBookmark.ts +0 -10
- package/src/_internal/platform/inlineEdits/common/editReason.ts +0 -134
- package/src/_internal/platform/inlineEdits/common/inlineEditLogContext.ts +0 -490
- package/src/_internal/platform/inlineEdits/common/observableGit.ts +0 -49
- package/src/_internal/platform/inlineEdits/common/observableWorkspace.ts +0 -239
- package/src/_internal/platform/inlineEdits/common/responseProcessor.ts +0 -249
- package/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.ts +0 -468
- package/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.ts +0 -59
- package/src/_internal/platform/inlineEdits/common/utils/observable.ts +0 -54
- package/src/_internal/platform/inlineEdits/common/utils/stringifyChatMessages.ts +0 -29
- package/src/_internal/platform/inlineEdits/common/utils/utils.ts +0 -56
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/historyContextProvider.ts +0 -60
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesHistoryContextProvider.ts +0 -353
- package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker.ts +0 -176
- package/src/_internal/platform/languageContextProvider/common/languageContextProviderService.ts +0 -25
- package/src/_internal/platform/languageContextProvider/common/nullLanguageContextProviderService.ts +0 -38
- package/src/_internal/platform/languageServer/common/languageContextService.ts +0 -186
- package/src/_internal/platform/languages/common/languageDiagnosticsService.ts +0 -67
- package/src/_internal/platform/languages/common/testLanguageDiagnosticsService.ts +0 -28
- package/src/_internal/platform/log/common/logService.ts +0 -232
- package/src/_internal/platform/nesFetch/common/completionsAPI.ts +0 -78
- package/src/_internal/platform/nesFetch/common/completionsFetchService.ts +0 -118
- package/src/_internal/platform/nesFetch/common/responseStream.ts +0 -151
- package/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.ts +0 -236
- package/src/_internal/platform/nesFetch/node/streamTransformer.ts +0 -95
- package/src/_internal/platform/networking/common/fetch.ts +0 -349
- package/src/_internal/platform/networking/common/fetcherService.ts +0 -84
- package/src/_internal/platform/networking/common/networking.ts +0 -442
- package/src/_internal/platform/networking/common/openai.ts +0 -273
- package/src/_internal/platform/networking/node/chatStream.ts +0 -137
- package/src/_internal/platform/networking/node/stream.ts +0 -749
- package/src/_internal/platform/notebook/common/alternativeContent.ts +0 -89
- package/src/_internal/platform/notebook/common/alternativeContentFormat.ts +0 -10
- package/src/_internal/platform/notebook/common/alternativeContentProvider.json.ts +0 -262
- package/src/_internal/platform/notebook/common/alternativeContentProvider.text.ts +0 -243
- package/src/_internal/platform/notebook/common/alternativeContentProvider.ts +0 -41
- package/src/_internal/platform/notebook/common/alternativeContentProvider.xml.ts +0 -205
- package/src/_internal/platform/notebook/common/alternativeNotebookDocument.ts +0 -155
- package/src/_internal/platform/notebook/common/helpers.ts +0 -212
- package/src/_internal/platform/notebook/common/notebookService.ts +0 -43
- package/src/_internal/platform/openai/node/fetch.ts +0 -596
- package/src/_internal/platform/parser/node/nodes.ts +0 -190
- package/src/_internal/platform/requestLogger/node/nullRequestLogger.ts +0 -26
- package/src/_internal/platform/requestLogger/node/requestLogger.ts +0 -383
- package/src/_internal/platform/simulationTestContext/common/simulationTestContext.ts +0 -29
- package/src/_internal/platform/snippy/common/snippyService.ts +0 -25
- package/src/_internal/platform/telemetry/common/nullExperimentationService.ts +0 -64
- package/src/_internal/platform/telemetry/common/nullTelemetryService.ts +0 -53
- package/src/_internal/platform/telemetry/common/telemetry.ts +0 -215
- package/src/_internal/platform/telemetry/common/telemetryData.ts +0 -205
- package/src/_internal/platform/thinking/common/thinking.ts +0 -61
- package/src/_internal/platform/thinking/common/thinkingUtils.ts +0 -57
- package/src/_internal/platform/tokenizer/node/parseTikTokens.ts +0 -23
- package/src/_internal/platform/tokenizer/node/tikTokenizerImpl.ts +0 -74
- package/src/_internal/platform/tokenizer/node/tikTokenizerWorker.ts +0 -24
- package/src/_internal/platform/tokenizer/node/tokenizer.ts +0 -357
- package/src/_internal/platform/workspace/common/workspaceService.ts +0 -226
- package/src/_internal/platform/workspaceRecorder/common/workspaceLog.ts +0 -118
- package/src/_internal/util/common/anomalyDetection.ts +0 -112
- package/src/_internal/util/common/arrays.ts +0 -81
- package/src/_internal/util/common/async.ts +0 -155
- package/src/_internal/util/common/cache.ts +0 -183
- package/src/_internal/util/common/crypto.ts +0 -41
- package/src/_internal/util/common/errors.ts +0 -22
- package/src/_internal/util/common/globals.d.ts +0 -12
- package/src/_internal/util/common/imageUtils.ts +0 -154
- package/src/_internal/util/common/languages.ts +0 -940
- package/src/_internal/util/common/notebooks.ts +0 -286
- package/src/_internal/util/common/result.ts +0 -71
- package/src/_internal/util/common/services.ts +0 -43
- package/src/_internal/util/common/test/shims/chatTypes.ts +0 -448
- package/src/_internal/util/common/test/shims/editing.ts +0 -233
- package/src/_internal/util/common/test/shims/enums.ts +0 -61
- package/src/_internal/util/common/test/shims/l10n.ts +0 -37
- package/src/_internal/util/common/test/shims/newSymbolName.ts +0 -23
- package/src/_internal/util/common/test/shims/terminal.ts +0 -33
- package/src/_internal/util/common/test/shims/vscodeTypesShim.ts +0 -115
- package/src/_internal/util/common/time.ts +0 -31
- package/src/_internal/util/common/tokenizer.ts +0 -30
- package/src/_internal/util/common/tracing.ts +0 -52
- package/src/_internal/util/common/types.ts +0 -33
- package/src/_internal/util/common/variableLengthQuantity.ts +0 -40
- package/src/_internal/util/node/worker.ts +0 -130
- package/src/_internal/util/vs/base/common/arrays.ts +0 -926
- package/src/_internal/util/vs/base/common/arraysFind.ts +0 -206
- package/src/_internal/util/vs/base/common/assert.ts +0 -89
- package/src/_internal/util/vs/base/common/async.ts +0 -2582
- package/src/_internal/util/vs/base/common/buffer.ts +0 -501
- package/src/_internal/util/vs/base/common/cache.ts +0 -122
- package/src/_internal/util/vs/base/common/cancellation.ts +0 -150
- package/src/_internal/util/vs/base/common/charCode.ts +0 -452
- package/src/_internal/util/vs/base/common/codicons.ts +0 -66
- package/src/_internal/util/vs/base/common/codiconsLibrary.ts +0 -618
- package/src/_internal/util/vs/base/common/codiconsUtil.ts +0 -30
- package/src/_internal/util/vs/base/common/collections.ts +0 -156
- package/src/_internal/util/vs/base/common/diff/diff.ts +0 -1317
- package/src/_internal/util/vs/base/common/diff/diffChange.ts +0 -62
- package/src/_internal/util/vs/base/common/equals.ts +0 -148
- package/src/_internal/util/vs/base/common/errors.ts +0 -342
- package/src/_internal/util/vs/base/common/event.ts +0 -1782
- package/src/_internal/util/vs/base/common/extpath.ts +0 -425
- package/src/_internal/util/vs/base/common/filters.ts +0 -928
- package/src/_internal/util/vs/base/common/functional.ts +0 -34
- package/src/_internal/util/vs/base/common/glob.ts +0 -839
- package/src/_internal/util/vs/base/common/hash.ts +0 -326
- package/src/_internal/util/vs/base/common/htmlContent.ts +0 -212
- package/src/_internal/util/vs/base/common/iconLabels.ts +0 -118
- package/src/_internal/util/vs/base/common/iterator.ts +0 -196
- package/src/_internal/util/vs/base/common/lazy.ts +0 -59
- package/src/_internal/util/vs/base/common/lifecycle.ts +0 -845
- package/src/_internal/util/vs/base/common/linkedList.ts +0 -144
- package/src/_internal/util/vs/base/common/map.ts +0 -954
- package/src/_internal/util/vs/base/common/marshallingIds.ts +0 -35
- package/src/_internal/util/vs/base/common/mime.ts +0 -136
- package/src/_internal/util/vs/base/common/naturalLanguage/korean.ts +0 -425
- package/src/_internal/util/vs/base/common/network.ts +0 -429
- package/src/_internal/util/vs/base/common/numbers.ts +0 -166
- package/src/_internal/util/vs/base/common/objects.ts +0 -242
- package/src/_internal/util/vs/base/common/observable.ts +0 -10
- package/src/_internal/util/vs/base/common/observableInternal/base.ts +0 -208
- package/src/_internal/util/vs/base/common/observableInternal/changeTracker.ts +0 -96
- package/src/_internal/util/vs/base/common/observableInternal/commonFacade/cancellation.ts +0 -9
- package/src/_internal/util/vs/base/common/observableInternal/commonFacade/deps.ts +0 -12
- package/src/_internal/util/vs/base/common/observableInternal/debugLocation.ts +0 -88
- package/src/_internal/util/vs/base/common/observableInternal/debugName.ts +0 -150
- package/src/_internal/util/vs/base/common/observableInternal/experimental/utils.ts +0 -62
- package/src/_internal/util/vs/base/common/observableInternal/index.ts +0 -61
- package/src/_internal/util/vs/base/common/observableInternal/logging/consoleObservableLogger.ts +0 -388
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts +0 -154
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerRpc.ts +0 -80
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts +0 -485
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/rpc.ts +0 -103
- package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/utils.ts +0 -69
- package/src/_internal/util/vs/base/common/observableInternal/logging/logging.ts +0 -133
- package/src/_internal/util/vs/base/common/observableInternal/map.ts +0 -81
- package/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.ts +0 -172
- package/src/_internal/util/vs/base/common/observableInternal/observables/constObservable.ts +0 -44
- package/src/_internal/util/vs/base/common/observableInternal/observables/derived.ts +0 -190
- package/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.ts +0 -445
- package/src/_internal/util/vs/base/common/observableInternal/observables/lazyObservableValue.ts +0 -154
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.ts +0 -174
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignal.ts +0 -67
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignalFromEvent.ts +0 -62
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableValue.ts +0 -131
- package/src/_internal/util/vs/base/common/observableInternal/observables/observableValueOpts.ts +0 -37
- package/src/_internal/util/vs/base/common/observableInternal/reactions/autorun.ts +0 -188
- package/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.ts +0 -256
- package/src/_internal/util/vs/base/common/observableInternal/set.ts +0 -78
- package/src/_internal/util/vs/base/common/observableInternal/transaction.ts +0 -115
- package/src/_internal/util/vs/base/common/observableInternal/utils/promise.ts +0 -129
- package/src/_internal/util/vs/base/common/observableInternal/utils/runOnChange.ts +0 -65
- package/src/_internal/util/vs/base/common/observableInternal/utils/utils.ts +0 -281
- package/src/_internal/util/vs/base/common/observableInternal/utils/utilsCancellation.ts +0 -101
- package/src/_internal/util/vs/base/common/observableInternal/utils/valueWithChangeEvent.ts +0 -31
- package/src/_internal/util/vs/base/common/path.ts +0 -1591
- package/src/_internal/util/vs/base/common/platform.ts +0 -282
- package/src/_internal/util/vs/base/common/process.ts +0 -78
- package/src/_internal/util/vs/base/common/resources.ts +0 -446
- package/src/_internal/util/vs/base/common/sequence.ts +0 -36
- package/src/_internal/util/vs/base/common/sseParser.ts +0 -247
- package/src/_internal/util/vs/base/common/stopwatch.ts +0 -43
- package/src/_internal/util/vs/base/common/stream.ts +0 -792
- package/src/_internal/util/vs/base/common/strings.ts +0 -1364
- package/src/_internal/util/vs/base/common/symbols.ts +0 -11
- package/src/_internal/util/vs/base/common/themables.ts +0 -106
- package/src/_internal/util/vs/base/common/types.ts +0 -345
- package/src/_internal/util/vs/base/common/uint.ts +0 -61
- package/src/_internal/util/vs/base/common/uri.ts +0 -752
- package/src/_internal/util/vs/base/common/uuid.ts +0 -72
- package/src/_internal/util/vs/base-common.d.ts +0 -42
- package/src/_internal/util/vs/editor/common/core/editOperation.ts +0 -62
- package/src/_internal/util/vs/editor/common/core/edits/edit.ts +0 -399
- package/src/_internal/util/vs/editor/common/core/edits/lineEdit.ts +0 -414
- package/src/_internal/util/vs/editor/common/core/edits/stringEdit.ts +0 -568
- package/src/_internal/util/vs/editor/common/core/edits/textEdit.ts +0 -411
- package/src/_internal/util/vs/editor/common/core/position.ts +0 -186
- package/src/_internal/util/vs/editor/common/core/range.ts +0 -519
- package/src/_internal/util/vs/editor/common/core/ranges/lineRange.ts +0 -416
- package/src/_internal/util/vs/editor/common/core/ranges/offsetRange.ts +0 -275
- package/src/_internal/util/vs/editor/common/core/text/abstractText.ts +0 -127
- package/src/_internal/util/vs/editor/common/core/text/positionToOffset.ts +0 -26
- package/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.ts +0 -144
- package/src/_internal/util/vs/editor/common/core/text/textLength.ts +0 -150
- package/src/_internal/util/vs/editor/common/core/wordHelper.ts +0 -177
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/diffAlgorithm.ts +0 -210
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/dynamicProgrammingDiffing.ts +0 -109
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/myersDiffAlgorithm.ts +0 -178
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/computeMovedLines.ts +0 -331
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/defaultLinesDiffComputer.ts +0 -273
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/heuristicSequenceOptimizations.ts +0 -475
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/lineSequence.ts +0 -47
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/linesSliceCharSequence.ts +0 -248
- package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/utils.ts +0 -76
- package/src/_internal/util/vs/editor/common/diff/legacyLinesDiffComputer.ts +0 -693
- package/src/_internal/util/vs/editor/common/diff/linesDiffComputer.ts +0 -61
- package/src/_internal/util/vs/editor/common/diff/rangeMapping.ts +0 -418
- package/src/_internal/util/vs/editor/common/model/prefixSumComputer.ts +0 -304
- package/src/_internal/util/vs/nls.messages.ts +0 -21
- package/src/_internal/util/vs/nls.ts +0 -243
- package/src/_internal/util/vs/platform/instantiation/common/descriptors.ts +0 -23
- package/src/_internal/util/vs/platform/instantiation/common/graph.ts +0 -113
- package/src/_internal/util/vs/platform/instantiation/common/instantiation.ts +0 -127
- package/src/_internal/util/vs/platform/instantiation/common/instantiationService.ts +0 -483
- package/src/_internal/util/vs/platform/instantiation/common/serviceCollection.ts +0 -34
- package/src/_internal/util/vs/vscode-globals-nls.d.ts +0 -42
- package/src/_internal/util/vs/vscode-globals-product.d.ts +0 -35
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/diagnostic.ts +0 -109
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/es5ClassCompat.ts +0 -34
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/location.ts +0 -51
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.ts +0 -83
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/notebooks.ts +0 -296
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/position.ts +0 -195
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/range.ts +0 -167
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.ts +0 -94
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.ts +0 -103
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetTextEdit.ts +0 -44
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/symbolInformation.ts +0 -89
- package/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.ts +0 -99
- package/src/_internal/vscodeTypes.ts +0 -100
- package/src/main.ts +0 -207
- package/src/package.json +0 -4063
|
@@ -1,442 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
|
|
6
|
-
import { RequestMetadata } from '@vscode/copilot-api';
|
|
7
|
-
import { Raw } from '@vscode/prompt-tsx';
|
|
8
|
-
import type { CancellationToken } from 'vscode';
|
|
9
|
-
import { createServiceIdentifier } from '../../../util/common/services';
|
|
10
|
-
import { ITokenizer, TokenizerType } from '../../../util/common/tokenizer';
|
|
11
|
-
import { AsyncIterableObject } from '../../../util/vs/base/common/async';
|
|
12
|
-
import { CancellationError } from '../../../util/vs/base/common/errors';
|
|
13
|
-
import { Source } from '../../chat/common/chatMLFetcher';
|
|
14
|
-
import type { ChatLocation, ChatResponse } from '../../chat/common/commonTypes';
|
|
15
|
-
import { ICAPIClientService } from '../../endpoint/common/capiClient';
|
|
16
|
-
import { IDomainService } from '../../endpoint/common/domainService';
|
|
17
|
-
import { IEnvService } from '../../env/common/envService';
|
|
18
|
-
import { ILogService } from '../../log/common/logService';
|
|
19
|
-
import { ITelemetryService, TelemetryProperties } from '../../telemetry/common/telemetry';
|
|
20
|
-
import { TelemetryData } from '../../telemetry/common/telemetryData';
|
|
21
|
-
import { FinishedCallback, OpenAiFunctionTool, OpenAiResponsesFunctionTool, OptionalChatRequestParams } from './fetch';
|
|
22
|
-
import { FetchOptions, IAbortController, IFetcherService, Response } from './fetcherService';
|
|
23
|
-
import { ChatCompletion, RawMessageConversionCallback, rawMessageToCAPI } from './openai';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Encapsulates all the functionality related to making GET/POST requests using
|
|
27
|
-
* different libraries (and in the future, different environments like web vs
|
|
28
|
-
* node).
|
|
29
|
-
*/
|
|
30
|
-
export interface IFetcher {
|
|
31
|
-
getUserAgentLibrary(): string;
|
|
32
|
-
fetch(url: string, options: FetchOptions): Promise<Response>;
|
|
33
|
-
disconnectAll(): Promise<unknown>;
|
|
34
|
-
makeAbortController(): IAbortController;
|
|
35
|
-
isAbortError(e: any): boolean;
|
|
36
|
-
isInternetDisconnectedError(e: any): boolean;
|
|
37
|
-
isFetcherError(err: any): boolean;
|
|
38
|
-
getUserMessageForFetcherError(err: any): string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const userAgentLibraryHeader = 'X-VSCode-User-Agent-Library-Version';
|
|
42
|
-
|
|
43
|
-
export type ReqHeaders = { [key: string]: string };
|
|
44
|
-
/**
|
|
45
|
-
* The HeaderContributor provides the interface which allows implmentors
|
|
46
|
-
* to decorate a request's `headers` object with additional key / value pairs.
|
|
47
|
-
*/
|
|
48
|
-
export interface HeaderContributor {
|
|
49
|
-
contributeHeaderValues(headers: ReqHeaders): void;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// The maximum time to wait for a request to complete.
|
|
53
|
-
const requestTimeoutMs = 30 * 1000; // 30 seconds
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Rough shape of an endpoint body. A superset of the parameters of any request,
|
|
58
|
-
* but provided to at least have rough typings.
|
|
59
|
-
*/
|
|
60
|
-
export interface IEndpointBody {
|
|
61
|
-
/** General or completions: */
|
|
62
|
-
tools?: (OpenAiFunctionTool | OpenAiResponsesFunctionTool)[];
|
|
63
|
-
model?: string;
|
|
64
|
-
previous_response_id?: string;
|
|
65
|
-
max_tokens?: number;
|
|
66
|
-
max_output_tokens?: number;
|
|
67
|
-
max_completion_tokens?: number;
|
|
68
|
-
temperature?: number;
|
|
69
|
-
top_p?: number;
|
|
70
|
-
stream?: boolean;
|
|
71
|
-
messages?: any[];
|
|
72
|
-
n?: number;
|
|
73
|
-
reasoning?: { effort?: string; summary?: string };
|
|
74
|
-
tool_choice?: OptionalChatRequestParams['tool_choice'] | { type: 'function'; name: string };
|
|
75
|
-
top_logprobs?: number;
|
|
76
|
-
intent?: boolean;
|
|
77
|
-
intent_threshold?: number;
|
|
78
|
-
state?: 'enabled';
|
|
79
|
-
snippy?: { enabled: boolean };
|
|
80
|
-
stream_options?: { include_usage?: boolean };
|
|
81
|
-
prompt?: string;
|
|
82
|
-
/** Embeddings endpoints only: */
|
|
83
|
-
dimensions?: number;
|
|
84
|
-
embed?: boolean;
|
|
85
|
-
/** Chunking endpoints: */
|
|
86
|
-
qos?: any;
|
|
87
|
-
content?: string;
|
|
88
|
-
path?: string;
|
|
89
|
-
local_hashes?: string[];
|
|
90
|
-
language_id?: number;
|
|
91
|
-
/** docs search */
|
|
92
|
-
query?: string;
|
|
93
|
-
scopingQuery?: string;
|
|
94
|
-
limit?: number;
|
|
95
|
-
similarity?: number;
|
|
96
|
-
/** Code search: */
|
|
97
|
-
scoping_query?: string;
|
|
98
|
-
|
|
99
|
-
/** Responses API: */
|
|
100
|
-
input?: readonly any[];
|
|
101
|
-
truncation?: 'auto' | 'disabled';
|
|
102
|
-
include?: ['reasoning.encrypted_content'];
|
|
103
|
-
store?: boolean;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface IEndpoint {
|
|
107
|
-
readonly urlOrRequestMetadata: string | RequestMetadata;
|
|
108
|
-
getExtraHeaders?(): Record<string, string>;
|
|
109
|
-
interceptBody?(body: IEndpointBody | undefined): void;
|
|
110
|
-
acquireTokenizer(): ITokenizer;
|
|
111
|
-
readonly modelMaxPromptTokens: number;
|
|
112
|
-
readonly name: string;
|
|
113
|
-
readonly version: string;
|
|
114
|
-
readonly family: string;
|
|
115
|
-
readonly tokenizer: TokenizerType;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function stringifyUrlOrRequestMetadata(urlOrRequestMetadata: string | RequestMetadata): string {
|
|
119
|
-
if (typeof urlOrRequestMetadata === 'string') {
|
|
120
|
-
return urlOrRequestMetadata;
|
|
121
|
-
}
|
|
122
|
-
return JSON.stringify(urlOrRequestMetadata);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface IMakeChatRequestOptions {
|
|
126
|
-
/** The debug name for this request */
|
|
127
|
-
debugName: string;
|
|
128
|
-
/** The array of chat messages to send */
|
|
129
|
-
messages: Raw.ChatMessage[];
|
|
130
|
-
// todo
|
|
131
|
-
ignoreStatefulMarker?: boolean;
|
|
132
|
-
/** Streaming callback for each response part. */
|
|
133
|
-
finishedCb: FinishedCallback | undefined;
|
|
134
|
-
/** Location where the chat message is being sent. */
|
|
135
|
-
location: ChatLocation;
|
|
136
|
-
/** Optional source of the chat request */
|
|
137
|
-
source?: Source;
|
|
138
|
-
/** Additional request options */
|
|
139
|
-
requestOptions?: Omit<OptionalChatRequestParams, 'n'>;
|
|
140
|
-
/** Indicates if the request was user-initiated */
|
|
141
|
-
userInitiatedRequest?: boolean;
|
|
142
|
-
/** (CAPI-only) Optional telemetry properties for analytics */
|
|
143
|
-
telemetryProperties?: TelemetryProperties;
|
|
144
|
-
/** Whether this request is retrying a filtered response */
|
|
145
|
-
isFilterRetry?: boolean;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export interface ICreateEndpointBodyOptions extends IMakeChatRequestOptions {
|
|
149
|
-
requestId: string;
|
|
150
|
-
postOptions: OptionalChatRequestParams;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export interface IChatEndpoint extends IEndpoint {
|
|
154
|
-
readonly maxOutputTokens: number;
|
|
155
|
-
/** The model ID- this may change and will be `copilot-base` for the base model. Use `family` to switch behavior based on model type. */
|
|
156
|
-
readonly model: string;
|
|
157
|
-
readonly apiType?: string;
|
|
158
|
-
readonly supportsToolCalls: boolean;
|
|
159
|
-
readonly supportsVision: boolean;
|
|
160
|
-
readonly supportsPrediction: boolean;
|
|
161
|
-
readonly showInModelPicker: boolean;
|
|
162
|
-
readonly isPremium?: boolean;
|
|
163
|
-
readonly multiplier?: number;
|
|
164
|
-
readonly restrictedToSkus?: string[];
|
|
165
|
-
readonly isDefault: boolean;
|
|
166
|
-
readonly isFallback: boolean;
|
|
167
|
-
readonly policy: 'enabled' | { terms: string };
|
|
168
|
-
/**
|
|
169
|
-
* Handles processing of responses from a chat endpoint. Each endpoint can have different response formats.
|
|
170
|
-
* @param telemetryService The telemetry service
|
|
171
|
-
* @param logService The log service
|
|
172
|
-
* @param response The response from the chat endpoint
|
|
173
|
-
* @param expectedNumChoices The expected number of choices in the response
|
|
174
|
-
* @param finishCallback A finish callback to indicate when the response should be complete
|
|
175
|
-
* @param telemetryData GH telemetry data from the originating request, will be extended with request information
|
|
176
|
-
* @param cancellationToken A cancellation tokenf for cancelling the request
|
|
177
|
-
* @returns An async iterable object of chat completions
|
|
178
|
-
*/
|
|
179
|
-
processResponseFromChatEndpoint(
|
|
180
|
-
telemetryService: ITelemetryService,
|
|
181
|
-
logService: ILogService,
|
|
182
|
-
response: Response,
|
|
183
|
-
expectedNumChoices: number,
|
|
184
|
-
finishCallback: FinishedCallback,
|
|
185
|
-
telemetryData: TelemetryData,
|
|
186
|
-
cancellationToken?: CancellationToken
|
|
187
|
-
): Promise<AsyncIterableObject<ChatCompletion>>;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Accepts the chat policy for the given endpoint, enabling its usage.
|
|
191
|
-
* @returns A promise that resolves to true if the chat policy was accepted, false otherwise.
|
|
192
|
-
*/
|
|
193
|
-
acceptChatPolicy(): Promise<boolean>;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Flights a request from the chat endpoint returning a chat response.
|
|
197
|
-
* Most of the time this is ChatMLFetcher#fetchOne, but it can be overridden for special cases.
|
|
198
|
-
* TODO @lramos15 - Support multiple completions in the future, we don't use this at the moment.
|
|
199
|
-
*
|
|
200
|
-
* @param userInitiatedRequest Is only applicable to CAPI requests
|
|
201
|
-
* @param telemetryProperties An object containing various properties for telemetry, e.g., can contain a field `requestId` that sets the header request ID
|
|
202
|
-
*/
|
|
203
|
-
makeChatRequest(
|
|
204
|
-
debugName: string,
|
|
205
|
-
messages: Raw.ChatMessage[],
|
|
206
|
-
finishedCb: FinishedCallback | undefined,
|
|
207
|
-
token: CancellationToken,
|
|
208
|
-
location: ChatLocation,
|
|
209
|
-
source?: Source,
|
|
210
|
-
requestOptions?: Omit<OptionalChatRequestParams, 'n'>,
|
|
211
|
-
userInitiatedRequest?: boolean,
|
|
212
|
-
telemetryProperties?: TelemetryProperties,
|
|
213
|
-
): Promise<ChatResponse>;
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Flights a request from the chat endpoint returning a chat response.
|
|
217
|
-
* Most of the time this is ChatMLFetcher#fetchOne, but it can be overridden for special cases.
|
|
218
|
-
*/
|
|
219
|
-
makeChatRequest2(options: IMakeChatRequestOptions, token: CancellationToken): Promise<ChatResponse>;
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Creates the request body to be sent to the endpoint based on the request.
|
|
223
|
-
*/
|
|
224
|
-
createRequestBody(options: ICreateEndpointBodyOptions): IEndpointBody;
|
|
225
|
-
|
|
226
|
-
cloneWithTokenOverride(modelMaxPromptTokens: number): IChatEndpoint;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/** Function to create a standard request body for CAPI completions */
|
|
230
|
-
export function createCapiRequestBody(options: ICreateEndpointBodyOptions, model: string, callback?: RawMessageConversionCallback) {
|
|
231
|
-
// FIXME@ulugbekna: need to investigate why language configs have such stop words, eg
|
|
232
|
-
// python has `\ndef` and `\nclass` which must be stop words for ghost text
|
|
233
|
-
// const stops = getLanguageConfig<string[]>(accessor, ConfigKey.Stops);
|
|
234
|
-
|
|
235
|
-
const request: IEndpointBody = {
|
|
236
|
-
messages: rawMessageToCAPI(options.messages, callback),
|
|
237
|
-
model,
|
|
238
|
-
// stop: stops,
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
if (options.postOptions) {
|
|
242
|
-
Object.assign(request, options.postOptions);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return request;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function networkRequest(
|
|
249
|
-
fetcher: IFetcher,
|
|
250
|
-
envService: IEnvService,
|
|
251
|
-
telemetryService: ITelemetryService,
|
|
252
|
-
domainService: IDomainService,
|
|
253
|
-
capiClientService: ICAPIClientService,
|
|
254
|
-
requestType: 'GET' | 'POST',
|
|
255
|
-
endpointOrUrl: IEndpoint | string | RequestMetadata,
|
|
256
|
-
secretKey: string,
|
|
257
|
-
hmac: string | undefined,
|
|
258
|
-
intent: string,
|
|
259
|
-
requestId: string,
|
|
260
|
-
body?: IEndpointBody,
|
|
261
|
-
additionalHeaders?: Record<string, string>,
|
|
262
|
-
cancelToken?: CancellationToken
|
|
263
|
-
): Promise<Response> {
|
|
264
|
-
// TODO @lramos15 Eventually don't even construct this fake endpoint object.
|
|
265
|
-
const endpoint = typeof endpointOrUrl === 'string' || 'type' in endpointOrUrl ? {
|
|
266
|
-
modelMaxPromptTokens: 0,
|
|
267
|
-
urlOrRequestMetadata: endpointOrUrl,
|
|
268
|
-
family: '',
|
|
269
|
-
tokenizer: TokenizerType.O200K,
|
|
270
|
-
acquireTokenizer: () => {
|
|
271
|
-
throw new Error('Method not implemented.');
|
|
272
|
-
},
|
|
273
|
-
name: '',
|
|
274
|
-
version: '',
|
|
275
|
-
} satisfies IEndpoint : endpointOrUrl;
|
|
276
|
-
const headers: ReqHeaders = {
|
|
277
|
-
Authorization: `Bearer ${secretKey}`,
|
|
278
|
-
'X-Request-Id': requestId,
|
|
279
|
-
'X-Interaction-Type': intent,
|
|
280
|
-
'OpenAI-Intent': intent, // Tells CAPI who flighted this request. Helps find buggy features
|
|
281
|
-
'X-GitHub-Api-Version': '2025-05-01',
|
|
282
|
-
...additionalHeaders,
|
|
283
|
-
...(endpoint.getExtraHeaders ? endpoint.getExtraHeaders() : {}),
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
if (endpoint.interceptBody) {
|
|
287
|
-
endpoint.interceptBody(body);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const request: FetchOptions = {
|
|
291
|
-
method: requestType,
|
|
292
|
-
headers: headers,
|
|
293
|
-
json: body,
|
|
294
|
-
timeout: requestTimeoutMs,
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
if (cancelToken) {
|
|
298
|
-
const abort = fetcher.makeAbortController();
|
|
299
|
-
cancelToken.onCancellationRequested(() => {
|
|
300
|
-
// abort the request when the token is canceled
|
|
301
|
-
telemetryService.sendGHTelemetryEvent('networking.cancelRequest', {
|
|
302
|
-
headerRequestId: requestId,
|
|
303
|
-
});
|
|
304
|
-
abort.abort();
|
|
305
|
-
});
|
|
306
|
-
// pass the controller abort signal to the request
|
|
307
|
-
request.signal = abort.signal;
|
|
308
|
-
}
|
|
309
|
-
if (typeof endpoint.urlOrRequestMetadata === 'string') {
|
|
310
|
-
const requestPromise = fetcher.fetch(endpoint.urlOrRequestMetadata, request).catch(reason => {
|
|
311
|
-
if (canRetryOnceNetworkError(reason)) {
|
|
312
|
-
// disconnect and retry the request once if the connection was reset
|
|
313
|
-
telemetryService.sendGHTelemetryEvent('networking.disconnectAll');
|
|
314
|
-
return fetcher.disconnectAll().then(() => {
|
|
315
|
-
return fetcher.fetch(endpoint.urlOrRequestMetadata as string, request);
|
|
316
|
-
});
|
|
317
|
-
} else if (fetcher.isAbortError(reason)) {
|
|
318
|
-
throw new CancellationError();
|
|
319
|
-
} else {
|
|
320
|
-
throw reason;
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
return requestPromise;
|
|
324
|
-
} else {
|
|
325
|
-
return capiClientService.makeRequest(request, endpoint.urlOrRequestMetadata as RequestMetadata);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
export function canRetryOnceNetworkError(reason: any) {
|
|
330
|
-
return [
|
|
331
|
-
'ECONNRESET',
|
|
332
|
-
'ETIMEDOUT',
|
|
333
|
-
'ERR_NETWORK_CHANGED',
|
|
334
|
-
'ERR_HTTP2_INVALID_SESSION',
|
|
335
|
-
'ERR_HTTP2_STREAM_CANCEL',
|
|
336
|
-
'ERR_HTTP2_GOAWAY_SESSION',
|
|
337
|
-
'ERR_HTTP2_PROTOCOL_ERROR',
|
|
338
|
-
].includes(reason?.code);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
export function postRequest(
|
|
342
|
-
fetcherService: IFetcherService,
|
|
343
|
-
envService: IEnvService,
|
|
344
|
-
telemetryService: ITelemetryService,
|
|
345
|
-
domainService: IDomainService,
|
|
346
|
-
capiClientService: ICAPIClientService,
|
|
347
|
-
endpointOrUrl: IEndpoint | string | RequestMetadata,
|
|
348
|
-
secretKey: string,
|
|
349
|
-
hmac: string | undefined,
|
|
350
|
-
intent: string,
|
|
351
|
-
requestId: string,
|
|
352
|
-
body?: IEndpointBody,
|
|
353
|
-
additionalHeaders?: Record<string, string>,
|
|
354
|
-
cancelToken?: CancellationToken
|
|
355
|
-
): Promise<Response> {
|
|
356
|
-
return networkRequest(fetcherService,
|
|
357
|
-
envService,
|
|
358
|
-
telemetryService,
|
|
359
|
-
domainService,
|
|
360
|
-
capiClientService,
|
|
361
|
-
'POST',
|
|
362
|
-
endpointOrUrl,
|
|
363
|
-
secretKey,
|
|
364
|
-
hmac,
|
|
365
|
-
intent,
|
|
366
|
-
requestId,
|
|
367
|
-
body,
|
|
368
|
-
additionalHeaders,
|
|
369
|
-
cancelToken
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
export function getRequest(
|
|
374
|
-
fetcherService: IFetcher,
|
|
375
|
-
envService: IEnvService,
|
|
376
|
-
telemetryService: ITelemetryService,
|
|
377
|
-
domainService: IDomainService,
|
|
378
|
-
capiClientService: ICAPIClientService,
|
|
379
|
-
endpointOrUrl: IEndpoint | string | RequestMetadata,
|
|
380
|
-
secretKey: string,
|
|
381
|
-
hmac: string | undefined,
|
|
382
|
-
intent: string,
|
|
383
|
-
requestId: string,
|
|
384
|
-
body?: IEndpointBody,
|
|
385
|
-
additionalHeaders?: Record<string, string>,
|
|
386
|
-
cancelToken?: CancellationToken
|
|
387
|
-
): Promise<Response> {
|
|
388
|
-
return networkRequest(fetcherService,
|
|
389
|
-
envService,
|
|
390
|
-
telemetryService,
|
|
391
|
-
domainService,
|
|
392
|
-
capiClientService,
|
|
393
|
-
'GET',
|
|
394
|
-
endpointOrUrl,
|
|
395
|
-
secretKey,
|
|
396
|
-
hmac,
|
|
397
|
-
intent,
|
|
398
|
-
requestId,
|
|
399
|
-
body,
|
|
400
|
-
additionalHeaders,
|
|
401
|
-
cancelToken
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
export const IHeaderContributors = createServiceIdentifier<HeaderContributors>('headerContributors');
|
|
406
|
-
|
|
407
|
-
export interface IHeaderContributors {
|
|
408
|
-
readonly _serviceBrand: undefined;
|
|
409
|
-
add(contributor: HeaderContributor): void;
|
|
410
|
-
remove(contributor: HeaderContributor): void;
|
|
411
|
-
contributeHeaders(headers: ReqHeaders): void;
|
|
412
|
-
size(): number;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
export class HeaderContributors implements IHeaderContributors {
|
|
416
|
-
declare readonly _serviceBrand: undefined;
|
|
417
|
-
private readonly contributors: HeaderContributor[] = [];
|
|
418
|
-
|
|
419
|
-
add(contributor: HeaderContributor) {
|
|
420
|
-
this.contributors.push(contributor);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
remove(contributor: HeaderContributor) {
|
|
424
|
-
const index = this.contributors.indexOf(contributor);
|
|
425
|
-
|
|
426
|
-
if (index === -1) {
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
this.contributors.splice(index, 1);
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
contributeHeaders(headers: ReqHeaders) {
|
|
434
|
-
for (const contributor of this.contributors) {
|
|
435
|
-
contributor.contributeHeaderValues(headers);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
size() {
|
|
440
|
-
return this.contributors.length;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
|
|
6
|
-
import { OpenAI, OutputMode, Raw, toMode } from '@vscode/prompt-tsx';
|
|
7
|
-
import { ChatCompletionContentPartKind } from '@vscode/prompt-tsx/dist/base/output/rawTypes';
|
|
8
|
-
import { rawPartAsThinkingData } from '../../endpoint/common/thinkingDataContainer';
|
|
9
|
-
import { TelemetryData } from '../../telemetry/common/telemetryData';
|
|
10
|
-
import { ThinkingData, ThinkingDataInMessage } from '../../thinking/common/thinking';
|
|
11
|
-
import { ICopilotReference, RequestId } from './fetch';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* How the logprobs field looks in the OpenAI API chunks.
|
|
15
|
-
*/
|
|
16
|
-
export interface APILogprobs {
|
|
17
|
-
text_offset: number[];
|
|
18
|
-
token_logprobs: number[];
|
|
19
|
-
top_logprobs?: { [key: string]: number }[];
|
|
20
|
-
tokens: string[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Usage statistics for the completion request.
|
|
25
|
-
*/
|
|
26
|
-
export interface APIUsage {
|
|
27
|
-
/**
|
|
28
|
-
* Number of tokens in the prompt.
|
|
29
|
-
*/
|
|
30
|
-
prompt_tokens: number;
|
|
31
|
-
/**
|
|
32
|
-
* Number of tokens in the generated completion.
|
|
33
|
-
*/
|
|
34
|
-
completion_tokens: number;
|
|
35
|
-
/**
|
|
36
|
-
* Total number of tokens used in the request (prompt + completion).
|
|
37
|
-
*/
|
|
38
|
-
total_tokens: number;
|
|
39
|
-
/**
|
|
40
|
-
* Breakdown of tokens used in the prompt.
|
|
41
|
-
*/
|
|
42
|
-
prompt_tokens_details?: {
|
|
43
|
-
cached_tokens: number;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Breakdown of tokens used in a completion.
|
|
47
|
-
*
|
|
48
|
-
* @remark it's an optional field because Copilot Proxy returns this information but not CAPI as of 18 Jun 2025
|
|
49
|
-
*/
|
|
50
|
-
completion_tokens_details?: {
|
|
51
|
-
/**
|
|
52
|
-
* Tokens generated by the model for reasoning.
|
|
53
|
-
*/
|
|
54
|
-
reasoning_tokens: number;
|
|
55
|
-
/**
|
|
56
|
-
* When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
|
|
57
|
-
*/
|
|
58
|
-
accepted_prediction_tokens: number;
|
|
59
|
-
/**
|
|
60
|
-
* When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion.
|
|
61
|
-
* However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing,
|
|
62
|
-
* output, and context window limits.
|
|
63
|
-
*/
|
|
64
|
-
rejected_prediction_tokens: number;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function isApiUsage(obj: unknown): obj is APIUsage {
|
|
69
|
-
return typeof (obj as APIUsage).prompt_tokens === 'number' &&
|
|
70
|
-
typeof (obj as APIUsage).completion_tokens === 'number' &&
|
|
71
|
-
typeof (obj as APIUsage).total_tokens === 'number';
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
export interface APIJsonData {
|
|
76
|
-
text: string;
|
|
77
|
-
/* Joining this together produces `text`, due to the way the proxy works. */
|
|
78
|
-
tokens: readonly string[];
|
|
79
|
-
/* These are only generated in certain situations. */
|
|
80
|
-
logprobs?: APILogprobs;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface APIErrorResponse {
|
|
84
|
-
code: number;
|
|
85
|
-
message: string;
|
|
86
|
-
metadata?: Record<string, any>;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export enum ChatRole {
|
|
91
|
-
System = 'system',
|
|
92
|
-
User = 'user',
|
|
93
|
-
Assistant = 'assistant',
|
|
94
|
-
Function = 'function',
|
|
95
|
-
Tool = 'tool'
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
export type CAPIChatMessage = OpenAI.ChatMessage & {
|
|
100
|
-
/**
|
|
101
|
-
* CAPI references used in this message.
|
|
102
|
-
*/
|
|
103
|
-
copilot_references?: ICopilotReference[];
|
|
104
|
-
/**
|
|
105
|
-
* CAPI confirmations used in this message.
|
|
106
|
-
*/
|
|
107
|
-
copilot_confirmations?: { state: string; confirmation: any }[];
|
|
108
|
-
|
|
109
|
-
copilot_cache_control?: {
|
|
110
|
-
'type': 'ephemeral';
|
|
111
|
-
};
|
|
112
|
-
} & ThinkingDataInMessage;
|
|
113
|
-
|
|
114
|
-
export function getCAPITextPart(content: string | OpenAI.ChatCompletionContentPart[] | OpenAI.ChatCompletionContentPart): string {
|
|
115
|
-
if (Array.isArray(content)) {
|
|
116
|
-
return content.map((part) => getCAPITextPart(part)).join('');
|
|
117
|
-
} else if (typeof content === 'string') {
|
|
118
|
-
return content;
|
|
119
|
-
} else if (typeof content === 'object' && 'text' in content) {
|
|
120
|
-
return content.text;
|
|
121
|
-
} else {
|
|
122
|
-
return '';
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export type RawMessageConversionCallback = (message: CAPIChatMessage, thinkingData?: ThinkingData) => void;
|
|
127
|
-
/**
|
|
128
|
-
* Converts a raw TSX chat message to CAPI's format.
|
|
129
|
-
*
|
|
130
|
-
* **Extra:** the raw message can have `copilot_references` and
|
|
131
|
-
* `copilot_confirmations` properties, which are copied to the CAPI message.
|
|
132
|
-
*/
|
|
133
|
-
export function rawMessageToCAPI(message: Raw.ChatMessage, callback?: RawMessageConversionCallback): CAPIChatMessage;
|
|
134
|
-
export function rawMessageToCAPI(message: Raw.ChatMessage[], callback?: RawMessageConversionCallback): CAPIChatMessage[];
|
|
135
|
-
export function rawMessageToCAPI(message: Raw.ChatMessage[] | Raw.ChatMessage, callback?: RawMessageConversionCallback): CAPIChatMessage | CAPIChatMessage[] {
|
|
136
|
-
if (Array.isArray(message)) {
|
|
137
|
-
return message.map(m => rawMessageToCAPI(m, callback));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const out: CAPIChatMessage = toMode(OutputMode.OpenAI, message);
|
|
141
|
-
if ('copilot_references' in message) {
|
|
142
|
-
out.copilot_references = (message as any).copilot_references;
|
|
143
|
-
}
|
|
144
|
-
if ('copilot_confirmations' in message) {
|
|
145
|
-
out.copilot_confirmations = (message as any).copilot_confirmations;
|
|
146
|
-
}
|
|
147
|
-
if (typeof out.content === 'string') {
|
|
148
|
-
out.content = out.content.trimEnd();
|
|
149
|
-
} else {
|
|
150
|
-
for (const part of out.content) {
|
|
151
|
-
if (part.type === 'text') {
|
|
152
|
-
part.text = part.text.trimEnd();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (message.content.find(part => part.type === ChatCompletionContentPartKind.CacheBreakpoint)) {
|
|
158
|
-
out.copilot_cache_control = { type: 'ephemeral' };
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
for (const content of message.content) {
|
|
162
|
-
if (content.type === Raw.ChatCompletionContentPartKind.Opaque) {
|
|
163
|
-
const data = rawPartAsThinkingData(content);
|
|
164
|
-
if (callback && data) {
|
|
165
|
-
callback(out, data);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return out;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export enum FinishedCompletionReason {
|
|
174
|
-
/**
|
|
175
|
-
* Reason generated by the server. See https://platform.openai.com/docs/guides/gpt/chat-completions-api
|
|
176
|
-
*/
|
|
177
|
-
Stop = 'stop',
|
|
178
|
-
/**
|
|
179
|
-
* Reason generated by the server. See https://platform.openai.com/docs/guides/gpt/chat-completions-api
|
|
180
|
-
*/
|
|
181
|
-
Length = 'length',
|
|
182
|
-
/**
|
|
183
|
-
* Reason generated by the server. See https://platform.openai.com/docs/guides/gpt/chat-completions-api
|
|
184
|
-
*/
|
|
185
|
-
FunctionCall = 'function_call',
|
|
186
|
-
/**
|
|
187
|
-
* Reason generated by the server. See https://platform.openai.com/docs/guides/gpt/chat-completions-api
|
|
188
|
-
*/
|
|
189
|
-
ToolCalls = 'tool_calls',
|
|
190
|
-
/**
|
|
191
|
-
* Reason generated by the server. See https://platform.openai.com/docs/guides/gpt/chat-completions-api
|
|
192
|
-
*/
|
|
193
|
-
ContentFilter = 'content_filter',
|
|
194
|
-
/**
|
|
195
|
-
* Reason generated by the server (CAPI). Happens when the stream cannot be completed and the server must terminate the response.
|
|
196
|
-
*/
|
|
197
|
-
ServerError = 'error',
|
|
198
|
-
/**
|
|
199
|
-
* Reason generated by the client when the finish callback asked for processing to stop.
|
|
200
|
-
*/
|
|
201
|
-
ClientTrimmed = 'client-trimmed',
|
|
202
|
-
/**
|
|
203
|
-
* Reason generated by the client when we never received a finish_reason for this particular completion (indicates a server-side bug)
|
|
204
|
-
*/
|
|
205
|
-
ClientIterationDone = 'Iteration Done',
|
|
206
|
-
/**
|
|
207
|
-
* Reason generated by the client when we never received a finish_reason for this particular completion (indicates a server-side bug)
|
|
208
|
-
*/
|
|
209
|
-
ClientDone = 'DONE',
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export interface IToolCall {
|
|
213
|
-
index: number;
|
|
214
|
-
id?: string;
|
|
215
|
-
function?: { name: string; arguments: string };
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Contains the possible reasons a response can be filtered
|
|
220
|
-
*/
|
|
221
|
-
export enum FilterReason {
|
|
222
|
-
/**
|
|
223
|
-
* Content deemed to be hateful
|
|
224
|
-
*/
|
|
225
|
-
Hate = 'hate',
|
|
226
|
-
/**
|
|
227
|
-
* Content deemed to cause self harm
|
|
228
|
-
*/
|
|
229
|
-
SelfHarm = 'self_harm',
|
|
230
|
-
/**
|
|
231
|
-
* Content deemed to be sexual in nature
|
|
232
|
-
*/
|
|
233
|
-
Sexual = 'sexual',
|
|
234
|
-
/**
|
|
235
|
-
* Content deemed to be violent in nature
|
|
236
|
-
*/
|
|
237
|
-
Violence = 'violence',
|
|
238
|
-
/**
|
|
239
|
-
* Content contains copyrighted material
|
|
240
|
-
*/
|
|
241
|
-
Copyright = 'snippy',
|
|
242
|
-
/**
|
|
243
|
-
* The prompt was filtered, the reason was not provided
|
|
244
|
-
*/
|
|
245
|
-
Prompt = 'prompt'
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export interface ChatCompletion {
|
|
249
|
-
message: Raw.ChatMessage;
|
|
250
|
-
choiceIndex: number;
|
|
251
|
-
requestId: RequestId;
|
|
252
|
-
tokens: readonly string[];
|
|
253
|
-
usage: APIUsage | undefined;
|
|
254
|
-
blockFinished: boolean; // Whether the block completion was determined to be finished
|
|
255
|
-
finishReason: FinishedCompletionReason;
|
|
256
|
-
filterReason?: FilterReason; // optional filter reason if the completion was filtered
|
|
257
|
-
telemetryData: TelemetryData; // optional telemetry data providing background
|
|
258
|
-
error?: APIErrorResponse; // optional, error was encountered during the response
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export interface ChoiceLogProbs {
|
|
262
|
-
content: ChoiceLogProbsContent[];
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export interface TokenLogProb {
|
|
266
|
-
bytes: number[];
|
|
267
|
-
token: string;
|
|
268
|
-
logprob: number;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export interface ChoiceLogProbsContent extends TokenLogProb {
|
|
272
|
-
top_logprobs: TokenLogProb[];
|
|
273
|
-
}
|