Skip to content

Commit da6c50b

Browse files
authored
Organize provider settings into separate components (#3196)
1 parent 883be32 commit da6c50b

File tree

16 files changed

+1552
-1185
lines changed

16 files changed

+1552
-1185
lines changed

.changeset/five-pigs-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Organize provider settings into separate components

src/api/providers/__tests__/chutes.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ describe("ChutesHandler", () => {
1919
beforeEach(() => {
2020
jest.clearAllMocks()
2121
mockCreate = (OpenAI as unknown as jest.Mock)().chat.completions.create
22-
handler = new ChutesHandler({})
22+
handler = new ChutesHandler({ chutesApiKey: "test-chutes-api-key" })
2323
})
2424

2525
test("should use the correct Chutes base URL", () => {
26-
new ChutesHandler({})
26+
new ChutesHandler({ chutesApiKey: "test-chutes-api-key" })
2727
expect(OpenAI).toHaveBeenCalledWith(expect.objectContaining({ baseURL: "https://llm.chutes.ai/v1" }))
2828
})
2929

@@ -41,9 +41,8 @@ describe("ChutesHandler", () => {
4141

4242
test("should return specified model when valid model is provided", () => {
4343
const testModelId: ChutesModelId = "deepseek-ai/DeepSeek-R1"
44-
const handlerWithModel = new ChutesHandler({ apiModelId: testModelId })
44+
const handlerWithModel = new ChutesHandler({ apiModelId: testModelId, chutesApiKey: "test-chutes-api-key" })
4545
const model = handlerWithModel.getModel()
46-
4746
expect(model.id).toBe(testModelId)
4847
expect(model.info).toEqual(chutesModels[testModelId])
4948
})
@@ -110,7 +109,7 @@ describe("ChutesHandler", () => {
110109
test("createMessage should pass correct parameters to Chutes client", async () => {
111110
const modelId: ChutesModelId = "deepseek-ai/DeepSeek-R1"
112111
const modelInfo = chutesModels[modelId]
113-
const handlerWithModel = new ChutesHandler({ apiModelId: modelId })
112+
const handlerWithModel = new ChutesHandler({ apiModelId: modelId, chutesApiKey: "test-chutes-api-key" })
114113

115114
mockCreate.mockImplementationOnce(() => {
116115
return {

src/api/providers/__tests__/groq.test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ describe("GroqHandler", () => {
1919
beforeEach(() => {
2020
jest.clearAllMocks()
2121
mockCreate = (OpenAI as unknown as jest.Mock)().chat.completions.create
22-
handler = new GroqHandler({})
22+
handler = new GroqHandler({ groqApiKey: "test-groq-api-key" })
2323
})
2424

2525
test("should use the correct Groq base URL", () => {
26-
new GroqHandler({})
26+
new GroqHandler({ groqApiKey: "test-groq-api-key" })
2727
expect(OpenAI).toHaveBeenCalledWith(expect.objectContaining({ baseURL: "https://api.groq.com/openai/v1" }))
2828
})
2929

@@ -35,17 +35,16 @@ describe("GroqHandler", () => {
3535

3636
test("should return default model when no model is specified", () => {
3737
const model = handler.getModel()
38-
expect(model.id).toBe(groqDefaultModelId) // Use groqDefaultModelId
39-
expect(model.info).toEqual(groqModels[groqDefaultModelId]) // Use groqModels
38+
expect(model.id).toBe(groqDefaultModelId)
39+
expect(model.info).toEqual(groqModels[groqDefaultModelId])
4040
})
4141

4242
test("should return specified model when valid model is provided", () => {
43-
const testModelId: GroqModelId = "llama-3.3-70b-versatile" // Use a valid Groq model ID and type
44-
const handlerWithModel = new GroqHandler({ apiModelId: testModelId }) // Instantiate GroqHandler
43+
const testModelId: GroqModelId = "llama-3.3-70b-versatile"
44+
const handlerWithModel = new GroqHandler({ apiModelId: testModelId, groqApiKey: "test-groq-api-key" })
4545
const model = handlerWithModel.getModel()
46-
4746
expect(model.id).toBe(testModelId)
48-
expect(model.info).toEqual(groqModels[testModelId]) // Use groqModels
47+
expect(model.info).toEqual(groqModels[testModelId])
4948
})
5049

5150
test("completePrompt method should return text from Groq API", async () => {
@@ -110,7 +109,7 @@ describe("GroqHandler", () => {
110109
test("createMessage should pass correct parameters to Groq client", async () => {
111110
const modelId: GroqModelId = "llama-3.1-8b-instant"
112111
const modelInfo = groqModels[modelId]
113-
const handlerWithModel = new GroqHandler({ apiModelId: modelId })
112+
const handlerWithModel = new GroqHandler({ apiModelId: modelId, groqApiKey: "test-groq-api-key" })
114113

115114
mockCreate.mockImplementationOnce(() => {
116115
return {

0 commit comments

Comments
 (0)