Skip to main content

search-stream

Documentation / search/search-stream

searchSTREAM()​

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

Defined in: packages/ai-research-agent/src/search/search-stream.js:34

🤖🔎 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; recencyIndex: number; maxRetries: number; maxTopResultsToExtract: number; customSearxngDomain: string; }

options.categoryIndex?

number

default=0 - Index of the search category.

options.recencyIndex?

number

default=0 - Index representing the recency of results.

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.customSearxngDomain?

string

default=null - Use your custom domain SearXNG

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)