@@ -96,10 +96,23 @@ export const ModelSelectionButton: React.FC<{}> = ({ }) => {
96
96
const [ newApiBase , setNewApiBase ] = useState < string | undefined > ( undefined ) ;
97
97
const [ newApiVersion , setNewApiVersion ] = useState < string | undefined > ( undefined ) ;
98
98
99
- let disableApiKey = newEndpoint == "" || newEndpoint == "ollama" ;
100
- let disableModel = newEndpoint == "" ;
101
- let disableApiBase = newEndpoint != "azure" ;
102
- let disableApiVersion = newEndpoint != "azure" ;
99
+ useEffect ( ( ) => {
100
+ if ( newEndpoint == 'ollama' ) {
101
+ if ( ! newApiBase ) {
102
+ setNewApiBase ( 'http://localhost:11434' ) ;
103
+ }
104
+ }
105
+ if ( newEndpoint == "openai" ) {
106
+ if ( ! newModel ) {
107
+ setNewModel ( 'gpt-4o' ) ;
108
+ }
109
+ }
110
+ if ( newEndpoint == "anthropic" ) {
111
+ if ( ! newModel ) {
112
+ setNewModel ( 'claude-3-5-sonnet-20241022' ) ;
113
+ }
114
+ }
115
+ } , [ newEndpoint ] ) ;
103
116
104
117
let modelExists = models . some ( m => m . endpoint == newEndpoint && m . model == newModel && m . api_base == newApiBase && m . api_key == newApiKey && m . api_version == newApiVersion ) ;
105
118
@@ -122,16 +135,7 @@ export const ModelSelectionButton: React.FC<{}> = ({ }) => {
122
135
} ) ;
123
136
}
124
137
125
- let readyToTest = false ;
126
- if ( newEndpoint == "openai" ) {
127
- readyToTest = newModel != "" ;
128
- }
129
- if ( newEndpoint == "azure" ) {
130
- readyToTest = newModel != "" && newApiBase != "" ;
131
- }
132
- if ( newEndpoint == "ollama" ) {
133
- readyToTest = newModel != "" ;
134
- }
138
+ let readyToTest = newModel && ( newApiKey || newApiBase ) ;
135
139
136
140
let newModelEntry = < TableRow
137
141
key = { `new-model-entry` }
@@ -189,24 +193,23 @@ export const ModelSelectionButton: React.FC<{}> = ({ }) => {
189
193
< TextField fullWidth size = "small" type = { showKeys ? "text" : "password" }
190
194
InputProps = { { style : { fontSize : "0.875rem" } } }
191
195
placeholder = 'leave blank if using keyless access'
196
+ error = { newEndpoint != "azure" && ! newApiKey }
192
197
value = { newApiKey } onChange = { ( event : any ) => { setNewApiKey ( event . target . value ) ; } }
193
198
autoComplete = 'off'
194
- disabled = { disableApiKey }
195
199
/>
196
200
</ TableCell >
197
201
< TableCell align = "left" >
198
202
< Autocomplete
199
203
freeSolo
200
- disabled = { disableModel }
201
204
onChange = { ( event : any , newValue : string | null ) => { setNewModel ( newValue || "" ) ; } }
202
205
value = { newModel }
203
- options = { [ 'gpt-4o-mini' , 'gpt-4 ' , 'llama3.2 ' ] }
206
+ options = { [ 'gpt-4o-mini' , 'gpt-4o ' , 'claude-3-5-sonnet-20241022' , 'codellama '] }
204
207
renderOption = { ( props , option ) => {
205
208
return < Typography { ...props } onClick = { ( ) => { setNewModel ( option ) ; } } sx = { { fontSize : "small" } } > { option } </ Typography >
206
209
} }
207
210
renderInput = { ( params ) => (
208
211
< TextField
209
- error = { modelExists }
212
+ error = { newEndpoint != "" && ! newModel }
210
213
{ ...params }
211
214
placeholder = "model name"
212
215
InputProps = { { ...params . InputProps , style : { fontSize : "0.875rem" } } }
@@ -234,19 +237,18 @@ export const ModelSelectionButton: React.FC<{}> = ({ }) => {
234
237
< TableCell align = "right" >
235
238
< TextField size = "small" type = "text" fullWidth
236
239
placeholder = "api_base"
240
+ error = { newEndpoint === "azure" && ! newApiBase }
237
241
InputProps = { { style : { fontSize : "0.875rem" } } }
238
- value = { newApiBase } onChange = { ( event : any ) => { setNewApiBase ( event . target . value ) ; } }
242
+ value = { newApiBase }
243
+ onChange = { ( event : any ) => { setNewApiBase ( event . target . value ) ; } }
239
244
autoComplete = 'off'
240
- disabled = { disableApiBase }
241
- required = { newEndpoint == "azure" }
242
245
/>
243
246
</ TableCell >
244
247
< TableCell align = "right" >
245
248
< TextField size = "small" type = "text" fullWidth
246
249
InputProps = { { style : { fontSize : "0.875rem" } } }
247
250
value = { newApiVersion } onChange = { ( event : any ) => { setNewApiVersion ( event . target . value ) ; } }
248
251
autoComplete = 'off'
249
- disabled = { disableApiVersion }
250
252
placeholder = "api_version"
251
253
/>
252
254
</ TableCell >
0 commit comments