forked from ericc-ch/copilot-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
39 lines (30 loc) · 984 Bytes
/
utils.ts
File metadata and controls
39 lines (30 loc) · 984 Bytes
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
import consola from "consola"
import { getModels } from "~/services/copilot/get-models"
import { getVSCodeVersion } from "~/services/get-vscode-version"
import {
createLingmaModels,
parseLingmaModelIds,
} from "~/services/lingma/models"
import { state } from "./state"
export const sleep = (ms: number) =>
new Promise((resolve) => {
setTimeout(resolve, ms)
})
export const isNullish = (value: unknown): value is null | undefined =>
value === null || value === undefined
export async function cacheModels(): Promise<void> {
const models = await getModels()
state.models = models
}
export async function cacheProviderModels(): Promise<void> {
if (state.provider === "lingma") {
state.models = createLingmaModels(parseLingmaModelIds())
return
}
await cacheModels()
}
export const cacheVSCodeVersion = async () => {
const response = await getVSCodeVersion()
state.vsCodeVersion = response
consola.info(`Using VSCode version: ${response}`)
}