# tools.search


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## The tool

Brave’s REST API returns a JSON document; we keep only the top `k` web
results and collapse each into a short `title / url / description`
block. That gives the model enough to decide whether to follow up
(potentially with another tool, like a future `fetch_url`) without
spending tokens on Brave’s auxiliary fields.

The schema is hand-written for now. Auto-generating it from the
function’s signature is a fine future move, but writing it explicitly
here keeps the dependency surface tiny and makes the contract obvious to
a reader of the file.

``` python
web_search.schema['function']['name'], list(web_search.schema['function']['parameters']['properties'])
```

    ('web_search', ['query', 'k'])

Smoke test — only runs when the key is present, so doc builds without
credentials stay green:

``` python
if os.environ.get("BRAVE_API_KEY"):
    print(_brave_search("nbdev fastai", k=2)[:400])
```

    ## nbdev – Create delightful software with Jupyter Notebooks ...
    https://nbdev.fast.ai/
    Write, test, document, and distribute software packages and technical articles — all in one place, your notebook.

    ## End-To-End Walkthrough - nbdev - Fast.ai
    https://nbdev.fast.ai/tutorial.html
    Write, test, document, and distribute software packages and technical articles — all in one place, your notebook.
