The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Community: Adds ability to pass a Config to the boto3 client used by Bedrock (#15029)
Blane Honeycutt3fc1b3553b62
diff --git a/libs/community/langchain_community/llms/bedrock.py b/libs/community/langchain_community/llms/bedrock.pyindex dca8cd5f8f..90187100d1 100644--- a/libs/community/langchain_community/llms/bedrock.py+++ b/libs/community/langchain_community/llms/bedrock.py@@ -1,7 +1,9 @@+from __future__ import annotations+import jsonimport warningsfrom abc import ABC-from typing import Any, Dict, Iterator, List, Mapping, Optional+from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Mapping, Optionalfrom langchain_core.callbacks import CallbackManagerForLLMRunfrom langchain_core.language_models.llms import LLM@@ -15,6 +17,9 @@ from langchain_community.utilities.anthropic import (get_token_ids_anthropic,)+if TYPE_CHECKING:+ from botocore.config import Config+HUMAN_PROMPT = "\n\nHuman:"ASSISTANT_PROMPT = "\n\nAssistant:"ALTERNATION_ERROR = (@@ -163,6 +168,9 @@ class BedrockBase(BaseModel, ABC):See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html"""+ config: Optional[Config] = None+ """An optional botocore.config.Config instance to pass to the client."""+model_id: str"""Id of the model to call, e.g., amazon.titan-text-express-v1, this isequivalent to the modelId property in the list-foundation-models api"""@@ -212,6 +220,8 @@ class BedrockBase(BaseModel, ABC):client_params["region_name"] = values["region_name"]if values["endpoint_url"]:client_params["endpoint_url"] = values["endpoint_url"]+ if values["config"]:+ client_params["config"] = values["config"]values["client"] = session.client("bedrock-runtime", **client_params)