APITools Introduction
APITools
is an experimental module wrapping helpful APIs for working with and enhancing GenerativeAI models.
Import the module as follows:
using PromptingTools.Experimental.APITools
Highlights
Currently, there is only one function in this module create_websearch
that leverages Tavily.com search and answer engine to provide additional context.
You need to sign up for an API key at Tavily.com and set it as an environment variable TAVILY_API_KEY
to use this function.
References
create_websearch(query::AbstractString;
api_key::AbstractString,
search_depth::AbstractString = "basic")
Arguments
query::AbstractString
: The query to search for.api_key::AbstractString
: The API key to use for the search. Get an API key from Tavily.search_depth::AbstractString
: The depth of the search. Can be either "basic" or "advanced". Default is "basic". Advanced search calls equal to 2 requests.include_answer::Bool
: Whether to include the answer in the search results. Default isfalse
.include_raw_content::Bool
: Whether to include the raw content in the search results. Default isfalse
.max_results::Integer
: The maximum number of results to return. Default is 5.include_images::Bool
: Whether to include images in the search results. Default isfalse
.include_domains::AbstractVector{<:AbstractString}
: A list of domains to include in the search results. Default is an empty list.exclude_domains::AbstractVector{<:AbstractString}
: A list of domains to exclude from the search results. Default is an empty list.
Example
r = create_websearch("Who is King Charles?")
Even better, you can get not just the results but also the answer:
r = create_websearch("Who is King Charles?"; include_answer = true)
See Rest API documentation for more information.