Bedrock Embeddings custom component
This commit is contained in:
parent
06dedcc90d
commit
31245c2d96
4 changed files with 48 additions and 2 deletions
|
|
@ -0,0 +1,46 @@
|
||||||
|
from typing import Optional
|
||||||
|
from langflow import CustomComponent
|
||||||
|
|
||||||
|
from langchain.embeddings import BedrockEmbeddings
|
||||||
|
from langchain.embeddings.base import Embeddings
|
||||||
|
|
||||||
|
|
||||||
|
class AmazonBedrockEmeddingsComponent(CustomComponent):
|
||||||
|
"""
|
||||||
|
A custom component for implementing an Embeddings Model using Amazon Bedrock.
|
||||||
|
"""
|
||||||
|
|
||||||
|
display_name: str = "Amazon Bedrock Embeddings"
|
||||||
|
description: str = "Embeddings model from Amazon Bedrock."
|
||||||
|
documentation = "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/bedrock"
|
||||||
|
beta = True
|
||||||
|
|
||||||
|
def build_config(self):
|
||||||
|
return {
|
||||||
|
"model_id": {
|
||||||
|
"display_name": "Model Id",
|
||||||
|
"options": ["amazon.titan-embed-text-v1"],
|
||||||
|
},
|
||||||
|
"credentials_profile_name": {"display_name": "Credentials Profile Name"},
|
||||||
|
"endpoint_url": {"display_name": "Bedrock Endpoint URL"},
|
||||||
|
"region_name": {"display_name": "AWS Region"},
|
||||||
|
"code": {"show": False},
|
||||||
|
}
|
||||||
|
|
||||||
|
def build(
|
||||||
|
self,
|
||||||
|
model_id: str = "amazon.titan-embed-text-v1",
|
||||||
|
credentials_profile_name: Optional[str] = None,
|
||||||
|
endpoint_url: Optional[str] = None,
|
||||||
|
region_name: Optional[str] = None,
|
||||||
|
) -> Embeddings:
|
||||||
|
try:
|
||||||
|
output = BedrockEmbeddings(
|
||||||
|
credentials_profile_name=credentials_profile_name,
|
||||||
|
model_id=model_id,
|
||||||
|
endpoint_url=endpoint_url,
|
||||||
|
region_name=region_name,
|
||||||
|
) # type: ignore
|
||||||
|
except Exception as e:
|
||||||
|
raise ValueError("Could not connect to AmazonBedrock API.") from e
|
||||||
|
return output
|
||||||
0
src/backend/langflow/components/embeddings/__init__.py
Normal file
0
src/backend/langflow/components/embeddings/__init__.py
Normal file
|
|
@ -106,7 +106,7 @@ embeddings:
|
||||||
documentation: "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/cohere"
|
documentation: "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/cohere"
|
||||||
VertexAIEmbeddings:
|
VertexAIEmbeddings:
|
||||||
documentation: "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/google_vertex_ai_palm"
|
documentation: "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/google_vertex_ai_palm"
|
||||||
BedrockEmbeddings:
|
AmazonBedrockEmbeddings:
|
||||||
documentation: "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/bedrock"
|
documentation: "https://python.langchain.com/docs/modules/data_connection/text_embedding/integrations/bedrock"
|
||||||
|
|
||||||
llms:
|
llms:
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ export const nodeIconsLucide: iconsType = {
|
||||||
ArrowUpToLine: ArrowUpToLine,
|
ArrowUpToLine: ArrowUpToLine,
|
||||||
Chroma: ChromaIcon,
|
Chroma: ChromaIcon,
|
||||||
AirbyteJSONLoader: AirbyteIcon,
|
AirbyteJSONLoader: AirbyteIcon,
|
||||||
BedrockEmbeddings: AWSIcon,
|
AmazonBedrockEmbeddings: AWSIcon,
|
||||||
Anthropic: AnthropicIcon,
|
Anthropic: AnthropicIcon,
|
||||||
ChatAnthropic: AnthropicIcon,
|
ChatAnthropic: AnthropicIcon,
|
||||||
BingSearchAPIWrapper: BingIcon,
|
BingSearchAPIWrapper: BingIcon,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue