mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-07 02:58:15 +00:00
Bug fix for trailing slash error when using LiteLLM provider (#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 <kcwhite@ancestry.com> Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com> Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
This commit is contained in:
parent
52673b3721
commit
12b8d59562
3 changed files with 28 additions and 1 deletions
5
.changeset/metal-suns-lay.md
Normal file
5
.changeset/metal-suns-lay.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"roo-code": patch
|
||||
---
|
||||
|
||||
Bug fix for trailing slash error when using LiteLLM provider
|
||||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue