Skip to content

Commit

Permalink
toggle summary
Browse files Browse the repository at this point in the history
  • Loading branch information
Endle committed Sep 1, 2024
1 parent e5c827b commit 55f739a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
22 changes: 9 additions & 13 deletions fireSeqSearch_addon/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ function createTitleBarDom(count) {
btn.appendChild(text);
btn.onclick = function () {
setSummaryState(".fireSeqSearchHitSummary", true);
setSummaryState(".fireSeqSearchLlmSummary", false);
};
titleBar.appendChild(btn);

Expand All @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -258,18 +252,18 @@ 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();
console.log(text);
}
}

// for the data div, may be I can create three, and let user switch between them
async function mainProcess(fetchResultArray) {
consoleLogForDebug("main process");

Expand All @@ -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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion fire_seq_search_server/debug_server_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 55f739a

Please sign in to comment.