|
@@ -7,18 +7,38 @@ import type { ModelInfo } from "@roo-code/types"
|
|
|
import { ThinkingBudget } from "../ThinkingBudget"
|
|
import { ThinkingBudget } from "../ThinkingBudget"
|
|
|
|
|
|
|
|
vi.mock("@/components/ui", () => ({
|
|
vi.mock("@/components/ui", () => ({
|
|
|
- Slider: ({ value, onValueChange, min, max }: any) => (
|
|
|
|
|
|
|
+ Slider: ({ value, onValueChange, min, max, step }: any) => (
|
|
|
<input
|
|
<input
|
|
|
type="range"
|
|
type="range"
|
|
|
data-testid="slider"
|
|
data-testid="slider"
|
|
|
min={min}
|
|
min={min}
|
|
|
max={max}
|
|
max={max}
|
|
|
|
|
+ step={step}
|
|
|
value={value[0]}
|
|
value={value[0]}
|
|
|
onChange={(e) => onValueChange([parseInt(e.target.value)])}
|
|
onChange={(e) => onValueChange([parseInt(e.target.value)])}
|
|
|
/>
|
|
/>
|
|
|
),
|
|
),
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
|
|
+vi.mock("@/components/ui/hooks/useSelectedModel", () => ({
|
|
|
|
|
+ useSelectedModel: (apiConfiguration: any) => {
|
|
|
|
|
+ // Return the model ID based on apiConfiguration for testing
|
|
|
|
|
+ // For Gemini tests, check if apiProvider is gemini and use apiModelId
|
|
|
|
|
+ if (apiConfiguration?.apiProvider === "gemini") {
|
|
|
|
|
+ return {
|
|
|
|
|
+ id: apiConfiguration?.apiModelId || "gemini-2.0-flash-exp",
|
|
|
|
|
+ provider: "gemini",
|
|
|
|
|
+ info: undefined,
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return {
|
|
|
|
|
+ id: apiConfiguration?.apiModelId || "claude-3-5-sonnet-20241022",
|
|
|
|
|
+ provider: apiConfiguration?.apiProvider || "anthropic",
|
|
|
|
|
+ info: undefined,
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+}))
|
|
|
|
|
+
|
|
|
describe("ThinkingBudget", () => {
|
|
describe("ThinkingBudget", () => {
|
|
|
const mockModelInfo: ModelInfo = {
|
|
const mockModelInfo: ModelInfo = {
|
|
|
supportsReasoningBudget: true,
|
|
supportsReasoningBudget: true,
|
|
@@ -103,13 +123,61 @@ describe("ThinkingBudget", () => {
|
|
|
expect(sliders[1]).toHaveValue("8000") // 80% of 10000
|
|
expect(sliders[1]).toHaveValue("8000") // 80% of 10000
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it("should use min thinking tokens of 1024", () => {
|
|
|
|
|
|
|
+ it("should use min thinking tokens of 1024 for non-Gemini models", () => {
|
|
|
render(<ThinkingBudget {...defaultProps} apiConfiguration={{ modelMaxTokens: 1000 }} />)
|
|
render(<ThinkingBudget {...defaultProps} apiConfiguration={{ modelMaxTokens: 1000 }} />)
|
|
|
|
|
|
|
|
const sliders = screen.getAllByTestId("slider")
|
|
const sliders = screen.getAllByTestId("slider")
|
|
|
expect(sliders[1].getAttribute("min")).toBe("1024")
|
|
expect(sliders[1].getAttribute("min")).toBe("1024")
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ it("should use min thinking tokens of 128 for Gemini 2.5 Pro models", () => {
|
|
|
|
|
+ render(
|
|
|
|
|
+ <ThinkingBudget
|
|
|
|
|
+ {...defaultProps}
|
|
|
|
|
+ apiConfiguration={{
|
|
|
|
|
+ modelMaxTokens: 10000,
|
|
|
|
|
+ apiProvider: "gemini",
|
|
|
|
|
+ apiModelId: "gemini-2.5-pro-002",
|
|
|
|
|
+ }}
|
|
|
|
|
+ />,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ const sliders = screen.getAllByTestId("slider")
|
|
|
|
|
+ expect(sliders[1].getAttribute("min")).toBe("128")
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it("should use step of 128 for Gemini 2.5 Pro models", () => {
|
|
|
|
|
+ render(
|
|
|
|
|
+ <ThinkingBudget
|
|
|
|
|
+ {...defaultProps}
|
|
|
|
|
+ apiConfiguration={{
|
|
|
|
|
+ modelMaxTokens: 10000,
|
|
|
|
|
+ apiProvider: "gemini",
|
|
|
|
|
+ apiModelId: "gemini-2.5-pro-002",
|
|
|
|
|
+ }}
|
|
|
|
|
+ />,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ const sliders = screen.getAllByTestId("slider")
|
|
|
|
|
+ expect(sliders[1].getAttribute("step")).toBe("128")
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it("should use step of 1024 for non-Gemini models", () => {
|
|
|
|
|
+ render(
|
|
|
|
|
+ <ThinkingBudget
|
|
|
|
|
+ {...defaultProps}
|
|
|
|
|
+ apiConfiguration={{
|
|
|
|
|
+ modelMaxTokens: 10000,
|
|
|
|
|
+ apiProvider: "anthropic",
|
|
|
|
|
+ apiModelId: "claude-3-5-sonnet-20241022",
|
|
|
|
|
+ }}
|
|
|
|
|
+ />,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ const sliders = screen.getAllByTestId("slider")
|
|
|
|
|
+ expect(sliders[1].getAttribute("step")).toBe("1024")
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
it("should update max tokens when slider changes", () => {
|
|
it("should update max tokens when slider changes", () => {
|
|
|
const setApiConfigurationField = vi.fn()
|
|
const setApiConfigurationField = vi.fn()
|
|
|
|
|
|