Skip to content

Commit 094253a

Browse files
committed
fix(agent-tars): custom model name should keep state (close: #285
1 parent 2f460fe commit 094253a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

apps/agent-tars/src/renderer/src/components/LeftSidebar/Settings/ModelSettingsTab.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react';
1+
import { useState, useEffect } from 'react';
22
import { Input, Select, SelectItem, Spinner, Switch } from '@nextui-org/react';
33
import { ModelSettings, ModelProvider } from '@agent-infra/shared';
44
import { getProviderLogo, getModelOptions } from './modelUtils';
@@ -17,6 +17,17 @@ export function ModelSettingsTab({
1717
const [useCustomModel, setUseCustomModel] = useState(false);
1818
const isAzure = settings.provider === ModelProvider.AZURE_OPENAI;
1919

20+
// Check if the current model is one of the preset options
21+
useEffect(() => {
22+
if (!settings.model) return;
23+
24+
const isCustomModel = !getModelOptions(settings.provider).some(
25+
(option) => option.value === settings.model,
26+
);
27+
28+
setUseCustomModel(isCustomModel);
29+
}, [settings.provider, settings.model]);
30+
2031
if (loading) {
2132
return (
2233
<div className="flex justify-center items-center h-64">

0 commit comments

Comments
 (0)