feat: Add support for sending notification after knowledge base processing
This commit is contained in:
parent
f5f0157260
commit
9c8584f1c4
@ -26,6 +26,9 @@
|
||||
},
|
||||
"restoreLastChatModel": {
|
||||
"label": "Restore last used model for previous chats"
|
||||
},
|
||||
"sendNotificationAfterIndexing": {
|
||||
"label": "Send Notification After Finishing Processing the Knowledge Base"
|
||||
}
|
||||
},
|
||||
"webSearch": {
|
||||
|
@ -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": {
|
||||
|
@ -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": {
|
||||
|
@ -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": {
|
||||
|
@ -29,6 +29,9 @@
|
||||
},
|
||||
"restoreLastChatModel": {
|
||||
"label": "以前のチャットで最後に使用したモデルを復元する"
|
||||
},
|
||||
"sendNotificationAfterIndexing": {
|
||||
"label": "ナレッジベースの処理完了後に通知を送信"
|
||||
}
|
||||
},
|
||||
"webSearch": {
|
||||
|
@ -29,6 +29,9 @@
|
||||
},
|
||||
"restoreLastChatModel": {
|
||||
"label": "മുൻപത്തെ ചാറ്റുകൾക്കായി അവസാനം ഉപയോഗിച്ച മോഡൽ പുനഃസ്ഥാപിക്കുക"
|
||||
},
|
||||
"sendNotificationAfterIndexing": {
|
||||
"label": "അറിവ് ശേഖരം പ്രോസസ്സ് ചെയ്ത് കഴിഞ്ഞതിന് ശേഷം അറിയിപ്പ് അയയ്ക്കുക"
|
||||
}
|
||||
},
|
||||
"webSearch": {
|
||||
|
@ -26,6 +26,9 @@
|
||||
},
|
||||
"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": {
|
||||
|
@ -26,6 +26,9 @@
|
||||
},
|
||||
"restoreLastChatModel": {
|
||||
"label": "Восстановить последнюю использованную модель для предыдущих чатов"
|
||||
},
|
||||
"sendNotificationAfterIndexing": {
|
||||
"label": "Отправить уведомление после завершения обработки базы знаний"
|
||||
}
|
||||
},
|
||||
"webSearch": {
|
||||
|
@ -29,6 +29,9 @@
|
||||
},
|
||||
"restoreLastChatModel": {
|
||||
"label": "恢复上次用于之前聊天的模型"
|
||||
},
|
||||
"sendNotificationAfterIndexing": {
|
||||
"label": "完成知识库处理后发送通知"
|
||||
}
|
||||
},
|
||||
"webSearch": {
|
||||
|
@ -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")}
|
||||
|
@ -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")
|
||||
|
27
src/libs/send-notification.ts
Normal file
27
src/libs/send-notification.ts
Normal 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."
|
||||
)
|
||||
}
|
@ -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://*/*"
|
||||
|
Loading…
x
Reference in New Issue
Block a user