From 6f07768809c2751aa0c5e2a5fcaa6dd2d59de11a Mon Sep 17 00:00:00 2001 From: Leo310 Date: Mon, 1 Apr 2024 13:48:26 +0200 Subject: [PATCH 1/6] style(logo): final mvp version --- src/components/Chat/Input.svelte | 2 +- src/components/Logos/Logo.svelte | 106 ++++++++++++++++++ src/components/Logos/LogoSimple.svelte | 113 -------------------- src/components/Onboarding/Onboarding.svelte | 2 +- 4 files changed, 108 insertions(+), 115 deletions(-) create mode 100644 src/components/Logos/Logo.svelte delete mode 100644 src/components/Logos/LogoSimple.svelte diff --git a/src/components/Chat/Input.svelte b/src/components/Chat/Input.svelte index 2c31394..bd67553 100644 --- a/src/components/Chat/Input.svelte +++ b/src/components/Chat/Input.svelte @@ -15,7 +15,7 @@ } from '../../store'; import ProgressCircle from '../base/ProgressCircle.svelte'; import { addMessage } from '../../controller/Messages'; - import Logo from '../Logos/LogoSimple.svelte'; + import Logo from '../Logos/Logo.svelte'; export let textarea: HTMLTextAreaElement; diff --git a/src/components/Logos/Logo.svelte b/src/components/Logos/Logo.svelte new file mode 100644 index 0000000..429edae --- /dev/null +++ b/src/components/Logos/Logo.svelte @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/Logos/LogoSimple.svelte b/src/components/Logos/LogoSimple.svelte deleted file mode 100644 index cec371f..0000000 --- a/src/components/Logos/LogoSimple.svelte +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/components/Onboarding/Onboarding.svelte b/src/components/Onboarding/Onboarding.svelte index 952cdf0..3f88dee 100644 --- a/src/components/Onboarding/Onboarding.svelte +++ b/src/components/Onboarding/Onboarding.svelte @@ -7,7 +7,7 @@ import DaemonComponent from './OllamaDaemon.svelte'; import IncognitoToggle from '../Settings/IncognitoToggle.svelte'; import { t } from 'svelte-i18n'; - import Logo from '../Logos/LogoDetailed.svelte'; + import Logo from '../Logos/Logo.svelte'; const osType = os.type(); From d788f5a6fd3be1e22ac7b3a23627cd78360cd9c1 Mon Sep 17 00:00:00 2001 From: Leo310 Date: Mon, 1 Apr 2024 15:29:15 +0200 Subject: [PATCH 2/6] refactor: vector store files in seperate directory --- src/SmartSecondBrain.ts | 14 ++++++++------ src/components/Modal/PullModal.svelte | 4 ---- src/components/Modal/RemoveModal.svelte | 3 --- src/components/base/Toggle.svelte | 2 ++ src/main.ts | 6 ++---- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/SmartSecondBrain.ts b/src/SmartSecondBrain.ts index 68aacb0..862c8bb 100644 --- a/src/SmartSecondBrain.ts +++ b/src/SmartSecondBrain.ts @@ -68,8 +68,8 @@ export default class SmartSecondBrain { return new Notice(t('notice.failed', { values: { error: e } }), 4000); } // check if vector store data exists - if (await this.app.vault.adapter.exists(this.getVectorStorePath())) { - const vectorStoreData = await this.app.vault.adapter.readBinary(this.getVectorStorePath()); + if (await this.app.vault.adapter.exists(this.getVectorStoreFile())) { + const vectorStoreData = await this.app.vault.adapter.readBinary(this.getVectorStoreFile()); await this.papa.load(vectorStoreData); } } @@ -122,7 +122,7 @@ export default class SmartSecondBrain { } async cancelIndexing() { - // if (this.app.vault.adapter.exists(this.getVectorStorePath())) await this.app.vault.adapter.remove(this.getVectorStorePath()); + // if (this.app.vault.adapter.exists(this.getVectorStoreFile())) await this.app.vault.adapter.remove(this.getVectorStoreFile()); papaState.set('uninitialized'); papaIndexingProgress.set(0); } @@ -170,16 +170,18 @@ export default class SmartSecondBrain { return fileName; } - private getVectorStorePath() { + getVectorStoreFile() { const d = get(data); - return normalizePath(this.pluginDir + '/' + (d.isIncognitoMode ? d.ollamaEmbedModel.model : d.openAIEmbedModel.model) + '-vector-store.bin'); + return normalizePath(this.pluginDir + '/vectorstores/' + (d.isIncognitoMode ? d.ollamaEmbedModel.model : d.openAIEmbedModel.model) + '.bin'); } async saveVectorStoreData() { if (this.needsToSaveVectorStoreData && this.papa) { Log.debug('Saving vector store data'); this.needsToSaveVectorStoreData = false; - await this.app.vault.adapter.writeBinary(this.getVectorStorePath(), await this.papa.getData()); + // create vectorstores directory if it doesn't exist + (await this.app.vault.adapter.exists(this.pluginDir + '/vectorstores')) || (await this.app.vault.adapter.mkdir(this.pluginDir + '/vectorstores')); + await this.app.vault.adapter.writeBinary(this.getVectorStoreFile(), await this.papa.getData()); Log.info('Saved vector store data'); } } diff --git a/src/components/Modal/PullModal.svelte b/src/components/Modal/PullModal.svelte index eb88556..5cc6d4a 100644 --- a/src/components/Modal/PullModal.svelte +++ b/src/components/Modal/PullModal.svelte @@ -7,12 +7,8 @@ import { data } from '../../store'; import { OllamaGenModelNames, OllamaEmbedModelNames } from '../Settings/models'; import { getOllamaModels, ollamaGenChange, ollamaEmbedChange } from '../../controller/Ollama'; - import type { PullModal } from './PullModal'; import DotAnimation from '../base/DotAnimation.svelte'; - export let modal: PullModal; - - let model = ''; let isOllama: boolean; let pulledModel = false; let installedOllamaModels: string[] = []; diff --git a/src/components/Modal/RemoveModal.svelte b/src/components/Modal/RemoveModal.svelte index 22e18ab..3f4402c 100644 --- a/src/components/Modal/RemoveModal.svelte +++ b/src/components/Modal/RemoveModal.svelte @@ -3,12 +3,9 @@ import { deleteOllamaModels, isOllamaRunning } from '../../controller/Ollama'; import { t } from 'svelte-i18n'; import { getOllamaModels } from '../../controller/Ollama'; - import type { PullModal } from './PullModal'; import DropdownComponent from '../base/Dropdown.svelte'; import DotAnimation from '../base/DotAnimation.svelte'; - export let modal: PullModal; - let model = ''; let isOllama: boolean; let installedOllamaModels: string[] = []; diff --git a/src/components/base/Toggle.svelte b/src/components/base/Toggle.svelte index db8f987..7d6866e 100644 --- a/src/components/base/Toggle.svelte +++ b/src/components/base/Toggle.svelte @@ -3,6 +3,8 @@ export let changeFunc: () => void; + +
diff --git a/src/main.ts b/src/main.ts index 6eb9ae0..9b94c92 100644 --- a/src/main.ts +++ b/src/main.ts @@ -225,10 +225,8 @@ export default class SecondBrainPlugin extends Plugin { async (result) => { if (result === 'Yes') { await this.saveData({}); - const files = (await this.app.vault.adapter.list(normalizePath(this.manifest.dir))).files; - for (const file of files) { - if (file.endsWith('vector-store.bin')) await this.app.vault.adapter.remove(file); - } + const files = (await this.app.vault.adapter.list(normalizePath(this.manifest.dir + '/vectorstores'))).files; + for (const file of files) await this.app.vault.adapter.remove(file); new Notice(t('notice.plugin_data_cleared'), 4000); await this.loadSettings(); await this.activateView(); From d8adfd5df8c5321e2a70340cd0df33469c36fc0d Mon Sep 17 00:00:00 2001 From: Leo310 Date: Mon, 1 Apr 2024 15:30:39 +0200 Subject: [PATCH 3/6] up manifest --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index f01931b..f21b25a 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "description": "Interact with your privacy focused assistant, leveraging Ollama or OpenAI, making your second brain even smarter.", "author": "Leo310, nicobrauchtgit", "authorUrl": "https://github.com/nicobrauchtgit", - "version": "0.6.0", + "version": "0.6.1", "minAppVersion": "1.5.0", "isDesktopOnly": true } From ed49a0e91f8d257c2cd57337b871985821776620 Mon Sep 17 00:00:00 2001 From: Leo310 Date: Wed, 3 Apr 2024 14:51:39 +0200 Subject: [PATCH 4/6] fix(style): rag toggle icon covers text --- src/components/Chat/Chat.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Chat/Chat.svelte b/src/components/Chat/Chat.svelte index cbcc52e..90f973c 100644 --- a/src/components/Chat/Chat.svelte +++ b/src/components/Chat/Chat.svelte @@ -24,7 +24,7 @@ let isAutoScrolling = true; let chatWindow: HTMLDivElement; - $: if (chatWindow && $papaState === 'running' && isAutoScrolling && $chatHistory) { + $: if (chatWindow && $papaState === 'running' && isAutoScrolling && $runContent) { chatWindow.scrollTop = chatWindow.scrollHeight; } let contentNode: HTMLElement; @@ -65,7 +65,7 @@
(isAutoScrolling = chatWindow.scrollTop + chatWindow.clientHeight + 1 >= chatWindow.scrollHeight)} - class="chat-window w-full flex-grow select-text overflow-y-scroll rounded-md border border-solid border-[--background-modifier-border] bg-[--background-primary]" + class="chat-window w-full pb-8 flex-grow select-text overflow-y-scroll rounded-md border border-solid border-[--background-modifier-border] bg-[--background-primary]" > {#each $chatHistory as message (message.id)} @@ -148,5 +148,5 @@ {/if}
- +
From 7486fdb54c7330e880e6bf45565ff6fd7d671156 Mon Sep 17 00:00:00 2001 From: Leo310 Date: Fri, 5 Apr 2024 12:11:27 +0200 Subject: [PATCH 5/6] style(onboarding): imroved ux --- src/components/Onboarding/OllamaApp.svelte | 10 +++++++-- src/components/Onboarding/OllamaDaemon.svelte | 3 ++- src/components/Onboarding/OllamaSetup.svelte | 14 +++++++++---- src/components/Onboarding/Onboarding.svelte | 21 ++++++++++++------- src/components/Onboarding/OpenAI.svelte | 11 +++++++++- .../Onboarding/PullOllamaModel.svelte | 1 - src/lang/en.json | 20 +++++++++--------- 7 files changed, 53 insertions(+), 27 deletions(-) diff --git a/src/components/Onboarding/OllamaApp.svelte b/src/components/Onboarding/OllamaApp.svelte index 4d44dae..226b7d1 100644 --- a/src/components/Onboarding/OllamaApp.svelte +++ b/src/components/Onboarding/OllamaApp.svelte @@ -4,8 +4,14 @@ import { isOllamaRunning } from '../../controller/Ollama'; import OllamaSetup from './OllamaSetup.svelte'; import { t } from 'svelte-i18n'; + import { afterUpdate } from 'svelte'; export let osType: string; + export let scrollToBottom = () => {}; + + afterUpdate(() => { + scrollToBottom(); + }); let isRunning: boolean = false; let isOllamaTested: boolean = false; @@ -52,11 +58,11 @@
  • {$t('onboarding.ollama.app.restart')}
  • - {:else} + {:else if osType === 'Windows_NT'}
  • {$t('onboarding.ollama.app.quit')}
  • {$t('onboarding.ollama.app.start_origins')}
  • {/if} - + {/if} diff --git a/src/components/Onboarding/OllamaDaemon.svelte b/src/components/Onboarding/OllamaDaemon.svelte index b3038cd..7ad91e8 100644 --- a/src/components/Onboarding/OllamaDaemon.svelte +++ b/src/components/Onboarding/OllamaDaemon.svelte @@ -8,6 +8,7 @@ import { t } from 'svelte-i18n'; export let osType: string; + export let scrollToBottom = () => {}; onMount(() => { $data.isIncognitoMode = true; @@ -34,5 +35,5 @@
  • {$t('onboarding.ollama.deamon.start')}
  • - + diff --git a/src/components/Onboarding/OllamaSetup.svelte b/src/components/Onboarding/OllamaSetup.svelte index df9d49c..2afc454 100644 --- a/src/components/Onboarding/OllamaSetup.svelte +++ b/src/components/Onboarding/OllamaSetup.svelte @@ -1,6 +1,6 @@ -
    +
    @@ -29,15 +34,15 @@ {#if osType === 'Darwin'} {/if} - {#if selected === 'Ollama App' || osType === 'Windows_NT'} - + {#if selected === 'Ollama App'} + {:else} - + {/if} {:else}

    {$t('onboarding.openai_mode_note')}

    - + {/if}
    diff --git a/src/components/Onboarding/OpenAI.svelte b/src/components/Onboarding/OpenAI.svelte index 7ea1bd9..ed800b2 100644 --- a/src/components/Onboarding/OpenAI.svelte +++ b/src/components/Onboarding/OpenAI.svelte @@ -6,6 +6,13 @@ import { plugin, data } from '../../store'; import InitButtonComponent from './InitButton.svelte'; import { t } from 'svelte-i18n'; + import { afterUpdate } from 'svelte'; + + export let scrollToBottom = () => {}; + + afterUpdate(() => { + scrollToBottom(); + }); let openAIApiKey: string = $data.openAIGenModel.openAIApiKey; let isValid: boolean = false; @@ -62,5 +69,7 @@ {#if isValid} - +
    + +
    {/if} diff --git a/src/components/Onboarding/PullOllamaModel.svelte b/src/components/Onboarding/PullOllamaModel.svelte index 2e657e4..eaf23ab 100644 --- a/src/components/Onboarding/PullOllamaModel.svelte +++ b/src/components/Onboarding/PullOllamaModel.svelte @@ -18,7 +18,6 @@ let progress: number = 0; let status: string = ''; let isPullingError = false; - console.log('pullModel', pullModel); async function pullOllamaModelStream() { isPullingModel = true; diff --git a/src/lang/en.json b/src/lang/en.json index cb8238a..4964847 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -73,18 +73,18 @@ "input_placeholder": "Chat with your Smart Second Brain..." }, "onboarding": { - "welcome_msg": "Welcome to your Smart Second Brain! Your personal AI assistant that helps you to find information in your notes.", + "welcome_msg": "Welcome to your Smart Second Brain! Your personal AI assistant that helps you to find and process information in your notes.", "setup": "Setup", "test": "Test", - "privacy_mode_note": "Your assistant is running in privacy mode. That means it is not connected to the internet and is running fully locally by leveraging Ollama.", - "openai_mode_note": "Your assistant is using third party services to run. That means you will have to share all your personal information with these services and your Smart Second Brain needs to be connected to the internet to leverage OpenAIs large language models like ChatGPT.", + "privacy_mode_note": "Your assistant will run in privacy mode. That means it is not connected to the internet and is running fully locally by leveraging Ollama.", + "openai_mode_note": "Your assistant will use third-party services to run. That means you will have to share all your personal information with these services and your Smart Second Brain needs to be connected to the internet to leverage OpenAIs large language models like ChatGPT.", "init": "Start your Smart Second Brain", "init_label": "Click to Start", "ollama": { "deamon": { - "install": "Install Ollama", + "install": "Install Ollama in the terminal:", "set_baseurl": "Set the Ollama Base URL", - "start": "Start the Ollama with origins" + "start": "Start Ollama by running this command in the terminal" }, "app": { "download": "Download the App", @@ -92,16 +92,16 @@ "extract": "Extract the .zip and start Ollama", "run": "Run the setup.exe", "test_label": "Test if Ollama is running", - "set_origins": "Set Ollama origins to enable streaming responses", + "set_origins": "In the terminal set Ollama origins to enable streaming responses:", "restart": "Restart the Ollama service ", - "restart_label": "Click menu bar icon and then quit", + "restart_label": "Click Ollamas menu bar icon and then quit", "quit": "Quit the Ollama service ", - "quit_label": "Click menu bar icon and then quit", - "start_origins": "Start the Ollama service with origins" + "quit_label": "Click Ollamas menu bar icon and then quit", + "start_origins": "Start Ollama by running this command in the powershell" }, "test_origins": "Test if the origins are set correctly", "install_model": "Install an Ollama Embedding Model.", - "recommended_models": "Recommended:", + "recommended": "Recommended: ", "set_model": "Set your Embedding Model:" }, "openai": { From e1bf4adfe1435ad23b50d4b29bccdd9f871ff002 Mon Sep 17 00:00:00 2001 From: Leo310 Date: Fri, 5 Apr 2024 12:15:41 +0200 Subject: [PATCH 6/6] up manifest --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 5a37df5..55d2292 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "description": "Interact with your privacy focused assistant, leveraging Ollama or OpenAI, making your second brain even smarter.", "author": "Leo310, nicobrauchtgit", "authorUrl": "https://github.com/nicobrauchtgit", - "version": "1.0.0", + "version": "1.0.1", "minAppVersion": "1.5.0", "isDesktopOnly": true }