diff --git a/src/assets/locale/en/common.json b/src/assets/locale/en/common.json index 5cd332f..ffa6e81 100644 --- a/src/assets/locale/en/common.json +++ b/src/assets/locale/en/common.json @@ -51,7 +51,7 @@ "chatWithCurrentPage": "Chat with current page", "beta": "Beta", "tts": "Read aloud", - "currentChatModelSettings":"Current Chat Model Settings", + "currentChatModelSettings": "Current Chat Model Settings", "modelSettings": { "label": "Model Settings", "description": "Set the model options globally for all chats", diff --git a/src/assets/locale/en/settings.json b/src/assets/locale/en/settings.json index ed76ddf..9d38d57 100644 --- a/src/assets/locale/en/settings.json +++ b/src/assets/locale/en/settings.json @@ -1,310 +1,313 @@ { - "generalSettings": { - "title": "General Settings", - "settings": { - "heading": "Web UI Settings", - "speechRecognitionLang": { - "label": "Speech Recognition Language", - "placeholder": "Select a language" - }, - "language": { - "label": "Language", - "placeholder": "Select a language" - }, - "darkMode": { - "label": "Change Theme", - "options": { - "light": "Light", - "dark": "Dark" - } - }, - "copilotResumeLastChat": { - "label": "Resume the last chat when opening the SidePanel (Copilot)" - }, - "hideCurrentChatModelSettings": { - "label": "Hide the current Chat Model Settings" - }, - "restoreLastChatModel": { - "label": "Restore last used model for previous chats" - } - }, - "webSearch": { - "heading": "Manage Web Search", - "searchMode": { - "label": "Perform Simple Internet Search" - }, - "provider": { - "label": "Search Engine", - "placeholder": "Select a search engine" - }, - "totalSearchResults": { - "label": "Total Search Results", - "placeholder": "Enter Total Search Results" - }, - "visitSpecificWebsite": { - "label": "Visit the website mentioned in the message" - } - }, - "system": { - "heading": "System Settings", - "deleteChatHistory": { - "label": "Delete Chat History", - "button": "Delete", - "confirm": "Are you sure you want to delete your chat history? This action cannot be undone." - }, - "export": { - "label": "Export Chat History, Knowledge Base, and Prompts", - "button": "Export Data", - "success": "Export Success" - }, - "import": { - "label": "Import Chat History, Knowledge Base, and Prompts", - "button": "Import Data", - "success": "Import Success", - "error": "Import Error" - } - }, - "tts": { - "heading": "Text-to-Speech Settings", - "ttsEnabled": { - "label": "Enable Text-to-Speech" - }, - "ttsProvider": { - "label": "Text-to-Speech Provider", - "placeholder": "Select a provider" - }, - "ttsVoice": { - "label": "Text-to-Speech Voice", - "placeholder": "Select a voice" - }, - "ssmlEnabled": { - "label": "Enable SSML (Speech Synthesis Markup Language)" - } + "generalSettings": { + "title": "General Settings", + "settings": { + "heading": "Web UI Settings", + "speechRecognitionLang": { + "label": "Speech Recognition Language", + "placeholder": "Select a language" + }, + "language": { + "label": "Language", + "placeholder": "Select a language" + }, + "darkMode": { + "label": "Change Theme", + "options": { + "light": "Light", + "dark": "Dark" } + }, + "copilotResumeLastChat": { + "label": "Resume the last chat when opening the SidePanel (Copilot)" + }, + "hideCurrentChatModelSettings": { + "label": "Hide the current Chat Model Settings" + }, + "restoreLastChatModel": { + "label": "Restore last used model for previous chats" + }, + "sendNotificationAfterIndexing": { + "label": "Send Notification After Finishing Processing the Knowledge Base" + } }, - "manageModels": { - "title": "Manage Models", - "addBtn": "Add New Model", - "columns": { - "name": "Name", - "digest": "Digest", - "modifiedAt": "Modified At", - "size": "Size", - "actions": "Actions" - }, - "expandedColumns": { - "parentModel": "Parent Model", - "format": "Format", - "family": "Family", - "parameterSize": "Parameter Size", - "quantizationLevel": "Quantization Level" - }, - "tooltip": { - "delete": "Delete Model", - "repull": "Re-Pull Model" - }, - "confirm": { - "delete": "Are you sure you want to delete this model?", - "repull": "Are you sure you want to re-pull this model?" - }, - "modal": { - "title": "Add New Model", - "placeholder": "Enter Model Name", - "pull": "Pull Model" - }, - "notification": { - "pullModel": "Pulling Model", - "pullModelDescription": "Pulling {{modelName}} model. For more details, check the extension icon.", - "success": "Success", - "error": "Error", - "successDescription": "Successfully pulled the model", - "successDeleteDescription": "Successfully deleted the model", - "someError": "Something went wrong. Please try again later" - } + "webSearch": { + "heading": "Manage Web Search", + "searchMode": { + "label": "Perform Simple Internet Search" + }, + "provider": { + "label": "Search Engine", + "placeholder": "Select a search engine" + }, + "totalSearchResults": { + "label": "Total Search Results", + "placeholder": "Enter Total Search Results" + }, + "visitSpecificWebsite": { + "label": "Visit the website mentioned in the message" + } }, - "managePrompts": { - "title": "Manage Prompts", - "addBtn": "Add New Prompt", - "option1": "Normal", - "option2": "RAG", - "questionPrompt": "Question Prompt", - "columns": { - "title": "Title", - "prompt": "Prompt", - "type": "Prompt Type", - "actions": "Actions" - }, - "systemPrompt": "System Prompt", - "quickPrompt": "Quick Prompt", - "tooltip": { - "delete": "Delete Prompt", - "edit": "Edit Prompt" - }, - "confirm": { - "delete": "Are you sure you want to delete this prompt? This action cannot be undone." - }, - "modal": { - "addTitle": "Add New Prompt", - "editTitle": "Edit Prompt" - }, - "form": { - "title": { - "label": "Title", - "placeholder": "My Awesome Prompt", - "required": "Please enter a title" - }, - "prompt": { - "label": "Prompt", - "placeholder": "Enter Prompt", - "required": "Please enter a prompt", - "help": "You can use {key} as variable in your prompt." - }, - "isSystem": { - "label": "Is System Prompt" - }, - "btnSave": { - "saving": "Adding Prompt...", - "save": "Add Prompt" - }, - "btnEdit": { - "saving": "Updating Prompt...", - "save": "Update Prompt" - } - }, - "notification": { - "addSuccess": "Prompt Added", - "addSuccessDesc": "Prompt has been added successfully", - "error": "Error", - "someError": "Something went wrong. Please try again later", - "updatedSuccess": "Prompt Updated", - "updatedSuccessDesc": "Prompt has been updated successfully", - "deletedSuccess": "Prompt Deleted", - "deletedSuccessDesc": "Prompt has been deleted successfully" - } + "system": { + "heading": "System Settings", + "deleteChatHistory": { + "label": "Delete Chat History", + "button": "Delete", + "confirm": "Are you sure you want to delete your chat history? This action cannot be undone." + }, + "export": { + "label": "Export Chat History, Knowledge Base, and Prompts", + "button": "Export Data", + "success": "Export Success" + }, + "import": { + "label": "Import Chat History, Knowledge Base, and Prompts", + "button": "Import Data", + "success": "Import Success", + "error": "Import Error" + } }, - "manageShare": { - "title": "Manage Share", - "heading": "Configure Page Share URL", - "form": { - "url": { - "label": "Page Share URL", - "placeholder": "Enter Page Share URL", - "required": "Please input your Page Share URL!", - "help": "For privacy reasons, you can self-host the page share and provide the URL here. Learn More." - } - }, - "webshare": { - "heading": "Web Share", - "columns": { - "title": "Title", - "url": "URL", - "actions": "Actions" - }, - "tooltip": { - "delete": "Delete Share" - }, - "confirm": { - "delete": "Are you sure you want to delete this share? This action cannot be undone." - }, - "label": "Manage Page Share", - "description": "Enable or disable the page share feature" - }, - "notification": { - "pageShareSuccess": "Page Share URL updated successfully", - "someError": "Something went wrong. Please try again later", - "webShareDeleteSuccess": "Web Share deleted successfully" - } - }, - "ollamaSettings": { - "title": "Ollama Settings", - "heading": "Configure Ollama", - "settings": { - "ollamaUrl": { - "label": "Ollama URL", - "placeholder": "Enter Ollama URL" - }, - "advanced": { - "label": "Advance Ollama URL Configuration", - "urlRewriteEnabled": { - "label": "Enable or Disable Custom Origin URL" - }, - "rewriteUrl": { - "label": "Custom Origin URL", - "placeholder": "Enter Custom Origin URL" - }, - "headers": { - "label": "Custom Headers", - "add": "Add Header", - "key": { - "label": "Header Key", - "placeholder": "Authorization" - }, - "value": { - "label": "Header Value", - "placeholder": "Bearer token" - } - }, - "help": "If you have connection issues with Ollama on Page Assist, you can configure a custom origin URL. To learn more about the configuration, click here." - } - } - }, - "manageSearch": { - "title": "Manage Web Search", - "heading": "Configure Web Search" - }, - "about": { - "title": "About", - "heading": "About", - "chromeVersion": "Page Assist Version", - "ollamaVersion": "Ollama Version", - "support": "You can support the Page Assist project by donating or sponsoring through the following platforms:", - "koFi": "Support on Ko-fi", - "githubSponsor": "Sponsor on GitHub", - "githubRepo": "GitHub Repository" - }, - "manageKnowledge": { - "title": "Manage Knowledge", - "heading": "Configure Knowledge Base" - }, - "rag": { - "title": "RAG Settings", - "ragSettings": { - "label": "RAG Settings", - "model": { - "label": "Embedding Model", - "required": "Please select a model", - "help": "Highly recommended to use embedding models like `nomic-embed-text`.", - "placeholder": "Select a model" - }, - "chunkSize": { - "label": "Chunk Size", - "placeholder": "Enter Chunk Size", - "required": "Please enter a chunk size" - }, - "chunkOverlap": { - "label": "Chunk Overlap", - "placeholder": "Enter Chunk Overlap", - "required": "Please enter a chunk overlap" - } - }, - "prompt": { - "label": "Configure RAG Prompt", - "option1": "Normal", - "option2": "Web", - "alert": "Configuring the system prompt here is deprecated. Please use the Manage Prompts section to add or edit prompts. This section will be removed in a future release", - "systemPrompt": "System Prompt", - "systemPromptPlaceholder": "Enter System Prompt", - "webSearchPrompt": "Web Search Prompt", - "webSearchPromptHelp": "Do not remove `{search_results}` from the prompt.", - "webSearchPromptError": "Please enter a web search prompt", - "webSearchPromptPlaceholder": "Enter Web Search Prompt", - "webSearchFollowUpPrompt": "Web Search Follow Up Prompt", - "webSearchFollowUpPromptHelp": "Do not remove `{chat_history}` and `{question}` from the prompt.", - "webSearchFollowUpPromptError": "Please input your Web Search Follow Up Prompt!", - "webSearchFollowUpPromptPlaceholder": "Your Web Search Follow Up Prompt" - } - }, - "chromeAiSettings": { - "title": "Chrome AI Settings" + "tts": { + "heading": "Text-to-Speech Settings", + "ttsEnabled": { + "label": "Enable Text-to-Speech" + }, + "ttsProvider": { + "label": "Text-to-Speech Provider", + "placeholder": "Select a provider" + }, + "ttsVoice": { + "label": "Text-to-Speech Voice", + "placeholder": "Select a voice" + }, + "ssmlEnabled": { + "label": "Enable SSML (Speech Synthesis Markup Language)" + } } -} \ No newline at end of file + }, + "manageModels": { + "title": "Manage Models", + "addBtn": "Add New Model", + "columns": { + "name": "Name", + "digest": "Digest", + "modifiedAt": "Modified At", + "size": "Size", + "actions": "Actions" + }, + "expandedColumns": { + "parentModel": "Parent Model", + "format": "Format", + "family": "Family", + "parameterSize": "Parameter Size", + "quantizationLevel": "Quantization Level" + }, + "tooltip": { + "delete": "Delete Model", + "repull": "Re-Pull Model" + }, + "confirm": { + "delete": "Are you sure you want to delete this model?", + "repull": "Are you sure you want to re-pull this model?" + }, + "modal": { + "title": "Add New Model", + "placeholder": "Enter Model Name", + "pull": "Pull Model" + }, + "notification": { + "pullModel": "Pulling Model", + "pullModelDescription": "Pulling {{modelName}} model. For more details, check the extension icon.", + "success": "Success", + "error": "Error", + "successDescription": "Successfully pulled the model", + "successDeleteDescription": "Successfully deleted the model", + "someError": "Something went wrong. Please try again later" + } + }, + "managePrompts": { + "title": "Manage Prompts", + "addBtn": "Add New Prompt", + "option1": "Normal", + "option2": "RAG", + "questionPrompt": "Question Prompt", + "columns": { + "title": "Title", + "prompt": "Prompt", + "type": "Prompt Type", + "actions": "Actions" + }, + "systemPrompt": "System Prompt", + "quickPrompt": "Quick Prompt", + "tooltip": { + "delete": "Delete Prompt", + "edit": "Edit Prompt" + }, + "confirm": { + "delete": "Are you sure you want to delete this prompt? This action cannot be undone." + }, + "modal": { + "addTitle": "Add New Prompt", + "editTitle": "Edit Prompt" + }, + "form": { + "title": { + "label": "Title", + "placeholder": "My Awesome Prompt", + "required": "Please enter a title" + }, + "prompt": { + "label": "Prompt", + "placeholder": "Enter Prompt", + "required": "Please enter a prompt", + "help": "You can use {key} as variable in your prompt." + }, + "isSystem": { + "label": "Is System Prompt" + }, + "btnSave": { + "saving": "Adding Prompt...", + "save": "Add Prompt" + }, + "btnEdit": { + "saving": "Updating Prompt...", + "save": "Update Prompt" + } + }, + "notification": { + "addSuccess": "Prompt Added", + "addSuccessDesc": "Prompt has been added successfully", + "error": "Error", + "someError": "Something went wrong. Please try again later", + "updatedSuccess": "Prompt Updated", + "updatedSuccessDesc": "Prompt has been updated successfully", + "deletedSuccess": "Prompt Deleted", + "deletedSuccessDesc": "Prompt has been deleted successfully" + } + }, + "manageShare": { + "title": "Manage Share", + "heading": "Configure Page Share URL", + "form": { + "url": { + "label": "Page Share URL", + "placeholder": "Enter Page Share URL", + "required": "Please input your Page Share URL!", + "help": "For privacy reasons, you can self-host the page share and provide the URL here. Learn More." + } + }, + "webshare": { + "heading": "Web Share", + "columns": { + "title": "Title", + "url": "URL", + "actions": "Actions" + }, + "tooltip": { + "delete": "Delete Share" + }, + "confirm": { + "delete": "Are you sure you want to delete this share? This action cannot be undone." + }, + "label": "Manage Page Share", + "description": "Enable or disable the page share feature" + }, + "notification": { + "pageShareSuccess": "Page Share URL updated successfully", + "someError": "Something went wrong. Please try again later", + "webShareDeleteSuccess": "Web Share deleted successfully" + } + }, + "ollamaSettings": { + "title": "Ollama Settings", + "heading": "Configure Ollama", + "settings": { + "ollamaUrl": { + "label": "Ollama URL", + "placeholder": "Enter Ollama URL" + }, + "advanced": { + "label": "Advance Ollama URL Configuration", + "urlRewriteEnabled": { + "label": "Enable or Disable Custom Origin URL" + }, + "rewriteUrl": { + "label": "Custom Origin URL", + "placeholder": "Enter Custom Origin URL" + }, + "headers": { + "label": "Custom Headers", + "add": "Add Header", + "key": { + "label": "Header Key", + "placeholder": "Authorization" + }, + "value": { + "label": "Header Value", + "placeholder": "Bearer token" + } + }, + "help": "If you have connection issues with Ollama on Page Assist, you can configure a custom origin URL. To learn more about the configuration, click here." + } + } + }, + "manageSearch": { + "title": "Manage Web Search", + "heading": "Configure Web Search" + }, + "about": { + "title": "About", + "heading": "About", + "chromeVersion": "Page Assist Version", + "ollamaVersion": "Ollama Version", + "support": "You can support the Page Assist project by donating or sponsoring through the following platforms:", + "koFi": "Support on Ko-fi", + "githubSponsor": "Sponsor on GitHub", + "githubRepo": "GitHub Repository" + }, + "manageKnowledge": { + "title": "Manage Knowledge", + "heading": "Configure Knowledge Base" + }, + "rag": { + "title": "RAG Settings", + "ragSettings": { + "label": "RAG Settings", + "model": { + "label": "Embedding Model", + "required": "Please select a model", + "help": "Highly recommended to use embedding models like `nomic-embed-text`.", + "placeholder": "Select a model" + }, + "chunkSize": { + "label": "Chunk Size", + "placeholder": "Enter Chunk Size", + "required": "Please enter a chunk size" + }, + "chunkOverlap": { + "label": "Chunk Overlap", + "placeholder": "Enter Chunk Overlap", + "required": "Please enter a chunk overlap" + } + }, + "prompt": { + "label": "Configure RAG Prompt", + "option1": "Normal", + "option2": "Web", + "alert": "Configuring the system prompt here is deprecated. Please use the Manage Prompts section to add or edit prompts. This section will be removed in a future release", + "systemPrompt": "System Prompt", + "systemPromptPlaceholder": "Enter System Prompt", + "webSearchPrompt": "Web Search Prompt", + "webSearchPromptHelp": "Do not remove `{search_results}` from the prompt.", + "webSearchPromptError": "Please enter a web search prompt", + "webSearchPromptPlaceholder": "Enter Web Search Prompt", + "webSearchFollowUpPrompt": "Web Search Follow Up Prompt", + "webSearchFollowUpPromptHelp": "Do not remove `{chat_history}` and `{question}` from the prompt.", + "webSearchFollowUpPromptError": "Please input your Web Search Follow Up Prompt!", + "webSearchFollowUpPromptPlaceholder": "Your Web Search Follow Up Prompt" + } + }, + "chromeAiSettings": { + "title": "Chrome AI Settings" + } +} diff --git a/src/assets/locale/es/settings.json b/src/assets/locale/es/settings.json index 07cc910..e4df0e0 100644 --- a/src/assets/locale/es/settings.json +++ b/src/assets/locale/es/settings.json @@ -26,6 +26,9 @@ }, "restoreLastChatModel": { "label": "Restaurar el último modelo utilizado para chats anteriores" + }, + "sendNotificationAfterIndexing": { + "label": "Enviar notificación después de terminar el procesamiento de la base de conocimientos" } }, "webSearch": { diff --git a/src/assets/locale/fr/settings.json b/src/assets/locale/fr/settings.json index 6482edb..6af2a68 100644 --- a/src/assets/locale/fr/settings.json +++ b/src/assets/locale/fr/settings.json @@ -26,6 +26,9 @@ }, "restoreLastChatModel": { "label": "Restaurer le dernier modèle utilisé pour les conversations précédentes" + }, + "sendNotificationAfterIndexing": { + "label": "Envoyer une notification après avoir terminé le traitement de la base de connaissances" } }, "webSearch": { diff --git a/src/assets/locale/it/settings.json b/src/assets/locale/it/settings.json index 6b06c47..31aed04 100644 --- a/src/assets/locale/it/settings.json +++ b/src/assets/locale/it/settings.json @@ -26,6 +26,9 @@ }, "restoreLastChatModel": { "label": "Ripristina l'ultimo modello utilizzato per le chat precedenti" + }, + "sendNotificationAfterIndexing": { + "label": "Inviare notifica dopo aver terminato l'elaborazione della base di conoscenza" } }, "webSearch": { diff --git a/src/assets/locale/ja-JP/settings.json b/src/assets/locale/ja-JP/settings.json index 03b20e0..f11105b 100644 --- a/src/assets/locale/ja-JP/settings.json +++ b/src/assets/locale/ja-JP/settings.json @@ -29,6 +29,9 @@ }, "restoreLastChatModel": { "label": "以前のチャットで最後に使用したモデルを復元する" + }, + "sendNotificationAfterIndexing": { + "label": "ナレッジベースの処理完了後に通知を送信" } }, "webSearch": { diff --git a/src/assets/locale/ml/settings.json b/src/assets/locale/ml/settings.json index 9f82953..d46f628 100644 --- a/src/assets/locale/ml/settings.json +++ b/src/assets/locale/ml/settings.json @@ -29,6 +29,9 @@ }, "restoreLastChatModel": { "label": "മുൻപത്തെ ചാറ്റുകൾക്കായി അവസാനം ഉപയോഗിച്ച മോഡൽ പുനഃസ്ഥാപിക്കുക" + }, + "sendNotificationAfterIndexing": { + "label": "അറിവ് ശേഖരം പ്രോസസ്സ് ചെയ്ത് കഴിഞ്ഞതിന് ശേഷം അറിയിപ്പ് അയയ്ക്കുക" } }, "webSearch": { diff --git a/src/assets/locale/pt-BR/settings.json b/src/assets/locale/pt-BR/settings.json index 15b5def..f396d0a 100644 --- a/src/assets/locale/pt-BR/settings.json +++ b/src/assets/locale/pt-BR/settings.json @@ -22,10 +22,13 @@ "label": "Retomar o último chat ao abrir o Painel Lateral (Copilot)" }, "hideCurrentChatModelSettings": { - "label": "Ocultar as Configurações Atuais do Modelo de Chat" + "label": "Ocultar as Configurações Atuais do Modelo de Chat" }, "restoreLastChatModel": { "label": "Restaurar o último modelo usado para conversas anteriores" + }, + "sendNotificationAfterIndexing": { + "label": "Enviar notificação após concluir o processamento da base de conhecimento" } }, "webSearch": { diff --git a/src/assets/locale/ru/settings.json b/src/assets/locale/ru/settings.json index dd1d821..bf85524 100644 --- a/src/assets/locale/ru/settings.json +++ b/src/assets/locale/ru/settings.json @@ -26,6 +26,9 @@ }, "restoreLastChatModel": { "label": "Восстановить последнюю использованную модель для предыдущих чатов" + }, + "sendNotificationAfterIndexing": { + "label": "Отправить уведомление после завершения обработки базы знаний" } }, "webSearch": { diff --git a/src/assets/locale/zh/settings.json b/src/assets/locale/zh/settings.json index ad08840..7b93060 100644 --- a/src/assets/locale/zh/settings.json +++ b/src/assets/locale/zh/settings.json @@ -29,6 +29,9 @@ }, "restoreLastChatModel": { "label": "恢复上次用于之前聊天的模型" + }, + "sendNotificationAfterIndexing": { + "label": "完成知识库处理后发送通知" } }, "webSearch": { diff --git a/src/components/Option/Settings/general-settings.tsx b/src/components/Option/Settings/general-settings.tsx index 367f283..21f622a 100644 --- a/src/components/Option/Settings/general-settings.tsx +++ b/src/components/Option/Settings/general-settings.tsx @@ -32,6 +32,9 @@ export const GeneralSettings = () => { const [hideCurrentChatModelSettings, setHideCurrentChatModelSettings] = useStorage("hideCurrentChatModelSettings", false) + const [sendNotificationAfterIndexing, setSendNotificationAfterIndexing] = + useStorage("sendNotificationAfterIndexing", false) + const queryClient = useQueryClient() const { mode, toggleDarkMode } = useDarkMode() @@ -124,6 +127,20 @@ export const GeneralSettings = () => { onChange={(checked) => setRestoreLastChatModel(checked)} /> + +
+
+ + {t("generalSettings.settings.sendNotificationAfterIndexing.label")} + +
+ + +
+
{t("generalSettings.settings.darkMode.label")} diff --git a/src/libs/process-knowledge.ts b/src/libs/process-knowledge.ts index f933d85..0288e3a 100644 --- a/src/libs/process-knowledge.ts +++ b/src/libs/process-knowledge.ts @@ -12,6 +12,7 @@ import { PageAssisCSVUrlLoader } from "@/loader/csv" import { PageAssisTXTUrlLoader } from "@/loader/txt" import { PageAssistDocxLoader } from "@/loader/docx" import { cleanUrl } from "./clean-url" +import { sendEmbeddingCompleteNotification } from "./send-notification" export const processKnowledge = async (msg: any, id: string): Promise => { @@ -102,6 +103,8 @@ export const processKnowledge = async (msg: any, id: string): Promise => { } await updateKnowledgeStatus(id, "finished") + + await sendEmbeddingCompleteNotification() } catch (error) { console.error(`Error processing knowledge with id: ${id}`, error) await updateKnowledgeStatus(id, "failed") diff --git a/src/libs/send-notification.ts b/src/libs/send-notification.ts new file mode 100644 index 0000000..91d1603 --- /dev/null +++ b/src/libs/send-notification.ts @@ -0,0 +1,27 @@ +import { Storage } from "@plasmohq/storage" +const storage = new Storage() + +export const sendNotification = async (title: string, message: string) => { + try { + const sendNotificationAfterIndexing = await storage.get( + "sendNotificationAfterIndexing" + ) + if (sendNotificationAfterIndexing) { + browser.notifications.create({ + type: "basic", + iconUrl: browser.runtime.getURL("/icon.png"), + title, + message + }) + } + } catch (error) { + console.error(error) + } +} + +export const sendEmbeddingCompleteNotification = async () => { + await sendNotification( + "Page Assist - Embedding Completed", + "The knowledge base embedding process is complete. You can now use the knowledge base for chatting." + ) +} diff --git a/wxt.config.ts b/wxt.config.ts index 4585e20..5c31a73 100644 --- a/wxt.config.ts +++ b/wxt.config.ts @@ -11,7 +11,8 @@ const chromeMV3Permissions = [ "action", "unlimitedStorage", "contextMenus", - "tts" + "tts", + "notifications" ] const firefoxMV2Permissions = [ @@ -22,6 +23,7 @@ const firefoxMV2Permissions = [ "contextMenus", "webRequest", "webRequestBlocking", + "notifications", "http://*/*", "https://*/*", "file://*/*"