Skip to main content

search-stream

ai-research-agent / search/search-stream

searchSTREAM()

function searchSTREAM(query, options?): Promise<any[]>

🤖🔎 STREAM: Search with Top Result Extraction & Answer Model

  1. Searches the Web for the query via metasearch of major engines or custom data.
  2. Extracts text of top results using Tractor the Text Extractor.
  3. Implements SEEKTOPIC to extract Keyphrase Topics and Top Sentences that centralize those topics.
  4. Reranks document chunks based on relevance to the query, using embeddings to
    convert text to concept vectors within LLM "concept space", and calculates cosine similarity of query to topic.
  5. Uses a Research Agent prompt with key sentences from relevant sources to generate an answer via Groq Llama, OpenAI, or Anthropic API, and suggests follow-up queries.

Parameters

ParameterTypeDescription

query

string

The search query string.

options?

{ categoryIndex: number; customSearxngDomain: null | string; maxRetries: number; maxTopResultsToExtract: number; recencyIndex: number; }

options.categoryIndex?

number

default=0 - Index of the search category.

options.customSearxngDomain?

null | string

default=null - Use your custom domain SearXNG

options.maxRetries?

number

default=5 - Maximum number of retry attempts for the search.

options.maxTopResultsToExtract?

number

default=6 - Maximum number of top results to extract and analyze.

options.recencyIndex?

number

default=0 - Index representing the recency of results.

Returns

Promise<any[]>

A promise that resolves to an array containing the search results, extracted information, and generated answer.

Example

const advancedResults = await searchSTREAM('Latest developments in quantum computing', {
categoryIndex: 2,
recencyIndex: 1,
maxRetries: 5,
maxTopResultsToExtract: 10
});

Author

ai-research-agent (2024)