diff --git a/libs/aws/langchain_aws/chat_models/bedrock.py b/libs/aws/langchain_aws/chat_models/bedrock.py index 8511cf5f..e058bb98 100644 --- a/libs/aws/langchain_aws/chat_models/bedrock.py +++ b/libs/aws/langchain_aws/chat_models/bedrock.py @@ -24,6 +24,8 @@ BaseChatModel, LangSmithParams, LanguageModelInput, + ModelProfile, + ModelProfileRegistry, ) from langchain_core.language_models.chat_models import generate_from_stream from langchain_core.messages import ( @@ -49,9 +51,11 @@ from langchain_core.utils.pydantic import TypeBaseModel, is_basemodel_subclass from langchain_core.utils.utils import _build_model_kwargs from pydantic import BaseModel, ConfigDict, Field, model_validator +from typing_extensions import Self from langchain_aws.chat_models._compat import _convert_from_v1_to_anthropic from langchain_aws.chat_models.bedrock_converse import ChatBedrockConverse +from langchain_aws.data._profiles import _PROFILES from langchain_aws.function_calling import ( AnthropicTool, ToolsOutputParser, @@ -77,6 +81,14 @@ logger = logging.getLogger(__name__) +_MODEL_PROFILES = cast("ModelProfileRegistry", _PROFILES) + + +def _get_default_model_profile(model_name: str) -> ModelProfile: + default = _MODEL_PROFILES.get(model_name) or {} + return default.copy() + + def _convert_one_message_to_text_llama(message: BaseMessage) -> str: if isinstance(message, ChatMessage): message_text = f"\n\n{message.role.capitalize()}: {message.content}" @@ -844,6 +856,14 @@ def build_extra(cls, values: dict[str, Any]) -> Any: } return values + @model_validator(mode="after") + def _set_model_profile(self) -> Self: + """Set model profile if not overridden.""" + if self.profile is None: + model_id = re.sub(r"^[A-Za-z]{2}\.", "", self.model_id) + self.profile = _get_default_model_profile(model_id) + return self + @property def lc_attributes(self) -> Dict[str, Any]: attributes: Dict[str, Any] = {} diff --git a/libs/aws/langchain_aws/chat_models/bedrock_converse.py b/libs/aws/langchain_aws/chat_models/bedrock_converse.py index 2606f37e..fd40594f 100644 --- a/libs/aws/langchain_aws/chat_models/bedrock_converse.py +++ b/libs/aws/langchain_aws/chat_models/bedrock_converse.py @@ -24,7 +24,12 @@ from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.exceptions import OutputParserException -from langchain_core.language_models import BaseChatModel, LanguageModelInput +from langchain_core.language_models import ( + BaseChatModel, + LanguageModelInput, + ModelProfile, + ModelProfileRegistry, +) from langchain_core.language_models.base import LangSmithParams from langchain_core.messages import ( AIMessage, @@ -58,6 +63,7 @@ from typing_extensions import Self from langchain_aws.chat_models._compat import _convert_from_v1_to_converse +from langchain_aws.data._profiles import _PROFILES from langchain_aws.function_calling import ToolsOutputParser from langchain_aws.utils import ( count_tokens_api_supported_for_model, @@ -66,6 +72,16 @@ ) logger = logging.getLogger(__name__) + + +_MODEL_PROFILES = cast("ModelProfileRegistry", _PROFILES) + + +def _get_default_model_profile(model_name: str) -> ModelProfile: + default = _MODEL_PROFILES.get(model_name) or {} + return default.copy() + + _BM = TypeVar("_BM", bound=BaseModel) EMPTY_CONTENT = "." @@ -837,6 +853,14 @@ def validate_environment(self) -> Self: return self + @model_validator(mode="after") + def _set_model_profile(self) -> Self: + """Set model profile if not overridden.""" + if self.profile is None: + model_id = re.sub(r"^[A-Za-z]{2}\.", "", self.model_id) + self.profile = _get_default_model_profile(model_id) + return self + def _get_base_model(self) -> str: """Return base model id, stripping any regional prefix.""" diff --git a/libs/aws/langchain_aws/data/__init__.py b/libs/aws/langchain_aws/data/__init__.py new file mode 100644 index 00000000..07c24b14 --- /dev/null +++ b/libs/aws/langchain_aws/data/__init__.py @@ -0,0 +1 @@ +"""Model profile data. All edits should be made in profile_augmentations.toml.""" diff --git a/libs/aws/langchain_aws/data/_profiles.py b/libs/aws/langchain_aws/data/_profiles.py new file mode 100644 index 00000000..c019b8b1 --- /dev/null +++ b/libs/aws/langchain_aws/data/_profiles.py @@ -0,0 +1,691 @@ +"""Auto-generated model profiles. + +DO NOT EDIT THIS FILE MANUALLY. +This file is generated by the langchain-profiles CLI tool. + +It contains data derived from the models.dev project. + +Source: https://github.com/sst/models.dev +License: MIT License + +To update these data, refer to the instructions here: + +https://docs.langchain.com/oss/python/langchain/models#updating-or-overwriting-profile-data +""" + +from typing import Any + +_PROFILES: dict[str, dict[str, Any]] = { + "cohere.command-r-plus-v1:0": { + "max_input_tokens": 128000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-v2": { + "max_input_tokens": 100000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": False, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-3-7-sonnet-20250219-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 8192, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-sonnet-4-20250514-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": True, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "qwen.qwen3-coder-30b-a3b-v1:0": { + "max_input_tokens": 262144, + "max_output_tokens": 131072, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama3-2-11b-instruct-v1:0": { + "max_input_tokens": 128000, + "max_output_tokens": 4096, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-3-haiku-20240307-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 4096, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama3-2-90b-instruct-v1:0": { + "max_input_tokens": 128000, + "max_output_tokens": 4096, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama3-2-1b-instruct-v1:0": { + "max_input_tokens": 131000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-v2:1": { + "max_input_tokens": 200000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": False, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "deepseek.v3-v1:0": { + "max_input_tokens": 163840, + "max_output_tokens": 81920, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": True, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "cohere.command-light-text-v14": { + "max_input_tokens": 4096, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": False, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "ai21.jamba-1-5-large-v1:0": { + "max_input_tokens": 256000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama3-3-70b-instruct-v1:0": { + "max_input_tokens": 128000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-3-opus-20240229-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 4096, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "amazon.nova-pro-v1:0": { + "max_input_tokens": 300000, + "max_output_tokens": 8192, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": True, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama3-1-8b-instruct-v1:0": { + "max_input_tokens": 128000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "qwen.qwen3-32b-v1:0": { + "max_input_tokens": 16384, + "max_output_tokens": 16384, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": True, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-3-5-sonnet-20240620-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 8192, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-haiku-4-5-20251001-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": True, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "cohere.command-r-v1:0": { + "max_input_tokens": 128000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "amazon.nova-micro-v1:0": { + "max_input_tokens": 128000, + "max_output_tokens": 8192, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama3-1-70b-instruct-v1:0": { + "max_input_tokens": 128000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama3-70b-instruct-v1:0": { + "max_input_tokens": 8192, + "max_output_tokens": 2048, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": False, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "deepseek.r1-v1:0": { + "max_input_tokens": 128000, + "max_output_tokens": 32768, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": True, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-3-5-sonnet-20241022-v2:0": { + "max_input_tokens": 200000, + "max_output_tokens": 8192, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "cohere.command-text-v14": { + "max_input_tokens": 4096, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": False, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-opus-4-20250514-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 32000, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": True, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "qwen.qwen3-coder-480b-a35b-v1:0": { + "max_input_tokens": 131072, + "max_output_tokens": 65536, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-sonnet-4-5-20250929-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 64000, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": True, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama3-2-3b-instruct-v1:0": { + "max_input_tokens": 131000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-instant-v1": { + "max_input_tokens": 100000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": False, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "amazon.nova-premier-v1:0": { + "max_input_tokens": 1000000, + "max_output_tokens": 16384, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": True, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": True, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-opus-4-1-20250805-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 32000, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": True, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama4-scout-17b-instruct-v1:0": { + "max_input_tokens": 3500000, + "max_output_tokens": 16384, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "ai21.jamba-1-5-mini-v1:0": { + "max_input_tokens": 256000, + "max_output_tokens": 4096, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama3-8b-instruct-v1:0": { + "max_input_tokens": 8192, + "max_output_tokens": 2048, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": False, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-3-sonnet-20240229-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 4096, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "meta.llama4-maverick-17b-instruct-v1:0": { + "max_input_tokens": 1000000, + "max_output_tokens": 16384, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "qwen.qwen3-235b-a22b-2507-v1:0": { + "max_input_tokens": 262144, + "max_output_tokens": 131072, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "amazon.nova-lite-v1:0": { + "max_input_tokens": 300000, + "max_output_tokens": 8192, + "image_inputs": True, + "audio_inputs": False, + "video_inputs": True, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, + "anthropic.claude-3-5-haiku-20241022-v1:0": { + "max_input_tokens": 200000, + "max_output_tokens": 8192, + "image_inputs": False, + "audio_inputs": False, + "video_inputs": False, + "image_outputs": False, + "audio_outputs": False, + "video_outputs": False, + "reasoning_output": False, + "tool_calling": True, + "image_url_inputs": True, + "pdf_inputs": True, + "pdf_tool_message": True, + "image_tool_message": True, + }, +} diff --git a/libs/aws/langchain_aws/data/profile_augmentations.toml b/libs/aws/langchain_aws/data/profile_augmentations.toml new file mode 100644 index 00000000..9d35d9a7 --- /dev/null +++ b/libs/aws/langchain_aws/data/profile_augmentations.toml @@ -0,0 +1,7 @@ +provider = "anthropic" + +[overrides] +image_url_inputs = true +pdf_inputs = true +pdf_tool_message = true +image_tool_message = true diff --git a/libs/aws/pyproject.toml b/libs/aws/pyproject.toml index 96f6affa..bdeb0b31 100644 --- a/libs/aws/pyproject.toml +++ b/libs/aws/pyproject.toml @@ -49,6 +49,9 @@ dev = [ "botocore-stubs>=1.38.46", ] +[tool.uv.sources] +langchain-core = { git = "https://github.com/langchain-ai/langchain", subdirectory = "libs/core", branch = "cc/model_profiles_distributed" } + [tool.uv] prerelease = "allow" diff --git a/libs/aws/tests/unit_tests/chat_models/test_bedrock.py b/libs/aws/tests/unit_tests/chat_models/test_bedrock.py index 2b7d5f07..223fdd89 100644 --- a/libs/aws/tests/unit_tests/chat_models/test_bedrock.py +++ b/libs/aws/tests/unit_tests/chat_models/test_bedrock.py @@ -26,6 +26,25 @@ from langchain_aws.function_calling import convert_to_anthropic_tool +def test_profile() -> None: + model = ChatBedrock( + model_id="anthropic.claude-3-5-sonnet-20241022-v2:0", + region_name="us-west-2", + ) + assert model.profile + assert not model.profile["reasoning_output"] + + model = ChatBedrock( + model_id="anthropic.claude-sonnet-4-20250514-v1:0", + region_name="us-west-2", + ) + assert model.profile + assert model.profile["reasoning_output"] + + model = ChatBedrock(model_id="foo") + assert model.profile == {} + + def test__merge_messages() -> None: messages = [ SystemMessage("foo"), # type: ignore[misc] diff --git a/libs/aws/tests/unit_tests/chat_models/test_bedrock_converse.py b/libs/aws/tests/unit_tests/chat_models/test_bedrock_converse.py index eaade3d9..d6211444 100644 --- a/libs/aws/tests/unit_tests/chat_models/test_bedrock_converse.py +++ b/libs/aws/tests/unit_tests/chat_models/test_bedrock_converse.py @@ -82,6 +82,25 @@ def test_init_streaming(self) -> None: super().test_init_streaming() +def test_profile() -> None: + model = ChatBedrockConverse( + model="anthropic.claude-3-5-sonnet-20241022-v2:0", + region_name="us-west-2", + ) + assert model.profile + assert not model.profile["reasoning_output"] + + model = ChatBedrockConverse( + model="anthropic.claude-sonnet-4-20250514-v1:0", + region_name="us-west-2", + ) + assert model.profile + assert model.profile["reasoning_output"] + + model = ChatBedrockConverse(model="foo") + assert model.profile == {} + + class GetWeather(BaseModel): """Get the current weather in a given location""" diff --git a/libs/aws/uv.lock b/libs/aws/uv.lock index a001252b..8d572519 100644 --- a/libs/aws/uv.lock +++ b/libs/aws/uv.lock @@ -671,7 +671,7 @@ requires-dist = [ { name = "beautifulsoup4", marker = "extra == 'tools'", specifier = ">=4.13.4" }, { name = "bedrock-agentcore", marker = "python_full_version >= '3.10' and extra == 'tools'", specifier = ">=0.1.0" }, { name = "boto3", specifier = ">=1.40.19" }, - { name = "langchain-core", specifier = ">=1.0.0" }, + { name = "langchain-core", git = "https://github.com/langchain-ai/langchain?subdirectory=libs%2Fcore&branch=cc%2Fmodel_profiles_distributed" }, { name = "numpy", marker = "python_full_version < '3.12'", specifier = ">=1.0.0,<3" }, { name = "numpy", marker = "python_full_version >= '3.12'", specifier = ">=2.3.2,<3" }, { name = "playwright", marker = "extra == 'tools'", specifier = ">=1.53.0" }, @@ -724,7 +724,7 @@ wheels = [ [[package]] name = "langchain-core" version = "1.0.7" -source = { registry = "https://pypi.org/simple" } +source = { git = "https://github.com/langchain-ai/langchain?subdirectory=libs%2Fcore&branch=cc%2Fmodel_profiles_distributed#b7ec8735b2589fe1815ce3c58e41410824bf67b7" } dependencies = [ { name = "jsonpatch" }, { name = "langsmith" }, @@ -734,10 +734,6 @@ dependencies = [ { name = "tenacity" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/69/83/dbd09c718ddd547b10b34a9cc69a46ac6bb9db89cc24c4971bc4467f0452/langchain_core-1.0.7.tar.gz", hash = "sha256:6c64399cb0f163a7e45a764cce75d80fd08b82f4e0274ca892cfbcaa2f29200b", size = 781744, upload-time = "2025-11-19T21:23:27.683Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/f0/d0/3e7b87b929e95310a219206937f614796d266bfc5e4350c32c5d6502c183/langchain_core-1.0.7-py3-none-any.whl", hash = "sha256:76af258b0e95a7915b8e301706a45ded50c75b80ff35329394d4df964416e32a", size = 472951, upload-time = "2025-11-19T21:23:26.579Z" }, -] [[package]] name = "langchain-tests"