Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/metal-suns-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"roo-code": patch
---

Bug fix for trailing slash error when using LiteLLM provider
20 changes: 20 additions & 0 deletions src/api/providers/fetchers/__tests__/litellm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ describe("getLiteLLMModels", () => {
jest.clearAllMocks()
})

it("handles base URLs with trailing slashes correctly", async () => {
const mockResponse = {
data: {
data: [],
},
}

mockedAxios.get.mockResolvedValue(mockResponse)

await getLiteLLMModels("test-api-key", "http://localhost:4000/")

expect(mockedAxios.get).toHaveBeenCalledWith("http://localhost:4000/v1/model/info", {
headers: {
Authorization: "Bearer test-api-key",
"Content-Type": "application/json",
},
timeout: 5000,
})
})

it("successfully fetches and formats LiteLLM models", async () => {
const mockResponse = {
data: {
Expand Down
4 changes: 3 additions & 1 deletion src/api/providers/fetchers/litellm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ export async function getLiteLLMModels(apiKey: string, baseUrl: string): Promise
if (apiKey) {
headers["Authorization"] = `Bearer ${apiKey}`
}
// Use URL constructor to properly join base URL and path
const url = new URL("/v1/model/info", baseUrl).href
// Added timeout to prevent indefinite hanging
const response = await axios.get(`${baseUrl}/v1/model/info`, { headers, timeout: 5000 })
const response = await axios.get(url, { headers, timeout: 5000 })
const models: ModelRecord = {}

const computerModels = Array.from(LITELLM_COMPUTER_USE_MODELS)
Expand Down
Loading