perf: no longer ask for apikeys for ollama and lm studio

This commit is contained in:
Junyan Qin
2025-05-20 16:01:20 +08:00
parent 1376530c2e
commit e5e8807312
@@ -103,7 +103,7 @@ export default function LLMForm({
name: '', name: '',
model_provider: '', model_provider: '',
url: '', url: '',
api_key: '', api_key: 'sk-xxxxx',
abilities: [], abilities: [],
extra_args: [], extra_args: [],
}, },
@@ -131,6 +131,7 @@ export default function LLMForm({
string[] string[]
>([]); >([]);
const [modelTesting, setModelTesting] = useState(false); const [modelTesting, setModelTesting] = useState(false);
const [currentModelProvider, setCurrentModelProvider] = useState('');
useEffect(() => { useEffect(() => {
initLLMModelFormComponent().then(() => { initLLMModelFormComponent().then(() => {
@@ -138,6 +139,7 @@ export default function LLMForm({
getLLMConfig(initLLMId).then((val) => { getLLMConfig(initLLMId).then((val) => {
form.setValue('name', val.name); form.setValue('name', val.name);
form.setValue('model_provider', val.model_provider); form.setValue('model_provider', val.model_provider);
setCurrentModelProvider(val.model_provider);
form.setValue('url', val.url); form.setValue('url', val.url);
form.setValue('api_key', val.api_key); form.setValue('api_key', val.api_key);
form.setValue( form.setValue(
@@ -409,6 +411,7 @@ export default function LLMForm({
<Select <Select
onValueChange={(value) => { onValueChange={(value) => {
field.onChange(value); field.onChange(value);
setCurrentModelProvider(value);
const index = requesterNameList.findIndex( const index = requesterNameList.findIndex(
(item) => item.value === value, (item) => item.value === value,
); );
@@ -455,22 +458,28 @@ export default function LLMForm({
</FormItem> </FormItem>
)} )}
/> />
<FormField
control={form.control} {!['lmstudio-chat-completions', 'ollama-chat'].includes(
name="api_key" currentModelProvider,
render={({ field }) => ( ) && (
<FormItem> <FormField
<FormLabel> control={form.control}
{t('models.apiKey')} name="api_key"
<span className="text-red-500">*</span> render={({ field }) => (
</FormLabel> <FormItem>
<FormControl> <FormLabel>
<Input {...field} /> {t('models.apiKey')}
</FormControl> <span className="text-red-500">*</span>
<FormMessage /> </FormLabel>
</FormItem> <FormControl>
)} <Input {...field} />
/> </FormControl>
<FormMessage />
</FormItem>
)}
/>
)}
<FormField <FormField
control={form.control} control={form.control}
name="abilities" name="abilities"