Browse modules

tavily

v0.1.0 · compiled with katari 0.1.0

Overview

from the package README

tavily — web search as a Katari tool

A single module, tavily: web search over the Tavily API, exposed as a tool the model can call. Pure Katari — the request body is built as json, the POST is the prelude's http.post_json, and the response is parsed as json. No FFI sidecar.

  • tavily.search(query) — the tool: returns the top results as a compact digest (title, URL, and a content snippet per hit), small enough to feed straight back to the model.
  • tavily.provider(api_key = ...) — provides the API key capability for the extent of a continuation, so search never takes the key as an argument.

Secrets / env

  • TAVILY_API_KEY — your Tavily API key. Store it in the runtime: katari env set TAVILY_API_KEY --secret. It is a string of private, riding the search call's Authorization header and never leaving as anything else.

Usage

import tavily
 
agent search_the_web(query: string) -> string with io {
  use tavily.provider(api_key = env.get_secret(key = "TAVILY_API_KEY"))
  tavily.search(query = query)
}

Hand tavily.search to an AI loop's tool list to let the model search on its own.

tavily

4 declarations

get_tavily_key#

request
request get_tavily_key() -> string of private

The Tavily API key capability (provided once at the root by use tavily.provider(...)).

Returns

of private
string
Wire view (JSON Schema)

provider#

agent
agent provider[R, effect E](api_key: string of private, continuation: agent(value: null) -> R with {...E, get_tavily_key}) -> R with E

Provide the Tavily API key capability for the extent of the continuation.

Generics

Rtype
Eeffect

Parameters

api_key
of private
string
continuation
agent
input
object
value
null
output
R
effects
override
base
E

Returns

R

Effects

E

Inferred type

agent(api_key: string of private, continuation: agent(value: null) -> T0 with get_tavily_key | E1) -> T0 with E1

Wire view — the wire shape is fixed at the call site, where the generic parameters are instantiated.

search#

agent
agent search(query: string) -> string

Tool: search the web and return the top results as a compact digest (title, URL, content snippet per hit — small enough to feed straight back to the model).

Parameters

query
string

Returns

string

Inferred type

agent(query: string) -> string with throw[fetch_error | status_error | parse_error] | get_tavily_key | io
Wire view (JSON Schema)

render_results#

agent
agent render_results(parsed: unknown) -> string

One digest line per result; a shape the API never promised (no results array) degrades to a note rather than an error — the model can rephrase and retry.

Parameters

parsed
unknown

Returns

string
Wire view (JSON Schema)