feat: Add support for sending notification after knowledge base processing

This commit is contained in:
n4ze3m 2024-07-16 00:37:50 +05:30
parent f5f0157260
commit 9c8584f1c4
14 changed files with 383 additions and 307 deletions

View File

@ -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",

View File

@ -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. <anchor>Learn More</anchor>."
}
},
"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, <anchor>click here</anchor>."
}
}
},
"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)"
}
}
}
},
"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. <anchor>Learn More</anchor>."
}
},
"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, <anchor>click here</anchor>."
}
}
},
"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"
}
}

View File

@ -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": {

View File

@ -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": {

View File

@ -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": {

View File

@ -29,6 +29,9 @@
},
"restoreLastChatModel": {
"label": "以前のチャットで最後に使用したモデルを復元する"
},
"sendNotificationAfterIndexing": {
"label": "ナレッジベースの処理完了後に通知を送信"
}
},
"webSearch": {

View File

@ -29,6 +29,9 @@
},
"restoreLastChatModel": {
"label": "മുൻപത്തെ ചാറ്റുകൾക്കായി അവസാനം ഉപയോഗിച്ച മോഡൽ പുനഃസ്ഥാപിക്കുക"
},
"sendNotificationAfterIndexing": {
"label": "അറിവ് ശേഖരം പ്രോസസ്സ് ചെയ്ത് കഴിഞ്ഞതിന് ശേഷം അറിയിപ്പ് അയയ്ക്കുക"
}
},
"webSearch": {

View File

@ -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": {

View File

@ -26,6 +26,9 @@
},
"restoreLastChatModel": {
"label": "Восстановить последнюю использованную модель для предыдущих чатов"
},
"sendNotificationAfterIndexing": {
"label": "Отправить уведомление после завершения обработки базы знаний"
}
},
"webSearch": {

View File

@ -29,6 +29,9 @@
},
"restoreLastChatModel": {
"label": "恢复上次用于之前聊天的模型"
},
"sendNotificationAfterIndexing": {
"label": "完成知识库处理后发送通知"
}
},
"webSearch": {

View File

@ -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)}
/>
</div>
<div className="flex flex-row justify-between">
<div className="inline-flex items-center gap-2">
<span className="text-gray-700 dark:text-neutral-50">
{t("generalSettings.settings.sendNotificationAfterIndexing.label")}
</span>
</div>
<Switch
checked={sendNotificationAfterIndexing}
onChange={setSendNotificationAfterIndexing}
/>
</div>
<div className="flex flex-row justify-between">
<span className="text-gray-700 dark:text-neutral-50 ">
{t("generalSettings.settings.darkMode.label")}

View File

@ -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<void> => {
@ -102,6 +103,8 @@ export const processKnowledge = async (msg: any, id: string): Promise<void> => {
}
await updateKnowledgeStatus(id, "finished")
await sendEmbeddingCompleteNotification()
} catch (error) {
console.error(`Error processing knowledge with id: ${id}`, error)
await updateKnowledgeStatus(id, "failed")

View File

@ -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<boolean>(
"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."
)
}

View File

@ -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://*/*"