fix: getunbound.ai may return null

This commit is contained in:
System233 2025-02-19 19:58:13 +08:00
parent 2d34cda0ea
commit b732005d23

View file

@ -2220,18 +2220,17 @@ export class ClineProvider implements vscode.WebviewViewProvider {
if (response.data) {
const rawModels: Record<string, any> = response.data
for (const [modelId, model] of Object.entries(rawModels)) {
models[modelId] = {
maxTokens: model.maxTokens ? parseInt(model.maxTokens) : undefined,
contextWindow: model.contextWindow ? parseInt(model.contextWindow) : 0,
supportsImages: model.supportsImages ?? false,
supportsPromptCache: model.supportsPromptCaching ?? false,
supportsComputerUse: model.supportsComputerUse ?? false,
inputPrice: model.inputTokenPrice ? parseFloat(model.inputTokenPrice) : undefined,
outputPrice: model.outputTokenPrice ? parseFloat(model.outputTokenPrice) : undefined,
cacheWritesPrice: model.cacheWritePrice ? parseFloat(model.cacheWritePrice) : undefined,
cacheReadsPrice: model.cacheReadPrice ? parseFloat(model.cacheReadPrice) : undefined,
maxTokens: model?.maxTokens ? parseInt(model.maxTokens) : undefined,
contextWindow: model?.contextWindow ? parseInt(model.contextWindow) : 0,
supportsImages: model?.supportsImages ?? false,
supportsPromptCache: model?.supportsPromptCaching ?? false,
supportsComputerUse: model?.supportsComputerUse ?? false,
inputPrice: model?.inputTokenPrice ? parseFloat(model.inputTokenPrice) : undefined,
outputPrice: model?.outputTokenPrice ? parseFloat(model.outputTokenPrice) : undefined,
cacheWritesPrice: model?.cacheWritePrice ? parseFloat(model.cacheWritePrice) : undefined,
cacheReadsPrice: model?.cacheReadPrice ? parseFloat(model.cacheReadPrice) : undefined,
}
}
}