Change litellm config logic to accept supports_computer_use from litellm the updated /v1/model/info endpoint

This commit is contained in:
slytechnical 2025-05-16 01:29:57 -05:00
parent dc694efdb2
commit d7bed5e0ba

View file

@ -1,5 +1,5 @@
import axios from "axios"
import { COMPUTER_USE_MODELS, ModelRecord } from "../../../shared/api"
import { ModelRecord } from "../../../shared/api"
/**
* Fetches available models from a LiteLLM server
@ -21,8 +21,6 @@ export async function getLiteLLMModels(apiKey: string, baseUrl: string): Promise
const response = await axios.get(`${baseUrl}/v1/model/info`, { headers })
const models: ModelRecord = {}
const computerModels = Array.from(COMPUTER_USE_MODELS)
// Process the model info from the response
if (response.data && response.data.data && Array.isArray(response.data.data)) {
for (const model of response.data.data) {
@ -37,9 +35,7 @@ export async function getLiteLLMModels(apiKey: string, baseUrl: string): Promise
contextWindow: modelInfo.max_input_tokens || 200000,
supportsImages: Boolean(modelInfo.supports_vision),
// litellm_params.model may have a prefix like openrouter/
supportsComputerUse: computerModels.some((computer_model) =>
litellmModelName.endsWith(computer_model),
),
supportsComputerUse: Boolean(modelInfo.supports_computer_use),
supportsPromptCache: Boolean(modelInfo.supports_prompt_caching),
inputPrice: modelInfo.input_cost_per_token ? modelInfo.input_cost_per_token * 1000000 : undefined,
outputPrice: modelInfo.output_cost_per_token