MCPcopy Create free account
hub / github.com/SillyTavern/Extension-WebSearch / doSeleniumPluginQuery

Function doSeleniumPluginQuery

index.js:967–991  ·  view source on GitHub ↗

* Performs a search query via the Selenium search plugin. * @param {string} query Search query * @returns {Promise<{textBits: string[], links: string[], images: string[]}>} Lines of search results.

(query)

Source from the content-addressed store, hash-verified

965 * @returns {Promise<{textBits: string[], links: string[], images: string[]}>} Lines of search results.
966 */
967async function doSeleniumPluginQuery(query) {
968 const result = await fetch('/api/plugins/selenium/search', {
969 method: 'POST',
970 headers: getRequestHeaders(),
971 body: JSON.stringify({
972 query: query,
973 engine: extension_settings.websearch.extras_engine,
974 include_images: extension_settings.websearch.include_images,
975 }),
976 });
977
978 if (!result.ok) {
979 const text = await result.text();
980 console.debug('WebSearch: search request failed', result.statusText, text);
981 return;
982 }
983
984 const data = await result.json();
985 console.debug('WebSearch: search response', data);
986
987 const textBits = data.results.split('\n');
988 const links = Array.isArray(data.links) ? data.links : [];
989 const images = Array.isArray(data.images) ? data.images : [];
990 return { textBits, links, images };
991}
992
993/**
994 * Performs a search query via Tavily.

Callers 1

callSearchSourceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected