mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-27 04:18:35 +02:00
Make access key and secret optional for AWS Bedrock
This commit is contained in:
@@ -2,13 +2,20 @@ import litellm # type: ignore
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class CustomConfigKey(BaseModel):
|
||||||
|
name: str
|
||||||
|
description: str | None = None
|
||||||
|
is_required: bool = True
|
||||||
|
is_secret: bool = False
|
||||||
|
|
||||||
|
|
||||||
class WellKnownLLMProviderDescriptor(BaseModel):
|
class WellKnownLLMProviderDescriptor(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
display_name: str | None = None
|
display_name: str | None = None
|
||||||
api_key_required: bool
|
api_key_required: bool
|
||||||
api_base_required: bool
|
api_base_required: bool
|
||||||
api_version_required: bool
|
api_version_required: bool
|
||||||
custom_config_keys: list[str] | None = None
|
custom_config_keys: list[CustomConfigKey] | None = None
|
||||||
|
|
||||||
llm_names: list[str]
|
llm_names: list[str]
|
||||||
default_model: str | None = None
|
default_model: str | None = None
|
||||||
@@ -96,9 +103,18 @@ def fetch_available_well_known_llms() -> list[WellKnownLLMProviderDescriptor]:
|
|||||||
api_base_required=False,
|
api_base_required=False,
|
||||||
api_version_required=False,
|
api_version_required=False,
|
||||||
custom_config_keys=[
|
custom_config_keys=[
|
||||||
"AWS_ACCESS_KEY_ID",
|
CustomConfigKey(name="AWS_REGION_NAME"),
|
||||||
"AWS_SECRET_ACCESS_KEY",
|
CustomConfigKey(
|
||||||
"AWS_REGION_NAME",
|
name="AWS_ACCESS_KEY_ID",
|
||||||
|
is_required=False,
|
||||||
|
description="If using AWS IAM roles, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY can be left blank.",
|
||||||
|
),
|
||||||
|
CustomConfigKey(
|
||||||
|
name="AWS_SECRET_ACCESS_KEY",
|
||||||
|
is_required=False,
|
||||||
|
is_secret=True,
|
||||||
|
description="If using AWS IAM roles, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY can be left blank.",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
llm_names=fetch_models_for_provider(BEDROCK_PROVIDER_NAME),
|
llm_names=fetch_models_for_provider(BEDROCK_PROVIDER_NAME),
|
||||||
default_model="anthropic.claude-3-sonnet-20240229-v1:0",
|
default_model="anthropic.claude-3-sonnet-20240229-v1:0",
|
||||||
|
@@ -50,8 +50,8 @@ export function LLMProviderUpdateForm({
|
|||||||
custom_config:
|
custom_config:
|
||||||
existingLlmProvider?.custom_config ??
|
existingLlmProvider?.custom_config ??
|
||||||
llmProviderDescriptor.custom_config_keys?.reduce(
|
llmProviderDescriptor.custom_config_keys?.reduce(
|
||||||
(acc, key) => {
|
(acc, customConfigKey) => {
|
||||||
acc[key] = "";
|
acc[customConfigKey.name] = "";
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{} as { [key: string]: string }
|
{} as { [key: string]: string }
|
||||||
@@ -77,8 +77,12 @@ export function LLMProviderUpdateForm({
|
|||||||
? {
|
? {
|
||||||
custom_config: Yup.object(
|
custom_config: Yup.object(
|
||||||
llmProviderDescriptor.custom_config_keys.reduce(
|
llmProviderDescriptor.custom_config_keys.reduce(
|
||||||
(acc, key) => {
|
(acc, customConfigKey) => {
|
||||||
acc[key] = Yup.string().required(`${key} is required`);
|
if (customConfigKey.is_required) {
|
||||||
|
acc[customConfigKey.name] = Yup.string().required(
|
||||||
|
`${customConfigKey.name} is required`
|
||||||
|
);
|
||||||
|
}
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{} as { [key: string]: Yup.StringSchema }
|
{} as { [key: string]: Yup.StringSchema }
|
||||||
@@ -205,9 +209,17 @@ export function LLMProviderUpdateForm({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{llmProviderDescriptor.custom_config_keys?.map((key) => (
|
{llmProviderDescriptor.custom_config_keys?.map((customConfigKey) => (
|
||||||
<div key={key}>
|
<div key={customConfigKey.name}>
|
||||||
<TextFormField name={`custom_config.${key}`} label={key} />
|
<TextFormField
|
||||||
|
name={`custom_config.${customConfigKey.name}`}
|
||||||
|
label={
|
||||||
|
customConfigKey.is_required
|
||||||
|
? customConfigKey.name
|
||||||
|
: `[Optional] ${customConfigKey.name}`
|
||||||
|
}
|
||||||
|
subtext={customConfigKey.description || undefined}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
@@ -1,3 +1,10 @@
|
|||||||
|
export interface CustomConfigKey {
|
||||||
|
name: string;
|
||||||
|
description: string | null;
|
||||||
|
is_required: boolean;
|
||||||
|
is_secret: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface WellKnownLLMProviderDescriptor {
|
export interface WellKnownLLMProviderDescriptor {
|
||||||
name: string;
|
name: string;
|
||||||
display_name: string | null;
|
display_name: string | null;
|
||||||
@@ -5,7 +12,7 @@ export interface WellKnownLLMProviderDescriptor {
|
|||||||
api_key_required: boolean;
|
api_key_required: boolean;
|
||||||
api_base_required: boolean;
|
api_base_required: boolean;
|
||||||
api_version_required: boolean;
|
api_version_required: boolean;
|
||||||
custom_config_keys: string[] | null;
|
custom_config_keys: CustomConfigKey[] | null;
|
||||||
|
|
||||||
llm_names: string[];
|
llm_names: string[];
|
||||||
default_model: string | null;
|
default_model: string | null;
|
||||||
|
Reference in New Issue
Block a user