@@ -68,15 +68,17 @@ const ApiOptions = ({
68
68
const [ lmStudioModels , setLmStudioModels ] = useState < string [ ] > ( [ ] )
69
69
const [ vsCodeLmModels , setVsCodeLmModels ] = useState < vscodemodels . LanguageModelChatSelector [ ] > ( [ ] )
70
70
const [ anthropicBaseUrlSelected , setAnthropicBaseUrlSelected ] = useState ( ! ! apiConfiguration ?. anthropicBaseUrl )
71
- const [ anthropicThinkingBudget , setAnthropicThinkingBudget ] = useState ( apiConfiguration ?. anthropicThinking )
72
71
const [ azureApiVersionSelected , setAzureApiVersionSelected ] = useState ( ! ! apiConfiguration ?. azureApiVersion )
73
72
const [ openRouterBaseUrlSelected , setOpenRouterBaseUrlSelected ] = useState ( ! ! apiConfiguration ?. openRouterBaseUrl )
74
73
const [ isDescriptionExpanded , setIsDescriptionExpanded ] = useState ( false )
75
74
76
- const inputEventTransform = < E , > ( event : E ) => ( event as { target : HTMLInputElement } ) ?. target ?. value as any
75
+ const anthropicThinkingBudget = apiConfiguration ?. anthropicThinking
76
+
77
77
const noTransform = < T , > ( value : T ) => value
78
+ const inputEventTransform = < E , > ( event : E ) => ( event as { target : HTMLInputElement } ) ?. target ?. value as any
78
79
const dropdownEventTransform = < T , > ( event : DropdownOption | string | undefined ) =>
79
80
( typeof event == "string" ? event : event ?. value ) as T
81
+
80
82
const handleInputChange = useCallback (
81
83
< K extends keyof ApiConfiguration , E > (
82
84
field : K ,
@@ -107,8 +109,10 @@ const ApiOptions = ({
107
109
250 ,
108
110
[ selectedProvider , apiConfiguration ?. ollamaBaseUrl , apiConfiguration ?. lmStudioBaseUrl ] ,
109
111
)
112
+
110
113
const handleMessage = useCallback ( ( event : MessageEvent ) => {
111
114
const message : ExtensionMessage = event . data
115
+
112
116
if ( message . type === "ollamaModels" && Array . isArray ( message . ollamaModels ) ) {
113
117
const newModels = message . ollamaModels
114
118
setOllamaModels ( newModels )
@@ -120,6 +124,7 @@ const ApiOptions = ({
120
124
setVsCodeLmModels ( newModels )
121
125
}
122
126
} , [ ] )
127
+
123
128
useEvent ( "message" , handleMessage )
124
129
125
130
const createDropdown = ( models : Record < string , ModelInfo > ) => {
@@ -130,6 +135,7 @@ const ApiOptions = ({
130
135
label : modelId ,
131
136
} ) ) ,
132
137
]
138
+
133
139
return (
134
140
< Dropdown
135
141
id = "model-id"
@@ -1268,11 +1274,9 @@ const ApiOptions = ({
1268
1274
< div className = "flex flex-col gap-2 mt-2" >
1269
1275
< Checkbox
1270
1276
checked = { ! ! anthropicThinkingBudget }
1271
- onChange = { ( checked ) => {
1272
- const budget = checked ? 16_384 : undefined
1273
- setAnthropicThinkingBudget ( budget )
1274
- setApiConfigurationField ( "anthropicThinking" , budget )
1275
- } } >
1277
+ onChange = { ( checked ) =>
1278
+ setApiConfigurationField ( "anthropicThinking" , checked ? 16_384 : undefined )
1279
+ } >
1276
1280
Thinking?
1277
1281
</ Checkbox >
1278
1282
{ anthropicThinkingBudget && (
@@ -1286,11 +1290,7 @@ const ApiOptions = ({
1286
1290
max = { anthropicModels [ "claude-3-7-sonnet-20250219" ] . maxTokens - 1 }
1287
1291
step = { 1024 }
1288
1292
value = { [ anthropicThinkingBudget ] }
1289
- onValueChange = { ( value ) => {
1290
- const budget = value [ 0 ]
1291
- setAnthropicThinkingBudget ( budget )
1292
- setApiConfigurationField ( "anthropicThinking" , budget )
1293
- } }
1293
+ onValueChange = { ( value ) => setApiConfigurationField ( "anthropicThinking" , value [ 0 ] ) }
1294
1294
/>
1295
1295
< div className = "w-10" > { anthropicThinkingBudget } </ div >
1296
1296
</ div >
0 commit comments