diff --git a/client/src/utils/ChatBot.tsx b/client/src/utils/ChatBot.tsx
index 09bd26f1..c2c491b3 100644
--- a/client/src/utils/ChatBot.tsx
+++ b/client/src/utils/ChatBot.tsx
@@ -137,7 +137,7 @@ const ChatBot: React.FC = () => {
{messages.length === 0 && (
👋 Hi! I'm Benny, your AI assistant.
-
I can search the LibreTexts Knowledge Base and the web to help you!
+
I am here to search the LibreTexts Knowledge Base to help you!
)}
diff --git a/server/api/kb.ts b/server/api/kb.ts
index eabc0fc9..26d7b26d 100644
--- a/server/api/kb.ts
+++ b/server/api/kb.ts
@@ -223,6 +223,15 @@ async function createKBPage(
lastEditedByUUID: editor.uuid,
});
+ if (kbPage.status === "published" && kbPage.body) {
+ try {
+ await qdrantService.initializeCollection();
+ await qdrantService.upsertKBPage(kbPage.toObject());
+ } catch (err) {
+ debugError(err);
+ }
+ }
+
return res.send({
err: false,
page: kbPage,
@@ -366,6 +375,20 @@ async function updateKBPage(
await kbPage.save();
+ try {
+ await qdrantService.initializeCollection();
+
+ if (kbPage.status === "published" && kbPage.body) {
+ // Upsert replaces old embedding with new content
+ await qdrantService.upsertKBPage(kbPage.toObject());
+ } else {
+ // Remove from vector DB if it's no longer published
+ await qdrantService.deleteKBPage(kbPage.uuid);
+ }
+ } catch (err) {
+ debugError(err);
+ }
+
return res.send({
err: false,
page: kbPage,
@@ -393,6 +416,13 @@ async function deleteKBPage(
await KBPage.findOneAndDelete({ uuid }).orFail();
+ try {
+ await qdrantService.initializeCollection();
+ await qdrantService.deleteKBPage(uuid);
+ } catch (err) {
+ debugError(err);
+ }
+
return res.send({
err: false,
page,
diff --git a/server/api/services/prompts.ts b/server/api/services/prompts.ts
index 69160bef..cde8d822 100644
--- a/server/api/services/prompts.ts
+++ b/server/api/services/prompts.ts
@@ -22,7 +22,9 @@ IMPORTANT:
- If a question is not about LibreTexts, politely redirect to our support team
- Always cite your sources
- If you cannot find relevant information, suggest contacting our support team
-- Use "we", "our", and "us" when referring to LibreTexts (e.g., "our support team", "our documentation", "we recommend")`,
+- Use "we", "our", and "us" when referring to LibreTexts (e.g., "our support team", "our documentation", "we recommend")
+- If a user asks about assignments, questions, or exams, assume they mean LibreTexts' assessment and homework platform, ADAPT.
+`,
detailed: `You are the official LibreTexts AI Assistant, part of the LibreTexts team, focused exclusively on helping users with our platform questions.
@@ -65,7 +67,9 @@ Response guidelines:
- Always cite sources with proper attribution
- If no relevant information is found, acknowledge limitations and suggest contacting our support team
- Be helpful but stay within your LibreTexts-focused scope
-- Always use first-person language: "we", "our", "us" when referring to LibreTexts, our team, our documentation, our support, etc.`,
+- Always use first-person language: "we", "our", "us" when referring to LibreTexts, our team, our documentation, our support, etc.
+- If a user asks about assignments, questions, or exams, assume they mean LibreTexts' assessment and homework platform, ADAPT.
+`,
concise: `LibreTexts AI Assistant, part of the LibreTexts team. Answer only LibreTexts-related questions using bullet points or numbered lists. Direct other questions to our support team. Always cite sources. Use "we", "our", and "us" when referring to LibreTexts.`,
};