Skip to content

Commit 12b8d59

Browse files
kcwhiteKevin Whitedaniel-lxs
authored
Bug fix for trailing slash error when using LiteLLM provider (RooCodeInc#4275)
* Added changeset for my code changes * Use URL constructor for joining baseUrl and path in litellm.ts * Restoring Roo dotfiles * Moved Roo dotfiles to root directory * Revert this * Add tests for litellm URL constructor fix --------- Co-authored-by: Kevin White <[email protected]> Co-authored-by: Daniel <[email protected]> Co-authored-by: Daniel Riccio <[email protected]>
1 parent 52673b3 commit 12b8d59

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

.changeset/metal-suns-lay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-code": patch
3+
---
4+
5+
Bug fix for trailing slash error when using LiteLLM provider

src/api/providers/fetchers/__tests__/litellm.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ describe("getLiteLLMModels", () => {
1212
jest.clearAllMocks()
1313
})
1414

15+
it("handles base URLs with trailing slashes correctly", async () => {
16+
const mockResponse = {
17+
data: {
18+
data: [],
19+
},
20+
}
21+
22+
mockedAxios.get.mockResolvedValue(mockResponse)
23+
24+
await getLiteLLMModels("test-api-key", "http://localhost:4000/")
25+
26+
expect(mockedAxios.get).toHaveBeenCalledWith("http://localhost:4000/v1/model/info", {
27+
headers: {
28+
Authorization: "Bearer test-api-key",
29+
"Content-Type": "application/json",
30+
},
31+
timeout: 5000,
32+
})
33+
})
34+
1535
it("successfully fetches and formats LiteLLM models", async () => {
1636
const mockResponse = {
1737
data: {

src/api/providers/fetchers/litellm.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ export async function getLiteLLMModels(apiKey: string, baseUrl: string): Promise
2121
if (apiKey) {
2222
headers["Authorization"] = `Bearer ${apiKey}`
2323
}
24+
// Use URL constructor to properly join base URL and path
25+
const url = new URL("/v1/model/info", baseUrl).href
2426
// Added timeout to prevent indefinite hanging
25-
const response = await axios.get(`${baseUrl}/v1/model/info`, { headers, timeout: 5000 })
27+
const response = await axios.get(url, { headers, timeout: 5000 })
2628
const models: ModelRecord = {}
2729

2830
const computerModels = Array.from(LITELLM_COMPUTER_USE_MODELS)

0 commit comments

Comments
 (0)