@@ -8,25 +8,30 @@ import {
88} from "@roo-code/types"
99
1010import type { ApiHandlerOptions } from "../../shared/api"
11+ import type { InternationalZAiModelId , MainlandZAiModelId , ModelInfo } from "@roo-code/types"
1112
1213import { BaseOpenAiCompatibleProvider } from "./base-openai-compatible-provider"
1314
14- export class ZAiHandler extends BaseOpenAiCompatibleProvider < string > {
15+ type ZAiModelId = InternationalZAiModelId | MainlandZAiModelId
16+
17+ export class ZAiHandler extends BaseOpenAiCompatibleProvider < ZAiModelId > {
1518 constructor ( options : ApiHandlerOptions ) {
16- const isChina = zaiApiLineConfigs [ options . zaiApiLine ?? "international_coding" ] . isChina
17- const models = ( isChina ? mainlandZAiModels : internationalZAiModels ) as Record <
18- string ,
19- import ( "@roo-code/types" ) . ModelInfo
19+ const line = options . zaiApiLine ?? "international_coding"
20+ const { isChina, baseUrl } = zaiApiLineConfigs [ line ]
21+
22+ const defaultModelId = isChina ? mainlandZAiDefaultModelId : internationalZAiDefaultModelId
23+ const providerModels = ( isChina ? mainlandZAiModels : internationalZAiModels ) as unknown as Record <
24+ ZAiModelId ,
25+ ModelInfo
2026 >
21- const defaultModelId = ( isChina ? mainlandZAiDefaultModelId : internationalZAiDefaultModelId ) as string
2227
2328 super ( {
2429 ...options ,
2530 providerName : "Z AI" ,
26- baseURL : zaiApiLineConfigs [ options . zaiApiLine ?? "international_coding" ] . baseUrl ,
31+ baseURL : baseUrl ,
2732 apiKey : options . zaiApiKey ?? "not-provided" ,
28- defaultProviderModelId : defaultModelId as any ,
29- providerModels : models as any ,
33+ defaultProviderModelId : defaultModelId ,
34+ providerModels,
3035 defaultTemperature : ZAI_DEFAULT_TEMPERATURE ,
3136 } )
3237 }
0 commit comments