Research topics using web search (Tavily/DuckDuckGo) and summarize with LLM
This feature researches topics using web search providers and provides summarized context. It supports both Tavily (API-based) and DuckDuckGo (scraper-based) providers.
_performResearch (searchUtils.ts)
├── SearchManager.getProvider(settings)
│ ├── TavilyProvider (if searchProvider='tavily')
│ └── DuckDuckGoProvider (if searchProvider='duckduckgo')
├── provider.search(query, settings)
│ └── Returns SearchResult[]
├── fetchContentFromUrl(url) [For DuckDuckGo only]
│ └── requestUrl({url, method: 'GET'})
│ └── Extract text from HTML
├── Combine research context
└── Return combined context string
tavilyApiKey, tavilyMaxResults, tavilySearchDepthddgMaxResults, ddgFetchTimeoutPerforms web research for a topic and returns combined context.
export async function _performResearch(
settings: NotemdSettings,
topic: string,
progressReporter: ProgressReporter,
): Promise<string | null>;
Fetches content from a URL and extracts text.
export async function fetchContentFromUrl(
url: string,
progressReporter: ProgressReporter,
debugMode?: boolean,
): Promise<string>;
// Returns extracted text or error message
Factory for getting search provider.
export class SearchManager {
static getProvider(settings: NotemdSettings): SearchProvider;
// Returns TavilyProvider or DuckDuckGoProvider
}
| Setting | Description |
| ---------------- | ------------------------ |
| searchProvider | 'tavily' or 'duckduckgo' |
| tavilyApiKey | API key for Tavily |
| Setting | Description |
| ------------------- | ------------------------------ |
| tavilyMaxResults | Number of results (default: 5) |
| tavilySearchDepth | 'basic' or 'advanced' |
| Setting | Description |
| ----------------- | -------------------------------- |
| ddgMaxResults | Number of results (default: 5) |
| ddgFetchTimeout | Timeout in seconds (default: 10) |
| Setting | Description |
| ----------------------- | -------------------------------------------------------- |
| enableFocusedLearning | Inject macro user domain preferences globally |
| focusedLearningDomain | The specific domain context (e.g., "Physics", "History") |
| Setting | Description |
| -------------------------- | ------------------------------- |
| maxResearchContentTokens | Max tokens for research context |
| enableApiErrorDebugMode | Enable detailed error logging |
From promptUtils.ts:
Summarize the following search results for the topic "{TOPIC}".
Provide a concise yet comprehensive overview.
Focus on key findings, data, and important conclusions.
Format the summary in Markdown.
The output language should be {LANGUAGE}.
Search Results:
{SEARCH_RESULTS_CONTEXT}
Research context is formatted as:
Research context for "{query}" (via {provider}):
Result 1:
Title: {title}
URL: {url}
Content: {content}
Result 2:
Title: {title}
...
No API key for Tavily
Network timeout
ddgFetchTimeoutNo search results
Enable enableApiErrorDebugMode for detailed error information including:
Category:web-search