Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/utils/ChatBot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const ChatBot: React.FC = () => {
{messages.length === 0 && (
<div className="welcome-message">
<p>👋 Hi! I'm Benny, your AI assistant.</p>
<p>I can search the LibreTexts Knowledge Base and the web to help you!</p>
<p>I am here to search the LibreTexts Knowledge Base to help you!</p>
</div>
)}

Expand Down
30 changes: 30 additions & 0 deletions server/api/kb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions server/api/services/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.`,
};
Expand Down