MCPcopy Create free account
hub / github.com/developersdigest/llm-answer-engine / searchEngineForSources

Function searchEngineForSources

express-api/index.js:45–58  ·  view source on GitHub ↗
(message)

Source from the content-addressed store, hash-verified

43 }
44 // 10. Define search engine function
45 async function searchEngineForSources(message) {
46 console.log(`3. Initializing Search Engine Process`);
47 // 11. Initialize BraveSearch
48 const loader = new BraveSearch({ apiKey: process.env.BRAVE_SEARCH_API_KEY });
49 // 12. Rephrase the message
50 const rephrasedMessage = await rephraseInput(message);
51 console.log(`6. Rephrased message and got documents from BraveSearch`);
52 // 13. Get documents from BraveSearch
53 const docs = await loader.call(rephrasedMessage, { count: numberOfPagesToScan });
54 // 14. Normalize data
55 const normalizedData = normalizeData(docs);
56 // 15. Process and vectorize the content
57 return await Promise.all(normalizedData.map(fetchAndProcess));
58 }
59 // 16. Normalize data
60 function normalizeData(docs) {
61 return JSON.parse(docs)

Callers 1

index.jsFile · 0.85

Calls 2

rephraseInputFunction · 0.85
normalizeDataFunction · 0.85

Tested by

no test coverage detected