Nova system tools helpers.
This module provides helper classes for working with Amazon Nova 2.0's system tools (nova_grounding and nova_code_interpreter).
Amazon Nova 2.0 models support built-in system tools that execute server-side. These tools enable web search (nova_grounding) and code execution (nova_code_interpreter) capabilities.
IAM Permissions Required:
System tools require the bedrock:InvokeTool IAM permission in addition
to bedrock:InvokeModel.
Web Grounding (nova_grounding): Enables the model to search the web for current information.
.. code-block:: python
from langchain_aws import ChatBedrockConverse
from langchain_aws.tools import NovaGroundingTool
model = ChatBedrockConverse(model="amazon.nova-2-lite-v1:0")
model_with_search = model.bind_tools([NovaGroundingTool()])
response = model_with_search.invoke(
"What are the latest developments in quantum computing?"
)
print(response.content)
You can also use the string name directly:
.. code-block:: python
model_with_search = model.bind_tools(["nova_grounding"])
Code Interpreter (nova_code_interpreter): Enables the model to execute Python code in a sandboxed environment.
.. code-block:: python
from langchain_aws import ChatBedrockConverse
from langchain_aws.tools import NovaCodeInterpreterTool
model = ChatBedrockConverse(model="amazon.nova-2-lite-v1:0")
model_with_code = model.bind_tools([NovaCodeInterpreterTool()])
response = model_with_code.invoke(
"Calculate the square root of 475878756857"
)
print(response.content)
Reasoning with Nova:
Nova models support reasoning configuration similar to Claude's thinking
feature, but use reasoningConfig instead of thinking.
.. code-block:: python
from langchain_aws import ChatBedrockConverse
reasoning_config = {
"reasoningConfig": {
"type": "enabled",
"maxReasoningEffort": "low" # or "medium", "high"
}
}
model = ChatBedrockConverse(
model="amazon.nova-2-lite-v1:0",
max_tokens=10000,
additional_model_request_fields=reasoning_config
)
response = model.invoke("Solve this logic puzzle: ...")
# Access reasoning content via response.content_blocks
Combining System Tools and Reasoning:
.. code-block:: python
from botocore.config import Config
from langchain_aws import ChatBedrockConverse
from langchain_aws.tools import NovaGroundingTool
# Increase timeout for reasoning and tool execution
config = Config(
connect_timeout=3600, # 60 minutes
read_timeout=3600, # 60 minutes
retries={'max_attempts': 1}
)
model = ChatBedrockConverse(
model="amazon.nova-2-lite-v1:0",
max_tokens=10000,
config=config,
additional_model_request_fields={
"reasoningConfig": {
"type": "enabled",
"maxReasoningEffort": "medium" # or "low", "high"
}
}
)
model_with_tools = model.bind_tools([NovaGroundingTool()])
response = model_with_tools.invoke(
"Research and explain the latest AI breakthroughs"
)
Timeout Recommendations:
Base class for Nova system tools.
System tools are built-in tools provided by Nova models that execute server-side. Unlike custom tools, system tools don't require client-side implementation.
Helper for Nova's web grounding system tool.
The nova_grounding tool enables the model to search the web for current information. The model autonomously decides when to invoke the tool and processes the results.
Helper for Nova's code interpreter system tool.
The nova_code_interpreter tool enables the model to execute Python code in a sandboxed environment. Useful for calculations, data analysis, and other computational tasks.