Skip to main content
WebSearchTools forwards backend and timelimit to separate DDGS text and news methods, whose supported values differ. The source leaves news enabled on its text-search toolkits, although some configured backends and timelimit="y" are text-only. Its regional comparison also executes only the US agent. Apply the corrections below before running.
websearch_tools_advanced.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your OpenAI API key

4

Keep text-search settings on the text tool

Add enable_news=False to every WebSearchTools(...) configuration except the one used by news_agent. That keeps each configured text backend and time limit away from DDGS news search.
5

Run every regional comparison

After the existing us_regional.print_response(...) call, add matching uk_regional.print_response(...) and de_regional.print_response(...) calls with the same prompt and markdown=True.
6

Run the example

Save the code above as websearch_tools_advanced.py, then run:
Full source: cookbook/91_tools/websearch_tools_advanced.py