feat: Add support for sending notification after knowledge base processing
This commit is contained in:
parent
f5f0157260
commit
9c8584f1c4
@ -51,7 +51,7 @@
|
|||||||
"chatWithCurrentPage": "Chat with current page",
|
"chatWithCurrentPage": "Chat with current page",
|
||||||
"beta": "Beta",
|
"beta": "Beta",
|
||||||
"tts": "Read aloud",
|
"tts": "Read aloud",
|
||||||
"currentChatModelSettings":"Current Chat Model Settings",
|
"currentChatModelSettings": "Current Chat Model Settings",
|
||||||
"modelSettings": {
|
"modelSettings": {
|
||||||
"label": "Model Settings",
|
"label": "Model Settings",
|
||||||
"description": "Set the model options globally for all chats",
|
"description": "Set the model options globally for all chats",
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
},
|
},
|
||||||
"restoreLastChatModel": {
|
"restoreLastChatModel": {
|
||||||
"label": "Restore last used model for previous chats"
|
"label": "Restore last used model for previous chats"
|
||||||
|
},
|
||||||
|
"sendNotificationAfterIndexing": {
|
||||||
|
"label": "Send Notification After Finishing Processing the Knowledge Base"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"webSearch": {
|
"webSearch": {
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
},
|
},
|
||||||
"restoreLastChatModel": {
|
"restoreLastChatModel": {
|
||||||
"label": "Restaurar el último modelo utilizado para chats anteriores"
|
"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": {
|
"webSearch": {
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
},
|
},
|
||||||
"restoreLastChatModel": {
|
"restoreLastChatModel": {
|
||||||
"label": "Restaurer le dernier modèle utilisé pour les conversations précédentes"
|
"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": {
|
"webSearch": {
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
},
|
},
|
||||||
"restoreLastChatModel": {
|
"restoreLastChatModel": {
|
||||||
"label": "Ripristina l'ultimo modello utilizzato per le chat precedenti"
|
"label": "Ripristina l'ultimo modello utilizzato per le chat precedenti"
|
||||||
|
},
|
||||||
|
"sendNotificationAfterIndexing": {
|
||||||
|
"label": "Inviare notifica dopo aver terminato l'elaborazione della base di conoscenza"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"webSearch": {
|
"webSearch": {
|
||||||
|
@ -29,6 +29,9 @@
|
|||||||
},
|
},
|
||||||
"restoreLastChatModel": {
|
"restoreLastChatModel": {
|
||||||
"label": "以前のチャットで最後に使用したモデルを復元する"
|
"label": "以前のチャットで最後に使用したモデルを復元する"
|
||||||
|
},
|
||||||
|
"sendNotificationAfterIndexing": {
|
||||||
|
"label": "ナレッジベースの処理完了後に通知を送信"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"webSearch": {
|
"webSearch": {
|
||||||
|
@ -29,6 +29,9 @@
|
|||||||
},
|
},
|
||||||
"restoreLastChatModel": {
|
"restoreLastChatModel": {
|
||||||
"label": "മുൻപത്തെ ചാറ്റുകൾക്കായി അവസാനം ഉപയോഗിച്ച മോഡൽ പുനഃസ്ഥാപിക്കുക"
|
"label": "മുൻപത്തെ ചാറ്റുകൾക്കായി അവസാനം ഉപയോഗിച്ച മോഡൽ പുനഃസ്ഥാപിക്കുക"
|
||||||
|
},
|
||||||
|
"sendNotificationAfterIndexing": {
|
||||||
|
"label": "അറിവ് ശേഖരം പ്രോസസ്സ് ചെയ്ത് കഴിഞ്ഞതിന് ശേഷം അറിയിപ്പ് അയയ്ക്കുക"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"webSearch": {
|
"webSearch": {
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
},
|
},
|
||||||
"restoreLastChatModel": {
|
"restoreLastChatModel": {
|
||||||
"label": "Restaurar o último modelo usado para conversas anteriores"
|
"label": "Restaurar o último modelo usado para conversas anteriores"
|
||||||
|
},
|
||||||
|
"sendNotificationAfterIndexing": {
|
||||||
|
"label": "Enviar notificação após concluir o processamento da base de conhecimento"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"webSearch": {
|
"webSearch": {
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
},
|
},
|
||||||
"restoreLastChatModel": {
|
"restoreLastChatModel": {
|
||||||
"label": "Восстановить последнюю использованную модель для предыдущих чатов"
|
"label": "Восстановить последнюю использованную модель для предыдущих чатов"
|
||||||
|
},
|
||||||
|
"sendNotificationAfterIndexing": {
|
||||||
|
"label": "Отправить уведомление после завершения обработки базы знаний"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"webSearch": {
|
"webSearch": {
|
||||||
|
@ -29,6 +29,9 @@
|
|||||||
},
|
},
|
||||||
"restoreLastChatModel": {
|
"restoreLastChatModel": {
|
||||||
"label": "恢复上次用于之前聊天的模型"
|
"label": "恢复上次用于之前聊天的模型"
|
||||||
|
},
|
||||||
|
"sendNotificationAfterIndexing": {
|
||||||
|
"label": "完成知识库处理后发送通知"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"webSearch": {
|
"webSearch": {
|
||||||
|
@ -32,6 +32,9 @@ export const GeneralSettings = () => {
|
|||||||
const [hideCurrentChatModelSettings, setHideCurrentChatModelSettings] =
|
const [hideCurrentChatModelSettings, setHideCurrentChatModelSettings] =
|
||||||
useStorage("hideCurrentChatModelSettings", false)
|
useStorage("hideCurrentChatModelSettings", false)
|
||||||
|
|
||||||
|
const [sendNotificationAfterIndexing, setSendNotificationAfterIndexing] =
|
||||||
|
useStorage("sendNotificationAfterIndexing", false)
|
||||||
|
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
const { mode, toggleDarkMode } = useDarkMode()
|
const { mode, toggleDarkMode } = useDarkMode()
|
||||||
@ -124,6 +127,20 @@ export const GeneralSettings = () => {
|
|||||||
onChange={(checked) => setRestoreLastChatModel(checked)}
|
onChange={(checked) => setRestoreLastChatModel(checked)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</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">
|
<div className="flex flex-row justify-between">
|
||||||
<span className="text-gray-700 dark:text-neutral-50 ">
|
<span className="text-gray-700 dark:text-neutral-50 ">
|
||||||
{t("generalSettings.settings.darkMode.label")}
|
{t("generalSettings.settings.darkMode.label")}
|
||||||
|
@ -12,6 +12,7 @@ import { PageAssisCSVUrlLoader } from "@/loader/csv"
|
|||||||
import { PageAssisTXTUrlLoader } from "@/loader/txt"
|
import { PageAssisTXTUrlLoader } from "@/loader/txt"
|
||||||
import { PageAssistDocxLoader } from "@/loader/docx"
|
import { PageAssistDocxLoader } from "@/loader/docx"
|
||||||
import { cleanUrl } from "./clean-url"
|
import { cleanUrl } from "./clean-url"
|
||||||
|
import { sendEmbeddingCompleteNotification } from "./send-notification"
|
||||||
|
|
||||||
|
|
||||||
export const processKnowledge = async (msg: any, id: string): Promise<void> => {
|
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 updateKnowledgeStatus(id, "finished")
|
||||||
|
|
||||||
|
await sendEmbeddingCompleteNotification()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error processing knowledge with id: ${id}`, error)
|
console.error(`Error processing knowledge with id: ${id}`, error)
|
||||||
await updateKnowledgeStatus(id, "failed")
|
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",
|
"action",
|
||||||
"unlimitedStorage",
|
"unlimitedStorage",
|
||||||
"contextMenus",
|
"contextMenus",
|
||||||
"tts"
|
"tts",
|
||||||
|
"notifications"
|
||||||
]
|
]
|
||||||
|
|
||||||
const firefoxMV2Permissions = [
|
const firefoxMV2Permissions = [
|
||||||
@ -22,6 +23,7 @@ const firefoxMV2Permissions = [
|
|||||||
"contextMenus",
|
"contextMenus",
|
||||||
"webRequest",
|
"webRequest",
|
||||||
"webRequestBlocking",
|
"webRequestBlocking",
|
||||||
|
"notifications",
|
||||||
"http://*/*",
|
"http://*/*",
|
||||||
"https://*/*",
|
"https://*/*",
|
||||||
"file://*/*"
|
"file://*/*"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user