forked from ericc-ch/copilot-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.ts
More file actions
45 lines (36 loc) · 1.23 KB
/
state.ts
File metadata and controls
45 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import type { ModelsResponse } from "~/services/copilot/get-models"
import type { Account, AccountPool, Strategy } from "./account-pool"
export type CopilotUpstreamEndpoint = "chat" | "responses"
export interface State {
pool?: AccountPool
strategy: Strategy
accountType: string
models?: ModelsResponse
vsCodeVersion?: string
manualApprove: boolean
rateLimitWait: boolean
showToken: boolean
// Rate limiting configuration
rateLimitSeconds?: number
lastRequestTimestamp?: number
/**
* Per-model memory of which Copilot upstream endpoint last succeeded.
* Some models (gpt-5*) only work on /responses; others only on
* /chat/completions. Once a model is observed to succeed on one endpoint,
* we keep using that endpoint for the rest of the process lifetime so
* we don't pay an extra failed round trip on every call.
*/
modelEndpointRoute: Map<string, CopilotUpstreamEndpoint>
}
export const state: State = {
accountType: "individual",
strategy: "round-robin",
manualApprove: false,
rateLimitWait: false,
showToken: false,
modelEndpointRoute: new Map(),
}
/** Convenience: the first usable account. */
export function defaultAccount(): Account | undefined {
return state.pool?.accounts[0]
}