diff --git a/fireSeqSearch_addon/main.js b/fireSeqSearch_addon/main.js index 68b6bb0..ac6b02c 100644 --- a/fireSeqSearch_addon/main.js +++ b/fireSeqSearch_addon/main.js @@ -172,6 +172,7 @@ function createTitleBarDom(count) { btn.appendChild(text); btn.onclick = function () { setSummaryState(".fireSeqSearchHitSummary", true); + setSummaryState(".fireSeqSearchLlmSummary", false); }; titleBar.appendChild(btn); @@ -181,6 +182,7 @@ function createTitleBarDom(count) { text = document.createTextNode("LLM"); btn.appendChild(text); btn.onclick = function () { + setSummaryState(".fireSeqSearchHitSummary", false); setSummaryState(".fireSeqSearchLlmSummary", true); }; titleBar.appendChild(btn); @@ -196,20 +198,12 @@ function createFireSeqDom(count) { return div; } -async function appendResultToSearchResult(serverInfo, parsedSearchResult) { +async function appendResultToSearchResult(serverInfo, parsedSearchResult, dom) { const firefoxExtensionUserOption = await checkUserOptions(); consoleLogForDebug('Loaded user option: ' + JSON.stringify(firefoxExtensionUserOption)); - const dom = createFireSeqDom(parsedSearchResult.length); - - //dom.appendChild(createTitleBarDom(parsedSearchResult.length)); - - consoleLogForDebug("dom created:"); - consoleLogForDebug(dom); - - function buildListItems(parsedSearchResult) { const hitList = document.createElement("ul"); for (const record of parsedSearchResult) { @@ -258,10 +252,11 @@ async function appendResultToSearchResult(serverInfo, parsedSearchResult) { insertDivToWebpage(dom); } -async function processLlmSummary(serverInfo, parsedSearchResult) { +async function processLlmSummary(serverInfo, parsedSearchResult, dom) { for (const record of parsedSearchResult) { // TODO remove hard code port const llm_api = "http://127.0.0.1:3030/summarize/" + record.title; + console.log("llm called"); console.log(record.title); const response = await fetch(llm_api); const text = await response.text(); @@ -269,7 +264,6 @@ async function processLlmSummary(serverInfo, parsedSearchResult) { } } -// for the data div, may be I can create three, and let user switch between them async function mainProcess(fetchResultArray) { consoleLogForDebug("main process"); @@ -282,11 +276,13 @@ async function mainProcess(fetchResultArray) { console.log(rawSearchResult); console.log(parsedSearchResult); - appendResultToSearchResult(serverInfo, parsedSearchResult); + const fireDom = createFireSeqDom(parsedSearchResult.length); + + appendResultToSearchResult(serverInfo, parsedSearchResult, fireDom); if (serverInfo.llm_enabled) { consoleLogForDebug("llm"); - processLlmSummary(serverInfo, parsedSearchResult); + processLlmSummary(serverInfo, parsedSearchResult, fireDom); } } diff --git a/fire_seq_search_server/debug_server_mac.sh b/fire_seq_search_server/debug_server_mac.sh index 08dd96a..accc2a3 100644 --- a/fire_seq_search_server/debug_server_mac.sh +++ b/fire_seq_search_server/debug_server_mac.sh @@ -7,4 +7,5 @@ cp target/debug/fire_seq_search_server ./fire_seq_search_server export RUST_LOG="warn,fire_seq_search_server=info" #export RUST_LOG="debug" export RUST_BACKTRACE=1 -./fire_seq_search_server --notebook_path ~/logseq --enable-journal-query +./fire_seq_search_server --notebook_path ~/logseq +#--enable-journal-query