@@ -2,9 +2,10 @@ import { memo, useCallback, useMemo, useState } from "react"
22import { useDebounce , useEvent } from "react-use"
33import { Checkbox , Dropdown , Pane , type DropdownOption } from "vscrui"
44import { VSCodeLink , VSCodeRadio , VSCodeRadioGroup , VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
5- import { TemperatureControl } from "./TemperatureControl"
65import * as vscodemodels from "vscode"
76
7+ import { Slider } from "@/components/ui"
8+
89import {
910 ApiConfiguration ,
1011 ModelInfo ,
@@ -34,6 +35,7 @@ import {
3435 requestyDefaultModelInfo ,
3536} from "../../../../src/shared/api"
3637import { ExtensionMessage } from "../../../../src/shared/ExtensionMessage"
38+
3739import { vscode } from "../../utils/vscode"
3840import VSCodeButtonLink from "../common/VSCodeButtonLink"
3941import { OpenRouterModelPicker } from "./OpenRouterModelPicker"
@@ -43,7 +45,7 @@ import { UnboundModelPicker } from "./UnboundModelPicker"
4345import { ModelInfoView } from "./ModelInfoView"
4446import { DROPDOWN_Z_INDEX } from "./styles"
4547import { RequestyModelPicker } from "./RequestyModelPicker"
46- import { Slider } from "../ui "
48+ import { TemperatureControl } from "./TemperatureControl "
4749
4850interface ApiOptionsProps {
4951 uriScheme : string | undefined
@@ -66,8 +68,7 @@ const ApiOptions = ({
6668 const [ lmStudioModels , setLmStudioModels ] = useState < string [ ] > ( [ ] )
6769 const [ vsCodeLmModels , setVsCodeLmModels ] = useState < vscodemodels . LanguageModelChatSelector [ ] > ( [ ] )
6870 const [ anthropicBaseUrlSelected , setAnthropicBaseUrlSelected ] = useState ( ! ! apiConfiguration ?. anthropicBaseUrl )
69- const [ anthropicThinkingEnabled , setAnthropicThinkingEnabled ] = useState ( ! ! apiConfiguration ?. anthropicThinking )
70- const [ anthropicThinkingBudget , setAnthropicThinkingBudget ] = useState ( apiConfiguration ?. anthropicThinking ?? 1024 )
71+ const [ anthropicThinkingBudget , setAnthropicThinkingBudget ] = useState ( apiConfiguration ?. anthropicThinking )
7172 const [ azureApiVersionSelected , setAzureApiVersionSelected ] = useState ( ! ! apiConfiguration ?. azureApiVersion )
7273 const [ openRouterBaseUrlSelected , setOpenRouterBaseUrlSelected ] = useState ( ! ! apiConfiguration ?. openRouterBaseUrl )
7374 const [ isDescriptionExpanded , setIsDescriptionExpanded ] = useState ( false )
@@ -188,6 +189,7 @@ const ApiOptions = ({
188189 checked = { anthropicBaseUrlSelected }
189190 onChange = { ( checked : boolean ) => {
190191 setAnthropicBaseUrlSelected ( checked )
192+
191193 if ( ! checked ) {
192194 setApiConfigurationField ( "anthropicBaseUrl" , "" )
193195 }
@@ -387,6 +389,7 @@ const ApiOptions = ({
387389 checked = { openRouterBaseUrlSelected }
388390 onChange = { ( checked : boolean ) => {
389391 setOpenRouterBaseUrlSelected ( checked )
392+
390393 if ( ! checked ) {
391394 setApiConfigurationField ( "openRouterBaseUrl" , "" )
392395 }
@@ -510,7 +513,7 @@ const ApiOptions = ({
510513 </ div >
511514 ) }
512515
513- { apiConfiguration ?. apiProvider === "vertex" && (
516+ { selectedProvider === "vertex" && (
514517 < div style = { { display : "flex" , flexDirection : "column" , gap : 5 } } >
515518 < VSCodeTextField
516519 value = { apiConfiguration ?. vertexProjectId || "" }
@@ -624,6 +627,7 @@ const ApiOptions = ({
624627 checked = { azureApiVersionSelected }
625628 onChange = { ( checked : boolean ) => {
626629 setAzureApiVersionSelected ( checked )
630+
627631 if ( ! checked ) {
628632 setApiConfigurationField ( "azureApiVersion" , "" )
629633 }
@@ -1260,23 +1264,33 @@ const ApiOptions = ({
12601264 </ >
12611265 ) }
12621266
1263- { selectedProvider === "anthropic" && (
1267+ { selectedProvider === "anthropic" && selectedModelId === "claude-3-7-sonnet-20250219" && (
12641268 < div className = "flex flex-col gap-2 mt-2" >
1265- < Checkbox checked = { anthropicThinkingEnabled } onChange = { setAnthropicThinkingEnabled } >
1269+ < Checkbox
1270+ checked = { ! ! anthropicThinkingBudget }
1271+ onChange = { ( checked ) => {
1272+ const budget = checked ? 16_384 : undefined
1273+ setAnthropicThinkingBudget ( budget )
1274+ setApiConfigurationField ( "anthropicThinking" , budget )
1275+ } } >
12661276 Thinking?
12671277 </ Checkbox >
1268- { anthropicThinkingEnabled && (
1278+ { anthropicThinkingBudget && (
12691279 < >
12701280 < div className = "text-muted-foreground text-sm" >
1271- Number of tokens Claude is allowed use for its internal reasoning process
1281+ Number of tokens Claude is allowed use for its internal reasoning process.
12721282 </ div >
12731283 < div className = "flex items-center gap-2" >
12741284 < Slider
12751285 min = { 1024 }
1276- max = { 6399 }
1277- step = { 100 }
1286+ max = { anthropicModels [ "claude-3-7-sonnet-20250219" ] . maxTokens - 1 }
1287+ step = { 1024 }
12781288 value = { [ anthropicThinkingBudget ] }
1279- onValueChange = { ( value ) => setAnthropicThinkingBudget ( value [ 0 ] ) }
1289+ onValueChange = { ( value ) => {
1290+ const budget = value [ 0 ]
1291+ setAnthropicThinkingBudget ( budget )
1292+ setApiConfigurationField ( "anthropicThinking" , budget )
1293+ } }
12801294 />
12811295 < div className = "w-10" > { anthropicThinkingBudget } </ div >
12821296 </ div >
0 commit comments