Make access key and secret optional for AWS Bedrock

This commit is contained in:
Weves
2024-05-07 01:08:19 -07:00
committed by Chris Weaver
parent 45d5d7af4a
commit d6522426c9
3 changed files with 47 additions and 12 deletions

View File

@@ -50,8 +50,8 @@ export function LLMProviderUpdateForm({
custom_config:
existingLlmProvider?.custom_config ??
llmProviderDescriptor.custom_config_keys?.reduce(
(acc, key) => {
acc[key] = "";
(acc, customConfigKey) => {
acc[customConfigKey.name] = "";
return acc;
},
{} as { [key: string]: string }
@@ -77,8 +77,12 @@ export function LLMProviderUpdateForm({
? {
custom_config: Yup.object(
llmProviderDescriptor.custom_config_keys.reduce(
(acc, key) => {
acc[key] = Yup.string().required(`${key} is required`);
(acc, customConfigKey) => {
if (customConfigKey.is_required) {
acc[customConfigKey.name] = Yup.string().required(
`${customConfigKey.name} is required`
);
}
return acc;
},
{} as { [key: string]: Yup.StringSchema }
@@ -205,9 +209,17 @@ export function LLMProviderUpdateForm({
/>
)}
{llmProviderDescriptor.custom_config_keys?.map((key) => (
<div key={key}>
<TextFormField name={`custom_config.${key}`} label={key} />
{llmProviderDescriptor.custom_config_keys?.map((customConfigKey) => (
<div key={customConfigKey.name}>
<TextFormField
name={`custom_config.${customConfigKey.name}`}
label={
customConfigKey.is_required
? customConfigKey.name
: `[Optional] ${customConfigKey.name}`
}
subtext={customConfigKey.description || undefined}
/>
</div>
))}

View File

@@ -1,3 +1,10 @@
export interface CustomConfigKey {
name: string;
description: string | null;
is_required: boolean;
is_secret: boolean;
}
export interface WellKnownLLMProviderDescriptor {
name: string;
display_name: string | null;
@@ -5,7 +12,7 @@ export interface WellKnownLLMProviderDescriptor {
api_key_required: boolean;
api_base_required: boolean;
api_version_required: boolean;
custom_config_keys: string[] | null;
custom_config_keys: CustomConfigKey[] | null;
llm_names: string[];
default_model: string | null;