Skip to content

Commit 497afab

Browse files
committed
maps do support key type inference in loops
1 parent 2edb8b7 commit 497afab

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/services/ghost/GhostModel.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ApiHandler, buildApiHandler } from "../../api"
33
import { ProviderSettingsManager } from "../../core/config/ProviderSettingsManager"
44
import { OpenRouterHandler } from "../../api/providers"
55
import { ApiStreamChunk } from "../../api/transform/stream"
6-
import { AUTOCOMPLETE_PROVIDER_MODELS, checkKilocodeBalance } from "./utils/kilocode-utils"
6+
import { AUTOCOMPLETE_PROVIDER_MAP, AUTOCOMPLETE_PROVIDER_MODELS, checkKilocodeBalance } from "./utils/kilocode-utils"
77

88
export class GhostModel {
99
private apiHandler: ApiHandler | null = null
@@ -22,14 +22,11 @@ export class GhostModel {
2222

2323
public async reload(providerSettingsManager: ProviderSettingsManager): Promise<boolean> {
2424
const profiles = await providerSettingsManager.listConfig()
25-
const supportedProviders = Object.keys(AUTOCOMPLETE_PROVIDER_MODELS) as Array<
26-
keyof typeof AUTOCOMPLETE_PROVIDER_MODELS
27-
>
2825

2926
this.cleanup()
3027

3128
// Check providers in order, but skip unusable ones (e.g., kilocode with zero balance)
32-
for (const provider of supportedProviders) {
29+
for (const [provider, model] of AUTOCOMPLETE_PROVIDER_MAP) {
3330
const selectedProfile = profiles.find((x) => x?.apiProvider === provider)
3431
if (!selectedProfile) continue
3532

@@ -46,7 +43,7 @@ export class GhostModel {
4643

4744
this.apiHandler = buildApiHandler({
4845
...profile,
49-
[modelIdKeysByProvider[provider]]: AUTOCOMPLETE_PROVIDER_MODELS[provider],
46+
[modelIdKeysByProvider[provider]]: model,
5047
})
5148

5249
if (this.apiHandler instanceof OpenRouterHandler) {

src/services/ghost/utils/kilocode-utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,10 @@ export const AUTOCOMPLETE_PROVIDER_MODELS = {
4343
bedrock: "mistral.codestral-2508-v1:0",
4444
} as const
4545
export type AutocompleteProviderKey = keyof typeof AUTOCOMPLETE_PROVIDER_MODELS
46+
export const AUTOCOMPLETE_PROVIDER_MAP = new Map([
47+
["mistral", "codestral-latest"],
48+
["kilocode", "mistralai/codestral-2508"],
49+
["openrouter", "mistralai/codestral-2508"],
50+
["bedrock", "mistral.codestral-2508-v1:0"],
51+
] as const)
52+
export type AutocompleteProviderKey2 = typeof AUTOCOMPLETE_PROVIDER_MAP extends Map<infer K, any> ? K : never

0 commit comments

Comments
 (0)