import type { CancellationToken } from 'vscode';
import { ServicesAccessor } from '../../../util/vs/platform/instantiation/common/instantiation';
import { ChatLocation } from '../../chat/common/commonTypes';
import { FinishedCallback, OptionalChatRequestParams, RequestId } from '../../networking/common/fetch';
import { FetcherId } from '../../networking/common/fetcherService';
import { IChatEndpoint, IEndpointBody } from '../../networking/common/networking';
import { CAPIChatMessage, ChatCompletion } from '../../networking/common/openai';
import { TelemetryProperties } from '../../telemetry/common/telemetry';
import { TelemetryData } from '../../telemetry/common/telemetryData';
/** based on https://platform.openai.com/docs/api-reference/chat/create */
interface RequiredChatRequestParams {
    model: string;
    messages: CAPIChatMessage[];
}
interface CopilotOnlyParams {
    /** Copilot-only: names of experimental features to enable in the proxy. */
    feature_flags?: string[];
    /** Copilot-only: NWO of repository, if any */
    nwo?: string;
    copilot_thread_id?: string;
}
export interface ChatRequest extends RequiredChatRequestParams, OptionalChatRequestParams, CopilotOnlyParams {
}
export declare enum FetchResponseKind {
    Success = "success",
    Failed = "failed",
    Canceled = "canceled"
}
export interface ChatResults {
    type: FetchResponseKind.Success;
    chatCompletions: AsyncIterable<ChatCompletion>;
    getProcessingTime(): number;
}
export interface ChatRequestFailed {
    type: FetchResponseKind.Failed;
    modelRequestId: RequestId | undefined;
    failKind: ChatFailKind;
    reason: string;
    data?: Record<string, any>;
}
export interface ChatRequestCanceled {
    type: FetchResponseKind.Canceled;
    reason: string;
}
export declare enum ChatFailKind {
    OffTopic = "offTopic",
    TokenExpiredOrInvalid = "tokenExpiredOrInvalid",
    ServerCanceled = "serverCanceled",
    ClientNotSupported = "clientNotSupported",
    RateLimited = "rateLimited",
    QuotaExceeded = "quotaExceeded",
    ExtensionBlocked = "extensionBlocked",
    ServerError = "serverError",
    ContentFilter = "contentFilter",
    AgentUnauthorized = "unauthorized",
    AgentFailedDependency = "failedDependency",
    ValidationFailed = "validationFailed",
    InvalidPreviousResponseId = "invalidPreviousResponseId",
    NotFound = "notFound",
    Unknown = "unknown"
}
/**
 * A fetcher specialized to fetch ChatML completions. This differs from the standard fetcher in the form that ChatML
 * requires a different datamodel. Details can be found here https://platform.openai.com/docs/guides/chat
 *
 * This fetcher was created because the standard fetcher is tightly coupled to the OpenAI API completion models and a major refactoring
 * or rewrite is necessary to have a more generic fetcher that can be used for both completions and chat models.
 */
export declare function fetchAndStreamChat(accessor: ServicesAccessor, chatEndpointInfo: IChatEndpoint, request: IEndpointBody, baseTelemetryData: TelemetryData, finishedCb: FinishedCallback, secretKey: string | undefined, location: ChatLocation, ourRequestId: string, nChoices: number | undefined, userInitiatedRequest?: boolean, cancel?: CancellationToken | undefined, telemetryProperties?: TelemetryProperties | undefined, useFetcher?: FetcherId): Promise<ChatResults | ChatRequestFailed | ChatRequestCanceled>;
export {};
//# sourceMappingURL=fetch.d.ts.map