mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
feat: Make API Key optional for custom model providers (#1756)
* Initial plan * Make API Key optional for custom model providers Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> * Fix TypeScript type errors in test functions Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> * perf: ui --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> Co-authored-by: Junyan Qin <rockchinq@gmail.com>
This commit is contained in:
@@ -75,7 +75,7 @@ const getFormSchema = (t: (key: string) => string) =>
|
|||||||
.string()
|
.string()
|
||||||
.min(1, { message: t('models.modelProviderRequired') }),
|
.min(1, { message: t('models.modelProviderRequired') }),
|
||||||
url: z.string().min(1, { message: t('models.requestURLRequired') }),
|
url: z.string().min(1, { message: t('models.requestURLRequired') }),
|
||||||
api_key: z.string().min(1, { message: t('models.apiKeyRequired') }),
|
api_key: z.string().optional(),
|
||||||
extra_args: z.array(getExtraArgSchema(t)).optional(),
|
extra_args: z.array(getExtraArgSchema(t)).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ export default function EmbeddingForm({
|
|||||||
name: '',
|
name: '',
|
||||||
model_provider: '',
|
model_provider: '',
|
||||||
url: '',
|
url: '',
|
||||||
api_key: 'sk-xxxxx',
|
api_key: '',
|
||||||
extra_args: [],
|
extra_args: [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -245,7 +245,7 @@ export default function EmbeddingForm({
|
|||||||
timeout: 120,
|
timeout: 120,
|
||||||
},
|
},
|
||||||
extra_args: extraArgsObj,
|
extra_args: extraArgsObj,
|
||||||
api_keys: [value.api_key],
|
api_keys: value.api_key ? [value.api_key] : [],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
@@ -310,6 +310,7 @@ export default function EmbeddingForm({
|
|||||||
extraArgsObj[arg.key] = arg.value;
|
extraArgsObj[arg.key] = arg.value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const apiKey = form.getValues('api_key');
|
||||||
httpClient
|
httpClient
|
||||||
.testEmbeddingModel('_', {
|
.testEmbeddingModel('_', {
|
||||||
uuid: '',
|
uuid: '',
|
||||||
@@ -320,7 +321,7 @@ export default function EmbeddingForm({
|
|||||||
base_url: form.getValues('url'),
|
base_url: form.getValues('url'),
|
||||||
timeout: 120,
|
timeout: 120,
|
||||||
},
|
},
|
||||||
api_keys: [form.getValues('api_key')],
|
api_keys: apiKey ? [apiKey] : [],
|
||||||
extra_args: extraArgsObj,
|
extra_args: extraArgsObj,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@@ -461,10 +462,7 @@ export default function EmbeddingForm({
|
|||||||
name="api_key"
|
name="api_key"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>{t('models.apiKey')}</FormLabel>
|
||||||
{t('models.apiKey')}
|
|
||||||
<span className="text-red-500">*</span>
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} />
|
<Input {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ const getFormSchema = (t: (key: string) => string) =>
|
|||||||
.string()
|
.string()
|
||||||
.min(1, { message: t('models.modelProviderRequired') }),
|
.min(1, { message: t('models.modelProviderRequired') }),
|
||||||
url: z.string().min(1, { message: t('models.requestURLRequired') }),
|
url: z.string().min(1, { message: t('models.requestURLRequired') }),
|
||||||
api_key: z.string().min(1, { message: t('models.apiKeyRequired') }),
|
api_key: z.string().optional(),
|
||||||
abilities: z.array(z.string()),
|
abilities: z.array(z.string()),
|
||||||
extra_args: z.array(getExtraArgSchema(t)).optional(),
|
extra_args: z.array(getExtraArgSchema(t)).optional(),
|
||||||
});
|
});
|
||||||
@@ -103,7 +103,7 @@ export default function LLMForm({
|
|||||||
name: '',
|
name: '',
|
||||||
model_provider: '',
|
model_provider: '',
|
||||||
url: '',
|
url: '',
|
||||||
api_key: 'sk-xxxxx',
|
api_key: '',
|
||||||
abilities: [],
|
abilities: [],
|
||||||
extra_args: [],
|
extra_args: [],
|
||||||
},
|
},
|
||||||
@@ -261,7 +261,7 @@ export default function LLMForm({
|
|||||||
timeout: 120,
|
timeout: 120,
|
||||||
},
|
},
|
||||||
extra_args: extraArgsObj,
|
extra_args: extraArgsObj,
|
||||||
api_keys: [value.api_key],
|
api_keys: value.api_key ? [value.api_key] : [],
|
||||||
abilities: value.abilities,
|
abilities: value.abilities,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -324,6 +324,7 @@ export default function LLMForm({
|
|||||||
extraArgsObj[arg.key] = arg.value;
|
extraArgsObj[arg.key] = arg.value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const apiKey = form.getValues('api_key');
|
||||||
httpClient
|
httpClient
|
||||||
.testLLMModel('_', {
|
.testLLMModel('_', {
|
||||||
uuid: '',
|
uuid: '',
|
||||||
@@ -334,7 +335,7 @@ export default function LLMForm({
|
|||||||
base_url: form.getValues('url'),
|
base_url: form.getValues('url'),
|
||||||
timeout: 120,
|
timeout: 120,
|
||||||
},
|
},
|
||||||
api_keys: [form.getValues('api_key')],
|
api_keys: apiKey ? [apiKey] : [],
|
||||||
abilities: form.getValues('abilities'),
|
abilities: form.getValues('abilities'),
|
||||||
extra_args: extraArgsObj,
|
extra_args: extraArgsObj,
|
||||||
})
|
})
|
||||||
@@ -478,10 +479,7 @@ export default function LLMForm({
|
|||||||
name="api_key"
|
name="api_key"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>{t('models.apiKey')}</FormLabel>
|
||||||
{t('models.apiKey')}
|
|
||||||
<span className="text-red-500">*</span>
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} />
|
<Input {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
Reference in New Issue
Block a user