import { VSBuffer } from "../../../../base/common/buffer.js"; import { CancellationToken } from "../../../../base/common/cancellation.js"; import { IStringDictionary } from "../../../../base/common/collections.js"; import { Event } from "../../../../base/common/event.js"; import { TypeFromJsonSchema } from "../../../../base/common/jsonSchema.js"; import { IDisposable } from "../../../../base/common/lifecycle.js"; import { IObservable } from "../../../../base/common/observable.js"; import Severity from "../../../../base/common/severity.js"; import { ThemeIcon } from "../../../../base/common/themables.js"; import { URI } from "../../../../base/common/uri.js"; import { IContextKeyService } from "../../../../platform/contextkey/common/contextkey.service.js"; import { ExtensionIdentifier } from "../../../../platform/extensions/common/extensions.js"; import { ILogService } from "../../../../platform/log/common/log.service.js"; import { IProductService } from "../../../../platform/product/common/productService.service.js"; import { IRequestService } from "../../../../platform/request/common/request.service.js"; import { IQuickInputService } from "../../../../platform/quickinput/common/quickInput.service.js"; import { ISecretStorageService } from "../../../../platform/secrets/common/secrets.service.js"; import { IStorageService } from "../../../../platform/storage/common/storage.service.js"; import { IExtensionService } from "../../../services/extensions/common/extensions.service.js"; import { ChatAgentLocation } from "./constants.js"; import { ILanguageModelsProviderGroup } from "./languageModelsConfiguration.js"; import { ILanguageModelsConfigurationService } from "./languageModelsConfiguration.service.js"; import { ILanguageModelsService } from "./languageModels.service.js"; export declare enum ChatMessageRole { System = 0, User = 1, Assistant = 2 } export declare enum LanguageModelPartAudience { Assistant = 0, User = 1, Extension = 2 } export interface IChatMessageTextPart { type: "text"; value: string; audience?: LanguageModelPartAudience[]; } export interface IChatMessageImagePart { type: "image_url"; value: IChatImageURLPart; } export interface IChatMessageThinkingPart { type: "thinking"; value: string | string[]; id?: string; metadata?: { readonly [key: string]: any; }; } export interface IChatMessageDataPart { type: "data"; mimeType: string; data: VSBuffer; audience?: LanguageModelPartAudience[]; } export interface IChatImageURLPart { /** * The image's MIME type (e.g., "image/png", "image/jpeg"). */ mimeType: ChatImageMimeType; /** * The raw binary data of the image, encoded as a Uint8Array. Note: do not use base64 encoding. Maximum image size is 5MB. */ data: VSBuffer; } /** * Enum for supported image MIME types. */ export declare enum ChatImageMimeType { PNG = "image/png", JPEG = "image/jpeg", GIF = "image/gif", WEBP = "image/webp", BMP = "image/bmp" } /** * Specifies the detail level of the image. */ export declare enum ImageDetailLevel { Low = "low", High = "high" } export interface IChatMessageToolResultPart { type: "tool_result"; toolCallId: string; value: (IChatResponseTextPart | IChatResponsePromptTsxPart | IChatResponseDataPart)[]; isError?: boolean; } export type IChatMessagePart = IChatMessageTextPart | IChatMessageToolResultPart | IChatResponseToolUsePart | IChatMessageImagePart | IChatMessageDataPart | IChatMessageThinkingPart; export interface IChatMessage { readonly name?: string | undefined; readonly role: ChatMessageRole; readonly content: IChatMessagePart[]; } export interface IChatResponseTextPart { type: "text"; value: string; audience?: LanguageModelPartAudience[]; } export interface IChatResponsePromptTsxPart { type: "prompt_tsx"; value: unknown; } export interface IChatResponseDataPart { type: "data"; mimeType: string; data: VSBuffer; audience?: LanguageModelPartAudience[]; } export interface IChatResponseToolUsePart { type: "tool_use"; name: string; toolCallId: string; parameters: any; } export interface IChatResponseThinkingPart { type: "thinking"; value: string | string[]; id?: string; metadata?: { readonly [key: string]: any; }; } export interface IChatResponsePullRequestPart { type: "pullRequest"; uri: URI; title: string; description: string; author: string; linkTag: string; } export type IChatResponsePart = IChatResponseTextPart | IChatResponseToolUsePart | IChatResponseDataPart | IChatResponseThinkingPart; export type IExtendedChatResponsePart = IChatResponsePullRequestPart; export interface ILanguageModelChatMetadata { readonly extension: ExtensionIdentifier; readonly name: string; readonly id: string; readonly vendor: string; readonly version: string; readonly tooltip?: string; readonly detail?: string; readonly multiplier?: string; readonly multiplierNumeric?: number; readonly family: string; readonly maxInputTokens: number; readonly maxOutputTokens: number; readonly isDefaultForLocation: { [K in ChatAgentLocation]?: boolean; }; readonly isUserSelectable?: boolean; readonly statusIcon?: ThemeIcon; readonly modelPickerCategory: { label: string; order: number; } | undefined; readonly auth?: { readonly providerLabel: string; readonly accountLabel?: string; }; readonly capabilities?: { readonly vision?: boolean; readonly toolCalling?: boolean; readonly agentMode?: boolean; readonly editTools?: ReadonlyArray; }; /** * When set, this model is only shown in the model picker for the specified chat session type. * Models with this property are excluded from the general model picker and only appear * when the user is in a session matching this type. */ readonly targetChatSessionType?: string; } export declare namespace ILanguageModelChatMetadata { function suitableForAgentMode(metadata: ILanguageModelChatMetadata): boolean; function asQualifiedName(metadata: ILanguageModelChatMetadata): string; function matchesQualifiedName(name: string, metadata: ILanguageModelChatMetadata): boolean; } export interface ILanguageModelChatResponse { stream: AsyncIterable; result: Promise; } export declare function getTextResponseFromStream(response: ILanguageModelChatResponse): Promise; export interface ILanguageModelChatProvider { readonly onDidChange: Event; provideLanguageModelChatInfo(options: ILanguageModelChatInfoOptions, token: CancellationToken): Promise; sendChatRequest(modelId: string, messages: IChatMessage[], from: ExtensionIdentifier | undefined, options: { [name: string]: unknown; }, token: CancellationToken): Promise; provideTokenCount(modelId: string, message: string | IChatMessage, token: CancellationToken): Promise; } export interface ILanguageModelChat { metadata: ILanguageModelChatMetadata; sendChatRequest(messages: IChatMessage[], from: ExtensionIdentifier | undefined, options: { [name: string]: unknown; }, token: CancellationToken): Promise; provideTokenCount(message: string | IChatMessage, token: CancellationToken): Promise; } export interface ILanguageModelChatSelector { readonly name?: string; readonly id?: string; readonly vendor?: string; readonly version?: string; readonly family?: string; readonly tokens?: number; readonly extension?: ExtensionIdentifier; } export declare function isILanguageModelChatSelector(value: unknown): value is ILanguageModelChatSelector; export interface ILanguageModelChatMetadataAndIdentifier { metadata: ILanguageModelChatMetadata; identifier: string; } export interface ILanguageModelChatInfoOptions { readonly group?: string; readonly silent: boolean; readonly configuration?: IStringDictionary; } export interface ILanguageModelsGroup { readonly group?: ILanguageModelsProviderGroup; readonly modelIdentifiers: string[]; readonly status?: { readonly message: string; readonly severity: Severity; }; } export interface IModelControlEntry { readonly label: string; readonly featured?: boolean; readonly minVSCodeVersion?: string; readonly exists: boolean; } export interface IModelsControlManifest { readonly free: IStringDictionary; readonly paid: IStringDictionary; } declare const languageModelChatProviderType: { readonly type: "object"; readonly required: [ "vendor", "displayName" ]; readonly properties: { readonly vendor: { readonly type: "string"; readonly description: string; }; readonly displayName: { readonly type: "string"; readonly description: string; }; readonly configuration: { readonly type: "object"; readonly description: string; readonly anyOf: [ { readonly $ref: "http://json-schema.org/draft-07/schema#"; }, { readonly properties: { readonly properties: { readonly type: "object"; readonly additionalProperties: { readonly $ref: "http://json-schema.org/draft-07/schema#"; readonly properties: { readonly secret: { readonly type: "boolean"; readonly description: string; }; }; }; }; readonly additionalProperties: { readonly $ref: "http://json-schema.org/draft-07/schema#"; readonly properties: { readonly secret: { readonly type: "boolean"; readonly description: string; }; }; }; }; } ]; }; readonly managementCommand: { readonly type: "string"; readonly description: string; readonly deprecated: true; readonly deprecationMessage: string; }; readonly when: { readonly type: "string"; readonly description: string; }; }; }; export type IUserFriendlyLanguageModel = TypeFromJsonSchema; export interface ILanguageModelProviderDescriptor extends IUserFriendlyLanguageModel { readonly isDefault: boolean; } export declare const languageModelChatProviderExtensionPoint: import("../../../services/extensions/common/extensionsRegistry.js").IExtensionPoint<{ readonly vendor: string; readonly displayName: string; readonly configuration: undefined; readonly managementCommand: string | undefined; readonly when: string | undefined; } | { readonly vendor: string; readonly displayName: string; readonly configuration: undefined; readonly managementCommand: string | undefined; readonly when: string | undefined; }[]>; export declare class LanguageModelsService implements ILanguageModelsService { private readonly _extensionService; private readonly _logService; private readonly _storageService; private readonly _contextKeyService; private readonly _languageModelsConfigurationService; private readonly _quickInputService; private readonly _secretStorageService; private readonly _productService; private readonly _requestService; private static SECRET_KEY_PREFIX; private static SECRET_INPUT; readonly _serviceBrand: undefined; private readonly _store; private readonly _providers; private readonly _vendors; private readonly _onDidChangeLanguageModelVendors; readonly onDidChangeLanguageModelVendors: Event; private readonly _modelsGroups; private readonly _modelCache; private readonly _resolveLMSequencer; private _modelPickerUserPreferences; private readonly _hasUserSelectableModels; private readonly _onLanguageModelChange; readonly onDidChangeLanguageModels: Event; private _recentlyUsedModelIds; private readonly _onDidChangeModelsControlManifest; readonly onDidChangeModelsControlManifest: Event; private _modelsControlManifest; private _modelsControlRawResponse; private _chatControlUrl; private _chatControlDisposed; private readonly _restrictedChatParticipants; readonly restrictedChatParticipants: IObservable<{ [name: string]: string[]; }>; constructor(_extensionService: IExtensionService, _logService: ILogService, _storageService: IStorageService, _contextKeyService: IContextKeyService, _languageModelsConfigurationService: ILanguageModelsConfigurationService, _quickInputService: IQuickInputService, _secretStorageService: ISecretStorageService, _productService: IProductService, _requestService: IRequestService); deltaLanguageModelChatProviderDescriptors(added: IUserFriendlyLanguageModel[], removed: IUserFriendlyLanguageModel[]): void; private _onDidChangeLanguageModelGroups; private _readModelPickerPreferences; private _onDidChangeModelPickerPreferences; private _hasStoredModelForVendor; private _saveModelPickerPreferences; updateModelPickerPreference(modelIdentifier: string, showInModelPicker: boolean): void; getVendors(): ILanguageModelProviderDescriptor[]; getLanguageModelIds(): string[]; lookupLanguageModel(modelIdentifier: string): ILanguageModelChatMetadata | undefined; lookupLanguageModelByQualifiedName(referenceName: string): ILanguageModelChatMetadataAndIdentifier | undefined; private _resolveAllLanguageModels; getLanguageModelGroups(vendor: string): ILanguageModelsGroup[]; selectLanguageModels(selector: ILanguageModelChatSelector): Promise; registerLanguageModelProvider(vendor: string, provider: ILanguageModelChatProvider): IDisposable; sendChatRequest(modelId: string, from: ExtensionIdentifier | undefined, messages: IChatMessage[], options: { [name: string]: any; }, token: CancellationToken): Promise; computeTokenLength(modelId: string, message: string | IChatMessage, token: CancellationToken): Promise; configureLanguageModelsProviderGroup(vendorId: string, providerGroupName?: string): Promise; addLanguageModelsProviderGroup(name: string, vendorId: string, configuration: IStringDictionary | undefined): Promise; removeLanguageModelsProviderGroup(vendorId: string, providerGroupName: string): Promise; private requireConfiguring; private getSnippetForFirstUnconfiguredProperty; private promptForName; private promptForConfiguration; private promptForValue; private canPromptForProperty; private promptForArray; private promptForInput; private encodeSecretKey; private decodeSecretKey; private _clearModelCache; private _resolveConfiguration; private _resolveLanguageModelProviderGroup; private _deleteSecretsInConfiguration; migrateLanguageModelsProviderGroup(languageModelsProviderGroup: ILanguageModelsProviderGroup): Promise; private _readRecentlyUsedModels; private _saveRecentlyUsedModels; getRecentlyUsedModelIds(): string[]; addToRecentlyUsedList(modelIdentifier: string): void; clearRecentlyUsedList(): void; getModelsControlManifest(): IModelsControlManifest; private _setModelsControlManifest; private _refreshModelsControlManifest; private _modelExistsInCache; private _initChatControlData; private _refreshChatControlData; private _fetchChatControlData; dispose(): void; } export {};