Search backends: the functions the search capabilities are built on.
A backend is just (fn [{:keys [query max-results]}] -> [{:title :url :snippet}]), so anything can be one: a public search API, your own index, an internal wiki. The named ones below are conveniences.
Search backends: the functions the search capabilities are built on.
A backend is just (fn [{:keys [query max-results]}] -> [{:title :url :snippet}]),
so anything can be one: a public search API, your own index, an internal wiki.
The named ones below are conveniences.(brave {:keys [api-key timeout-ms base-url]})https://brave.com/search/api - key: :api-key or BRAVE_API_KEY.
https://brave.com/search/api - key: :api-key or BRAVE_API_KEY.
(duckduckgo {:keys [timeout-ms base-url]})Scrapes DuckDuckGo's no-JavaScript endpoint. No API key, but it is a public HTML page: DuckDuckGo may answer with a bot challenge instead of results, in which case you get none. For anything load-bearing, use a keyed backend.
Scrapes DuckDuckGo's no-JavaScript endpoint. No API key, but it is a public HTML page: DuckDuckGo may answer with a bot challenge instead of results, in which case you get none. For anything load-bearing, use a keyed backend.
(format-results query results {:keys [snippet-length] :or {snippet-length 300}})Renders results for the model: numbered, with the URL on its own line so it can be quoted back accurately.
Renders results for the model: numbered, with the URL on its own line so it can be quoted back accurately.
(google {:keys [api-key cx timeout-ms base-url]})Google's official Custom Search JSON API.
Needs two things, both from https://developers.google.com/custom-search/v1/overview: :api-key an API key (or GOOGLE_API_KEY) :cx the id of a Programmable Search Engine (or GOOGLE_CSE_ID). Set that engine to 'Search the entire web' for general web search.
The free tier is 100 queries a day. Google caps num at 10 per request.
Google's official Custom Search JSON API.
Needs two things, both from https://developers.google.com/custom-search/v1/overview:
:api-key an API key (or GOOGLE_API_KEY)
:cx the id of a Programmable Search Engine (or GOOGLE_CSE_ID). Set that
engine to 'Search the entire web' for general web search.
The free tier is 100 queries a day. Google caps `num` at 10 per request.(parse-brave body)(parse-duckduckgo html)Pulls results out of the html.duckduckgo.com results page.
Pulls results out of the html.duckduckgo.com results page.
(parse-google body)(parse-serper body)(parse-tavily body)(parse-wikipedia body)(parse-wikipedia body site)Article urls are built from the wiki that was searched, not a fixed one: a :language of "lt" searches lt.wikipedia, and its articles do not exist under en.wikipedia.
Article urls are built from the wiki that was searched, not a fixed one: a :language of "lt" searches lt.wikipedia, and its articles do not exist under en.wikipedia.
(query-string params)Builds a url-encoded query string. The JDK client takes a url, not a params map, so we assemble it here.
Builds a url-encoded query string. The JDK client takes a url, not a params map, so we assemble it here.
(serper {:keys [api-key timeout-ms base-url]})https://serper.dev - Google results. Key: :api-key or SERPER_API_KEY.
https://serper.dev - Google results. Key: :api-key or SERPER_API_KEY.
(strip-tags s)Search snippets come back with <b> highlighting; drop the markup.
Search snippets come back with <b> highlighting; drop the markup.
(tavily {:keys [api-key timeout-ms search-depth base-url]})https://tavily.com - a search API built for LLMs. Key: :api-key or TAVILY_API_KEY.
https://tavily.com - a search API built for LLMs. Key: :api-key or TAVILY_API_KEY.
(unescape-html s)Decodes the entities that turn up in search result titles and snippets.
Decodes the entities that turn up in search result titles and snippets.
(wikipedia {:keys [timeout-ms language base-url]})Searches Wikipedia through the MediaWiki API. No key needed.
:language picks the edition, and the urls returned point at it.
Searches Wikipedia through the MediaWiki API. No key needed. `:language` picks the edition, and the urls returned point at it.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |