Skip to content

Commit f4e7962

Browse files
committed
Fixes from review
1 parent 2f6e831 commit f4e7962

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/api/providers/fetchers/litellm.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import axios from "axios"
2-
import { ModelRecord } from "../../../shared/api"
2+
import { COMPUTER_USE_MODELS, ModelRecord } from "../../../shared/api"
33

44
/**
55
* Fetches available models from a LiteLLM server
@@ -21,19 +21,25 @@ export async function getLiteLLMModels(apiKey: string, baseUrl: string): Promise
2121
const response = await axios.get(`${baseUrl}/v1/model/info`, { headers })
2222
const models: ModelRecord = {}
2323

24+
const computerModels = Array.from(COMPUTER_USE_MODELS)
25+
2426
// Process the model info from the response
2527
if (response.data && response.data.data && Array.isArray(response.data.data)) {
2628
for (const model of response.data.data) {
2729
const modelName = model.model_name
2830
const modelInfo = model.model_info
31+
const litellmModelName = model?.litellm_params?.model as string | undefined
2932

30-
if (!modelName || !modelInfo) continue
33+
if (!modelName || !modelInfo || !litellmModelName) continue
3134

3235
models[modelName] = {
3336
maxTokens: modelInfo.max_tokens || 8192,
3437
contextWindow: modelInfo.max_input_tokens || 200000,
3538
supportsImages: Boolean(modelInfo.supports_vision),
36-
supportsComputerUse: Boolean(modelInfo.supports_function_calling || modelInfo.supports_tool_choice),
39+
// litellm_params.model may have a prefix like openrouter/
40+
supportsComputerUse: computerModels.some((computer_model) =>
41+
litellmModelName.endsWith(computer_model),
42+
),
3743
supportsPromptCache: Boolean(modelInfo.supports_prompt_caching),
3844
inputPrice: modelInfo.input_cost_per_token ? modelInfo.input_cost_per_token * 1000000 : undefined,
3945
outputPrice: modelInfo.output_cost_per_token

src/api/providers/router-provider.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,7 @@ export abstract class RouterProvider extends BaseProvider {
4444
}
4545

4646
public async fetchModel() {
47-
// For LiteLLM, we need to pass the API key and base URL
48-
if (this.name === "litellm") {
49-
const apiKey = this.client.apiKey
50-
const baseUrl = this.client.baseURL
51-
this.models = await getModels(this.name, apiKey, baseUrl)
52-
} else {
53-
// For other routers, just pass the API key
54-
this.models = await getModels(this.name, this.client.apiKey)
55-
}
47+
this.models = await getModels(this.name, this.client.apiKey, this.client.baseURL)
5648
return this.getModel()
5749
}
5850

0 commit comments

Comments
 (0)