Add web search results to LLM prompts.
Requires an official server plugin to be installed and enabled.
See SillyTavern-WebSearch-Selenium for more details.
Supports Google and DuckDuckGo engines.
Requires a websearch
module and Chrome/Firefox web browser installed on the host machine.
Supports Google and DuckDuckGo engines.
Requires SerpApi key and provides access to Google search.
Get the key here: https://serpapi.com/dashboard
Requires a SearXNG instance URL (either private or public). Uses HTML format for search results.
Learn more: https://docs.searxng.org/
Requires an API key.
Get the key here: https://app.tavily.com/
- Make sure you use the latest version of SillyTavern (staging branch preferred).
- Install the extension via the "Download Extensions & Assets" menu in SillyTavern.
- Open the "Web Search" extension settings, set your API key, and enable the extension.
- The web search results will be added to the prompt organically as you chat. Only user messages trigger the search.
- To include search results more organically, wrap search queries with single backticks:
Tell me about the `latest Ryan Gosling movie`.
will produce a search querylatest Ryan Gosling movie
. - Optionally, configure the settings to your liking.
- Enabled - toggles the extension on and off.
- Sources = sets the search results source.
- Cache Lifetime - how long (in seconds) the search results are cached for your prompt. Default = one week.
- Prompt Budget - sets the maximum capacity of the inserted text (in characters of text, NOT tokens). Rule of thumb: 1 token ~ 3-4 characters, adjust according to your model's context limits. Default = 1500 characters.
- Insertion Template - how the result gets inserted into the prompt. Supports the usual macro + special macro:
{{query}}
for search query and{{text}}
for search results. - Injection Position - where the result goes in the prompt. The same options as for the Author's Note: as in-chat injection or before/after system prompt.
- Use Function Tool - uses function calling to activate search or scrape web pages. Must use a supported Chat Completion API and be enabled in the AI Response settings. Disables all other activation methods when engaged.
- Use Backticks - enables search activation using words encased in single backticks.
- Use Trigger Phrases - enables search activation using trigger phrases.
- Regular expressions - provide a JS-flavored regex to match the user message. If the regex matches, the search with a given query will be triggered. Search query supports
{{macros}}
and $1-syntax to reference the matched group. Example:/what is happening in (.*)/i
regex for search querynews in $1
will match a message containingwhat is happening in New York
and trigger the search with the querynews in New York
. - Trigger Phrases - add phrases that will trigger the search, one by one. It can be anywhere in the message, and the query starts from the trigger word and spans to "Max Words" total. To exclude a specific message from processing, it must start with a period, e.g.
.What do you think?
. Priority of triggers: first by order in the textbox, then the first one in the user message. - Max Words - how many words are included in the search query (including the trigger phrase). Google has a limit of about 32 words per prompt. Default = 10 words.
- Visit Links - text will be extracted from the visited search result pages and saved to a file attachment.
- Visit Count - how many links will be visited and parsed for text.
- Visit Domain Blacklist - site domains to be excluded from visiting. One per line.
- File Header - file header template, inserted at the start of the text file, has an additional
{{query}}
macro. - Block Header - link block template, inserted with the parsed content of every link. Use
{{link}}
macro for page URL and{{text}}
for page content. - Save Target - where to save the results of scraping. Possible options: trigger message attachments, or chat attachments of Data Bank (only on release >=1.12.0).
Search results from the latest query will stay included in the prompt until the next valid query is found. If you want to ask additional questions without accidentally triggering the search, start your message with a period.
Priority of triggers (if multiple are enabled):
- Backticks.
- Regular expressions.
- Trigger phrases.
To discard all previous queries from processing, start the user message with an exclamation mark, for example, a user message !Now let's talk about...
will discard this and every message above it.
This extension also provides a /websearch
slash command to use in STscript. More info here: https://docs.sillytavern.app/usage/st-script/
/websearch (links=on|off snippets=on|off [query]) – performs a web search query. Use named arguments to specify what to return - page snippets (default: on) or full parsed pages (default: off) or both.
Example: /websearch links=off snippets=on how to make a sandwich
- Answer box. Direct answer to the question.
- Knowledge graph. Encyclopedic knowledge about the topic.
- Page snippets (max 10). Relevant extracts from the web pages.
- Relevant questions (max 10). Questions and answers to similar topics.
- Google - answer box, knowledge graph, page snippets.
- DuckDuckGo - page snippets.
- Infobox.
- Page snippets.
- Answer.
- Page contents.