Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/openai/node/fetch.ts
13401 views
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 { RequestId } from '../../networking/common/fetch';
7
import { ChatCompletion } from '../../networking/common/openai';
8
9
export enum FetchResponseKind {
10
Success = 'success',
11
Failed = 'failed',
12
Canceled = 'canceled',
13
}
14
15
export interface ChatResults {
16
type: FetchResponseKind.Success;
17
chatCompletions: AsyncIterable<ChatCompletion>;
18
}
19
20
export interface ChatRequestFailed {
21
type: FetchResponseKind.Failed;
22
modelRequestId: RequestId | undefined;
23
failKind: ChatFailKind;
24
reason: string;
25
data?: Record<string, any>;
26
}
27
28
export interface ChatRequestCanceled {
29
type: FetchResponseKind.Canceled;
30
reason: string;
31
}
32
33
export enum ChatFailKind {
34
OffTopic = 'offTopic',
35
TokenExpiredOrInvalid = 'tokenExpiredOrInvalid',
36
ServerCanceled = 'serverCanceled',
37
ClientNotSupported = 'clientNotSupported',
38
RateLimited = 'rateLimited',
39
QuotaExceeded = 'quotaExceeded',
40
ExtensionBlocked = 'extensionBlocked',
41
ServerError = 'serverError',
42
ContentFilter = 'contentFilter',
43
AgentUnauthorized = 'unauthorized',
44
AgentFailedDependency = 'failedDependency',
45
ValidationFailed = 'validationFailed',
46
InvalidPreviousResponseId = 'invalidPreviousResponseId',
47
NotFound = 'notFound',
48
Unknown = 'unknown',
49
}
50
51