diff --git a/.github/workflows/logs.yml b/.github/workflows/logs.yml new file mode 100644 index 0000000..22f0739 --- /dev/null +++ b/.github/workflows/logs.yml @@ -0,0 +1,26 @@ +name: Check for console.logs + +on: + pull_request: + branches: + - main + +jobs: + check-logs: + runs-on: ubuntu-latest + steps: + - name: get the sources + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '20' + + - name: Install dependencies + run: npm ci + + - name: Run check script + run: node .github/workflows/create-check.js + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/manifest.json b/manifest.json index 07512a0..053c399 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.3.2", + "version": "0.4.2", "minAppVersion": "1.5.0", "isDesktopOnly": true } diff --git a/src/SmartSecondBrain.ts b/src/SmartSecondBrain.ts index f9e4d63..cd5a44c 100644 --- a/src/SmartSecondBrain.ts +++ b/src/SmartSecondBrain.ts @@ -6,6 +6,7 @@ import { isOllamaRunning, getOllamaModels } from './controller/Ollama'; import { isAPIKeyValid } from './controller/OpenAI'; import Log, { LogLvl } from './logging'; import { data, papaState, errorState, papaIndexingProgress, chatHistory, serializeChatHistory, runState, runContent } from './store'; +import { _ } from 'svelte-i18n'; export default class SmartSecondBrain { private papa: Papa; @@ -20,23 +21,29 @@ export default class SmartSecondBrain { async init() { const d = get(data); - if (get(papaState) === 'running') return new Notice('Smart Second Brain is still running.', 4000); + const t = get(_); + if (get(papaState) === 'running') return new Notice(t('notice.still_running'), 4000); else if (get(papaState) === 'indexing' || get(papaState) === 'loading') { - return new Notice('Please wait for the indexing to finish', 4000); + return new Notice(t('notice.still_indexing'), 4000); } else if (d.isIncognitoMode && !(await isOllamaRunning())) { papaState.set('error'); errorState.set('ollama-not-running'); - return new Notice('Please make sure Ollama is running before initializing Smart Second Brain.', 4000); + return new Notice(t('notice.ollama_not_running'), 4000); } else if (d.isIncognitoMode) { const models = await getOllamaModels(); if (!models.includes(d.ollamaGenModel.model)) { papaState.set('error'); - errorState.set('ollama-model-not-installed'); - return new Notice('Ollama model not installed. Please install the model before initializing Smart Second Brain.', 4000); + errorState.set('ollama-gen-model-not-installed'); + return new Notice(t('notice.ollama_gen_model'), 4000); + } + if (!models.includes(d.ollamaEmbedModel.model)) { + papaState.set('error'); + errorState.set('ollama-embed-model-not-installed'); + return new Notice(t('notice.ollama_embed_model'), 4000); } } else if (!d.isIncognitoMode && !(await isAPIKeyValid(d.openAIGenModel.openAIApiKey))) { papaState.set('error'); - return new Notice('Please make sure OpenAI API Key is valid before initializing Smart Second Brain.', 4000); + return new Notice(t('notice.openai_key'), 4000); } if (get(papaState) !== 'indexing-pause') { papaState.set('loading'); @@ -58,7 +65,7 @@ export default class SmartSecondBrain { } catch (e) { Log.error(e); papaState.set('error'); - return new Notice('Failed to initialize Smart Second Brain (Error: ' + e + '). Please retry.', 4000); + 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())) { @@ -75,7 +82,6 @@ export default class SmartSecondBrain { }) ); papaState.set('indexing'); - // const embedNotice = new Notice('Indexing notes into your smart second brain...', 0); let needsSave = false; try { for await (const result of this.papa.embedDocuments(docs)) { @@ -93,23 +99,24 @@ export default class SmartSecondBrain { Log.error(e); papaState.set('error'); // TODO add error state - new Notice('Failed to index notes into your smart second brain. Please retry.', 4000); + new Notice(t('notice.failed_indexing'), 4000); } this.needsToSaveVectorStoreData = needsSave; this.saveVectorStoreData(); if (get(papaIndexingProgress) === 100) { - new Notice('Smart Second Brain initialized.', 2000); + new Notice(t('notice.done'), 2000); papaIndexingProgress.set(0); papaState.set('idle'); } } canRunPapa() { - if (get(papaState) === 'running') return new Notice('Please wait for the current query to finish', 4000) && false; + const t = get(_); + if (get(papaState) === 'running') return new Notice(t('notice.still_running'), 4000) && false; else if (get(papaState) === 'indexing' || get(papaState) === 'indexing-pause' || get(papaState) === 'loading') - return new Notice('Please wait for the indexing to finish', 4000) && false; - else if (get(papaState) === 'error') return new Notice('Please wait for the error to resolve', 4000) && false; - else if (get(papaState) !== 'idle') return new Notice('Please initialize your Smart Second Brain first', 4000) && false; + return new Notice(t('notice.still_indexing'), 4000) && false; + else if (get(papaState) === 'error') return new Notice(t('notice.error'), 4000) && false; + else if (get(papaState) !== 'idle') return new Notice(t('notice.not_initialized'), 4000) && false; return true; } diff --git a/src/components/Chat/Chat.svelte b/src/components/Chat/Chat.svelte index 8f49d85..6fb51e0 100644 --- a/src/components/Chat/Chat.svelte +++ b/src/components/Chat/Chat.svelte @@ -5,6 +5,7 @@ import { afterUpdate } from 'svelte'; import DotAnimation from '../base/DotAnimation.svelte'; import MessageContainer from './MessageContainer.svelte'; + import { t } from 'svelte-i18n'; import { papaState, chatHistory, @@ -45,7 +46,7 @@ }); $: if ($runState === 'retrieving' && $runContent == '0') { - new Notice('No notes retrieved. Maybe lower the similarity threshold.'); + new Notice($t('notice.no_notes_retrieved')); } let editElem: HTMLSpanElement; @@ -90,11 +91,11 @@
Retrieving
{$t('chat.retrieving')}
Reducing {$runContent} Notes
{$t('chat.reducing', { values: { num: $runContent } })}