Skip to content

Commit ccb6a08

Browse files
committed
helper text test
1 parent 42b4a86 commit ccb6a08

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

src/views/ModelSelectionDialog.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,23 @@ export const ModelSelectionButton: React.FC<{}> = ({ }) => {
9696
const [newApiBase, setNewApiBase] = useState<string | undefined>(undefined);
9797
const [newApiVersion, setNewApiVersion] = useState<string | undefined>(undefined);
9898

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]);
103116

104117
let modelExists = models.some(m => m.endpoint == newEndpoint && m.model == newModel && m.api_base == newApiBase && m.api_key == newApiKey && m.api_version == newApiVersion);
105118

@@ -122,16 +135,7 @@ export const ModelSelectionButton: React.FC<{}> = ({ }) => {
122135
});
123136
}
124137

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);
135139

136140
let newModelEntry = <TableRow
137141
key={`new-model-entry`}
@@ -189,24 +193,23 @@ export const ModelSelectionButton: React.FC<{}> = ({ }) => {
189193
<TextField fullWidth size="small" type={showKeys ? "text" : "password"}
190194
InputProps={{ style: { fontSize: "0.875rem" } }}
191195
placeholder='leave blank if using keyless access'
196+
error={newEndpoint != "azure" && !newApiKey}
192197
value={newApiKey} onChange={(event: any) => { setNewApiKey(event.target.value); }}
193198
autoComplete='off'
194-
disabled={disableApiKey}
195199
/>
196200
</TableCell>
197201
<TableCell align="left">
198202
<Autocomplete
199203
freeSolo
200-
disabled={disableModel}
201204
onChange={(event: any, newValue: string | null) => { setNewModel(newValue || ""); }}
202205
value={newModel}
203-
options={['gpt-4o-mini', 'gpt-4', 'llama3.2']}
206+
options={['gpt-4o-mini', 'gpt-4o', 'claude-3-5-sonnet-20241022', 'codellama']}
204207
renderOption={(props, option) => {
205208
return <Typography {...props} onClick={()=>{ setNewModel(option); }} sx={{fontSize: "small"}}>{option}</Typography>
206209
}}
207210
renderInput={(params) => (
208211
<TextField
209-
error={modelExists}
212+
error={newEndpoint != "" && !newModel}
210213
{...params}
211214
placeholder="model name"
212215
InputProps={{ ...params.InputProps, style: { fontSize: "0.875rem" } }}
@@ -234,19 +237,18 @@ export const ModelSelectionButton: React.FC<{}> = ({ }) => {
234237
<TableCell align="right">
235238
<TextField size="small" type="text" fullWidth
236239
placeholder="api_base"
240+
error={newEndpoint === "azure" && !newApiBase}
237241
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); }}
239244
autoComplete='off'
240-
disabled={disableApiBase}
241-
required={newEndpoint == "azure"}
242245
/>
243246
</TableCell>
244247
<TableCell align="right">
245248
<TextField size="small" type="text" fullWidth
246249
InputProps={{ style: { fontSize: "0.875rem" } }}
247250
value={newApiVersion} onChange={(event: any) => { setNewApiVersion(event.target.value); }}
248251
autoComplete='off'
249-
disabled={disableApiVersion}
250252
placeholder="api_version"
251253
/>
252254
</TableCell>

0 commit comments

Comments
 (0)