Integrate Anthropic Web Search Tool for Supported Models #7311
Closed
Dual-0
started this conversation in
Feature Requests & Suggestions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Anthropic's Web Search tool enhances the capability of their models by providing access to current information, overcoming knowledge cutoffs. Implementing this feature in LibreChat would significantly improve the utility of supported Anthropic models within the platform, offering users more accurate, timely, and verifiable responses, especially for topics requiring recent information.
Technical Details (Based on Anthropic API Documentation):
API Endpoint: The web search functionality is provided via the standard
messagesAPI endpoint by including atoolsparameter in the request payload.Tool Definition: The tool is defined as follows:
{ "type": "web_search_20250305", "name": "web_search", // Optional: Limit the number of searches per request "max_uses": 5, // Optional: Only include results from these domains "allowed_domains": ["example.com", "trusteddomain.org"], // Optional: Never include results from these domains "blocked_domains": ["untrustedsource.com"], // Optional: Localize search results "user_location": { "type": "approximate", "city": "San Francisco", "region": "California", "country": "US", "timezone": "America/Los_Angeles" } }LibreChat would need to allow users to enable this tool and potentially configure the optional parameters (
max_uses,allowed_domains,blocked_domains,user_location).API Flow:
1. User sends a message.
2. LibreChat constructs the API request including the
toolsarray with the web search definition if enabled for the selected model.3. The Anthropic API decides if a search is needed based on the prompt.
4. If a search is performed, the API returns
server_tool_useandweb_search_tool_resultcontent blocks in the response.5. LibreChat needs to parse these blocks to display the search activity (e.g., "Searching...") and the search results.
6. Anthropics final response will include
textblocks withcitationsreferencing the search results. LibreChat needs to parse and display these citations correctly.7. Handle multi-turn conversations: Encrypted content/indices (
encrypted_content,encrypted_index) from search results and citations must be passed back to the API in subsequent turns within theweb_search_tool_resultblocks to maintain context and citations.Error Handling: LibreChat should handle potential
web_search_tool_result_errorresponses and inform the user (e.g.,max_uses_exceeded,too_many_requests,unavailable).Streaming: If streaming is used, LibreChat must process streamed
content_block_startandcontent_block_deltaevents forserver_tool_useandweb_search_tool_resultblocks, including the pause while the search executes.Usage/Pricing: Note that Anthropic charges separately for web searches ($10 per 1,000 searches) in addition to token usage. This might be relevant information for users.
Implementation Considerations:
max_uses, location).server_tool_use,web_search_tool_result, andcitationscontent blocks in the chat interface.This feature would bring parity with the native Anthropic web search experience for users of supported models within LibreChat.
All reactions