fix: bedrock component handling AWS constants (#4514)
* update model list as constants update model list as constants Add default value to Secret string variables * Update amazon_bedrock.py load_from_db false for session_token
This commit is contained in:
parent
f34d57acb7
commit
516ba8908d
3 changed files with 85 additions and 105 deletions
70
src/backend/base/langflow/base/models/aws_constants.py
Normal file
70
src/backend/base/langflow/base/models/aws_constants.py
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
AWS_MODEL_IDs = [
|
||||||
|
"amazon.titan-text-express-v1",
|
||||||
|
"amazon.titan-text-lite-v1",
|
||||||
|
"amazon.titan-text-premier-v1:0",
|
||||||
|
"amazon.titan-embed-text-v1",
|
||||||
|
"amazon.titan-embed-text-v2:0",
|
||||||
|
"amazon.titan-embed-image-v1",
|
||||||
|
"amazon.titan-image-generator-v1",
|
||||||
|
"anthropic.claude-v2",
|
||||||
|
"anthropic.claude-v2:1",
|
||||||
|
"anthropic.claude-3-sonnet-20240229-v1:0",
|
||||||
|
"anthropic.claude-3-haiku-20240307-v1:0",
|
||||||
|
"anthropic.claude-3-opus-20240229-v1:0",
|
||||||
|
"anthropic.claude-instant-v1",
|
||||||
|
"ai21.j2-mid-v1",
|
||||||
|
"ai21.j2-ultra-v1",
|
||||||
|
"cohere.command-text-v14",
|
||||||
|
"cohere.command-light-text-v14",
|
||||||
|
"cohere.command-r-v1:0",
|
||||||
|
"cohere.command-r-plus-v1:0",
|
||||||
|
"cohere.embed-english-v3",
|
||||||
|
"cohere.embed-multilingual-v3",
|
||||||
|
"meta.llama2-13b-chat-v1",
|
||||||
|
"meta.llama2-70b-chat-v1",
|
||||||
|
"meta.llama3-8b-instruct-v1:0",
|
||||||
|
"meta.llama3-70b-instruct-v1:0",
|
||||||
|
"mistral.mistral-7b-instruct-v0:2",
|
||||||
|
"mistral.mixtral-8x7b-instruct-v0:1",
|
||||||
|
"mistral.mistral-large-2402-v1:0",
|
||||||
|
"mistral.mistral-small-2402-v1:0",
|
||||||
|
"stability.stable-diffusion-xl-v0",
|
||||||
|
"stability.stable-diffusion-xl-v1",
|
||||||
|
]
|
||||||
|
|
||||||
|
AWS_REGIONS = [
|
||||||
|
"us-west-2",
|
||||||
|
"us-west-1",
|
||||||
|
"us-gov-west-1",
|
||||||
|
"us-gov-east-1",
|
||||||
|
"us-east-2",
|
||||||
|
"us-east-1",
|
||||||
|
"sa-east-1",
|
||||||
|
"me-south-1",
|
||||||
|
"me-central-1",
|
||||||
|
"il-central-1",
|
||||||
|
"eu-west-3",
|
||||||
|
"eu-west-2",
|
||||||
|
"eu-west-1",
|
||||||
|
"eu-south-2",
|
||||||
|
"eu-south-1",
|
||||||
|
"eu-north-1",
|
||||||
|
"eu-central-2",
|
||||||
|
"eu-central-1",
|
||||||
|
"cn-northwest-1",
|
||||||
|
"cn-north-1",
|
||||||
|
"ca-west-1",
|
||||||
|
"ca-central-1",
|
||||||
|
"ap-southeast-5",
|
||||||
|
"ap-southeast-4",
|
||||||
|
"ap-southeast-3",
|
||||||
|
"ap-southeast-2",
|
||||||
|
"ap-southeast-1",
|
||||||
|
"ap-south-2",
|
||||||
|
"ap-south-1",
|
||||||
|
"ap-northeast-3",
|
||||||
|
"ap-northeast-2",
|
||||||
|
"ap-northeast-1",
|
||||||
|
"ap-east-1",
|
||||||
|
"af-south-1",
|
||||||
|
]
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
from langflow.base.models.aws_constants import AWS_REGIONS
|
||||||
from langflow.base.models.model import LCModelComponent
|
from langflow.base.models.model import LCModelComponent
|
||||||
from langflow.field_typing import Embeddings
|
from langflow.field_typing import Embeddings
|
||||||
from langflow.inputs import SecretStrInput
|
from langflow.inputs import SecretStrInput
|
||||||
|
|
@ -22,12 +23,14 @@ class AmazonBedrockEmbeddingsComponent(LCModelComponent):
|
||||||
display_name="AWS Access Key ID",
|
display_name="AWS Access Key ID",
|
||||||
info="The access key for your AWS account."
|
info="The access key for your AWS account."
|
||||||
"Usually set in Python code as the environment variable 'AWS_ACCESS_KEY_ID'.",
|
"Usually set in Python code as the environment variable 'AWS_ACCESS_KEY_ID'.",
|
||||||
|
value="AWS_ACCESS_KEY_ID",
|
||||||
),
|
),
|
||||||
SecretStrInput(
|
SecretStrInput(
|
||||||
name="aws_secret_access_key",
|
name="aws_secret_access_key",
|
||||||
display_name="AWS Secret Access Key",
|
display_name="AWS Secret Access Key",
|
||||||
info="The secret key for your AWS account. "
|
info="The secret key for your AWS account. "
|
||||||
"Usually set in Python code as the environment variable 'AWS_SECRET_ACCESS_KEY'.",
|
"Usually set in Python code as the environment variable 'AWS_SECRET_ACCESS_KEY'.",
|
||||||
|
value="AWS_SECRET_ACCESS_KEY",
|
||||||
),
|
),
|
||||||
SecretStrInput(
|
SecretStrInput(
|
||||||
name="aws_session_token",
|
name="aws_session_token",
|
||||||
|
|
@ -36,6 +39,7 @@ class AmazonBedrockEmbeddingsComponent(LCModelComponent):
|
||||||
info="The session key for your AWS account. "
|
info="The session key for your AWS account. "
|
||||||
"Only needed for temporary credentials. "
|
"Only needed for temporary credentials. "
|
||||||
"Usually set in Python code as the environment variable 'AWS_SESSION_TOKEN'.",
|
"Usually set in Python code as the environment variable 'AWS_SESSION_TOKEN'.",
|
||||||
|
value="AWS_SESSION_TOKEN",
|
||||||
),
|
),
|
||||||
SecretStrInput(
|
SecretStrInput(
|
||||||
name="credentials_profile_name",
|
name="credentials_profile_name",
|
||||||
|
|
@ -44,47 +48,13 @@ class AmazonBedrockEmbeddingsComponent(LCModelComponent):
|
||||||
info="The name of the profile to use from your "
|
info="The name of the profile to use from your "
|
||||||
"~/.aws/credentials file. "
|
"~/.aws/credentials file. "
|
||||||
"If not provided, the default profile will be used.",
|
"If not provided, the default profile will be used.",
|
||||||
|
value="AWS_CREDENTIALS_PROFILE_NAME",
|
||||||
),
|
),
|
||||||
DropdownInput(
|
DropdownInput(
|
||||||
name="region_name",
|
name="region_name",
|
||||||
display_name="Region Name",
|
display_name="Region Name",
|
||||||
value="us-east-1",
|
value="us-east-1",
|
||||||
options=[
|
options=AWS_REGIONS,
|
||||||
"us-west-2",
|
|
||||||
"us-west-1",
|
|
||||||
"us-gov-west-1",
|
|
||||||
"us-gov-east-1",
|
|
||||||
"us-east-2",
|
|
||||||
"us-east-1",
|
|
||||||
"sa-east-1",
|
|
||||||
"me-south-1",
|
|
||||||
"me-central-1",
|
|
||||||
"il-central-1",
|
|
||||||
"eu-west-3",
|
|
||||||
"eu-west-2",
|
|
||||||
"eu-west-1",
|
|
||||||
"eu-south-2",
|
|
||||||
"eu-south-1",
|
|
||||||
"eu-north-1",
|
|
||||||
"eu-central-2",
|
|
||||||
"eu-central-1",
|
|
||||||
"cn-northwest-1",
|
|
||||||
"cn-north-1",
|
|
||||||
"ca-west-1",
|
|
||||||
"ca-central-1",
|
|
||||||
"ap-southeast-5",
|
|
||||||
"ap-southeast-4",
|
|
||||||
"ap-southeast-3",
|
|
||||||
"ap-southeast-2",
|
|
||||||
"ap-southeast-1",
|
|
||||||
"ap-south-2",
|
|
||||||
"ap-south-1",
|
|
||||||
"ap-northeast-3",
|
|
||||||
"ap-northeast-2",
|
|
||||||
"ap-northeast-1",
|
|
||||||
"ap-east-1",
|
|
||||||
"af-south-1",
|
|
||||||
],
|
|
||||||
info="The AWS region where your Bedrock resources are located.",
|
info="The AWS region where your Bedrock resources are located.",
|
||||||
),
|
),
|
||||||
MessageTextInput(
|
MessageTextInput(
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
from langflow.base.models.aws_constants import AWS_REGIONS, AWS_MODEL_IDs
|
||||||
from langflow.base.models.model import LCModelComponent
|
from langflow.base.models.model import LCModelComponent
|
||||||
from langflow.field_typing import LanguageModel
|
from langflow.field_typing import LanguageModel
|
||||||
from langflow.inputs import MessageTextInput, SecretStrInput
|
from langflow.inputs import MessageTextInput, SecretStrInput
|
||||||
|
|
@ -16,39 +17,7 @@ class AmazonBedrockComponent(LCModelComponent):
|
||||||
DropdownInput(
|
DropdownInput(
|
||||||
name="model_id",
|
name="model_id",
|
||||||
display_name="Model ID",
|
display_name="Model ID",
|
||||||
options=[
|
options=AWS_MODEL_IDs,
|
||||||
"amazon.titan-text-express-v1",
|
|
||||||
"amazon.titan-text-lite-v1",
|
|
||||||
"amazon.titan-text-premier-v1:0",
|
|
||||||
"amazon.titan-embed-text-v1",
|
|
||||||
"amazon.titan-embed-text-v2:0",
|
|
||||||
"amazon.titan-embed-image-v1",
|
|
||||||
"amazon.titan-image-generator-v1",
|
|
||||||
"anthropic.claude-v2",
|
|
||||||
"anthropic.claude-v2:1",
|
|
||||||
"anthropic.claude-3-sonnet-20240229-v1:0",
|
|
||||||
"anthropic.claude-3-haiku-20240307-v1:0",
|
|
||||||
"anthropic.claude-3-opus-20240229-v1:0",
|
|
||||||
"anthropic.claude-instant-v1",
|
|
||||||
"ai21.j2-mid-v1",
|
|
||||||
"ai21.j2-ultra-v1",
|
|
||||||
"cohere.command-text-v14",
|
|
||||||
"cohere.command-light-text-v14",
|
|
||||||
"cohere.command-r-v1:0",
|
|
||||||
"cohere.command-r-plus-v1:0",
|
|
||||||
"cohere.embed-english-v3",
|
|
||||||
"cohere.embed-multilingual-v3",
|
|
||||||
"meta.llama2-13b-chat-v1",
|
|
||||||
"meta.llama2-70b-chat-v1",
|
|
||||||
"meta.llama3-8b-instruct-v1:0",
|
|
||||||
"meta.llama3-70b-instruct-v1:0",
|
|
||||||
"mistral.mistral-7b-instruct-v0:2",
|
|
||||||
"mistral.mixtral-8x7b-instruct-v0:1",
|
|
||||||
"mistral.mistral-large-2402-v1:0",
|
|
||||||
"mistral.mistral-small-2402-v1:0",
|
|
||||||
"stability.stable-diffusion-xl-v0",
|
|
||||||
"stability.stable-diffusion-xl-v1",
|
|
||||||
],
|
|
||||||
value="anthropic.claude-3-haiku-20240307-v1:0",
|
value="anthropic.claude-3-haiku-20240307-v1:0",
|
||||||
info="List of available model IDs to choose from.",
|
info="List of available model IDs to choose from.",
|
||||||
),
|
),
|
||||||
|
|
@ -57,12 +26,14 @@ class AmazonBedrockComponent(LCModelComponent):
|
||||||
display_name="AWS Access Key ID",
|
display_name="AWS Access Key ID",
|
||||||
info="The access key for your AWS account."
|
info="The access key for your AWS account."
|
||||||
"Usually set in Python code as the environment variable 'AWS_ACCESS_KEY_ID'.",
|
"Usually set in Python code as the environment variable 'AWS_ACCESS_KEY_ID'.",
|
||||||
|
value="AWS_ACCESS_KEY_ID",
|
||||||
),
|
),
|
||||||
SecretStrInput(
|
SecretStrInput(
|
||||||
name="aws_secret_access_key",
|
name="aws_secret_access_key",
|
||||||
display_name="AWS Secret Access Key",
|
display_name="AWS Secret Access Key",
|
||||||
info="The secret key for your AWS account. "
|
info="The secret key for your AWS account. "
|
||||||
"Usually set in Python code as the environment variable 'AWS_SECRET_ACCESS_KEY'.",
|
"Usually set in Python code as the environment variable 'AWS_SECRET_ACCESS_KEY'.",
|
||||||
|
value="AWS_SECRET_ACCESS_KEY",
|
||||||
),
|
),
|
||||||
SecretStrInput(
|
SecretStrInput(
|
||||||
name="aws_session_token",
|
name="aws_session_token",
|
||||||
|
|
@ -71,6 +42,8 @@ class AmazonBedrockComponent(LCModelComponent):
|
||||||
info="The session key for your AWS account. "
|
info="The session key for your AWS account. "
|
||||||
"Only needed for temporary credentials. "
|
"Only needed for temporary credentials. "
|
||||||
"Usually set in Python code as the environment variable 'AWS_SESSION_TOKEN'.",
|
"Usually set in Python code as the environment variable 'AWS_SESSION_TOKEN'.",
|
||||||
|
value="AWS_SESSION_TOKEN",
|
||||||
|
load_from_db=False,
|
||||||
),
|
),
|
||||||
SecretStrInput(
|
SecretStrInput(
|
||||||
name="credentials_profile_name",
|
name="credentials_profile_name",
|
||||||
|
|
@ -79,47 +52,14 @@ class AmazonBedrockComponent(LCModelComponent):
|
||||||
info="The name of the profile to use from your "
|
info="The name of the profile to use from your "
|
||||||
"~/.aws/credentials file. "
|
"~/.aws/credentials file. "
|
||||||
"If not provided, the default profile will be used.",
|
"If not provided, the default profile will be used.",
|
||||||
|
value="AWS_CREDENTIALS_PROFILE_NAME",
|
||||||
|
load_from_db=False,
|
||||||
),
|
),
|
||||||
DropdownInput(
|
DropdownInput(
|
||||||
name="region_name",
|
name="region_name",
|
||||||
display_name="Region Name",
|
display_name="Region Name",
|
||||||
value="us-east-1",
|
value="us-east-1",
|
||||||
options=[
|
options=AWS_REGIONS,
|
||||||
"us-west-2",
|
|
||||||
"us-west-1",
|
|
||||||
"us-gov-west-1",
|
|
||||||
"us-gov-east-1",
|
|
||||||
"us-east-2",
|
|
||||||
"us-east-1",
|
|
||||||
"sa-east-1",
|
|
||||||
"me-south-1",
|
|
||||||
"me-central-1",
|
|
||||||
"il-central-1",
|
|
||||||
"eu-west-3",
|
|
||||||
"eu-west-2",
|
|
||||||
"eu-west-1",
|
|
||||||
"eu-south-2",
|
|
||||||
"eu-south-1",
|
|
||||||
"eu-north-1",
|
|
||||||
"eu-central-2",
|
|
||||||
"eu-central-1",
|
|
||||||
"cn-northwest-1",
|
|
||||||
"cn-north-1",
|
|
||||||
"ca-west-1",
|
|
||||||
"ca-central-1",
|
|
||||||
"ap-southeast-5",
|
|
||||||
"ap-southeast-4",
|
|
||||||
"ap-southeast-3",
|
|
||||||
"ap-southeast-2",
|
|
||||||
"ap-southeast-1",
|
|
||||||
"ap-south-2",
|
|
||||||
"ap-south-1",
|
|
||||||
"ap-northeast-3",
|
|
||||||
"ap-northeast-2",
|
|
||||||
"ap-northeast-1",
|
|
||||||
"ap-east-1",
|
|
||||||
"af-south-1",
|
|
||||||
],
|
|
||||||
info="The AWS region where your Bedrock resources are located.",
|
info="The AWS region where your Bedrock resources are located.",
|
||||||
),
|
),
|
||||||
DictInput(
|
DictInput(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue