Repository navigation
Replies: 3 comments
|
kytkhrz |
|
As of now, web search functionality through Claude on AWS Bedrock is not supported in langchain-aws. Here's why:
AlternativesIf you need web search with LangChain, you can: Option 1: Use LangChain's built-in web search toolsfrom langchain_community.tools import TavilySearchResults
from langchain_aws import ChatBedrockConverse
llm = ChatBedrockConverse(model="anthropic.claude-3-5-sonnet-20240620-v1:0")
search = TavilySearchResults()
# Bind the search tool to the LLM
llm_with_tools = llm.bind_tools([search])Option 2: Use Anthropic API directly for web searchIf you specifically need Anthropic's built-in web search, use from langchain_anthropic import ChatAnthropic
llm = ChatAnthropic(model="claude-sonnet-4-20250514")
# Anthropic's web search is available via their APIOption 3: Implement a custom toolfrom langchain_core.tools import tool
import requests
@tool
def web_search(query: str) -> str:
"Search the web for information."
# Use your preferred search API
response = requests.get(f"https://api.search.service/search?q={query}")
return response.text
llm_with_tools = llm.bind_tools([web_search])For the latest updates on Bedrock feature support, check the AWS Bedrock documentation. |
|
Thanks kytkhrz for linking the Anthropic announcement in the question, and Piyush Jain (@3coins) and code-by-mahereddy for the earlier answers. The core point still holds and I re-checked it below: Anthropic's server-side What has changed since June is the second half.
# pip install "langchain-aws[tools]" # brings bedrock-agentcore>=1.23.0
from langchain.agents import create_agent
from langchain_aws import ChatBedrockConverse
from langchain_aws.tools import create_web_search_toolkit
toolkit, tools = create_web_search_toolkit(
region="us-east-1", # us-east-1, eu-west-1 or ap-northeast-1, per the notebook
gateway_id="<AgentCore gateway with a web-search target>",
target_name="amazon-web-search",
)
model = ChatBedrockConverse(model="us.anthropic.claude-sonnet-4-5-20250929-v1:0")
agent = create_agent(model, tools=tools)Two caveats. The toolkit needs an AgentCore Gateway with the web search connector target, and the connector is enabled per account; the notebook creates the gateway and lists the two IAM permissions involved. I had no gateway to point at, so the last row is the offline construction plus the source, not a live search. On the model: Run output and source pointersBedrock and The new toolkit, constructed with sockets blocked (no gateway available to me): Source, |
Uh oh!
There was an error while loading. Please reload this page.
Hi there,
I recently came across an update on the Anthropic website stating that "Claude can now search the web" (source).
I wanted to confirm if this functionality is supported when using langchain-aws with the Bedrock Claude 3.7 Sonnet model.
If it is supported, could you provide guidance on how to enable or integrate the web search capability?
If not, are there plans to add this feature in the future?
Thank you for your help!
All reactions