This project provides a Node.js proxy service that enables you to run a chatbot using open-source LLMs (via Ollama), but restricts the chatbot's knowledge to only the content found on the Blackboard Learn Help site. It implements a simple retrieval-augmented generation (RAG) pipeline: user questions are matched to relevant website content, and only that content is provided as context to the LLM for answering.
- Retrieval-Augmented Generation (RAG): Answers are based only on content from Blackboard Learn Help, not the model's general knowledge.
- Local LLMs: Uses Ollama to run models like Llama 2, Mistral, or Phi-3 on your own machine.
- Simple REST API: POST
/chatbotwith a question, get a focused answer. - Easy Content Updating: Re-crawl the site anytime to refresh the knowledge base.
git clone https://github.com/ShannonH/chatbot-middleware
cd chatbot-middlewarenpm install- Download and install Ollama from https://ollama.com/download
- Pull a model (e.g., Llama 2):
ollama pull llama2
- Make sure Ollama is running (it usually starts automatically):
ollama serve
This will download and extract content from the help site for use by the chatbot.
npm install axios cheerio
node crawl_blackboard_learn.mjs- This creates
blackboard_learn_content.jsonin your project directory. - You can adjust the crawl limit in the script if you want more or fewer pages.
node ollama-proxy.mjs- The service will listen on port 4000 by default.
Send a POST request to /chatbot with a JSON body:
{
"message": "How do I create an assessment with different question types in Blackboard?"
}The response will be:
{
"reply": "...answer based only on Blackboard Learn Help..."
}- The proxy loads the crawled content from
blackboard_learn_content.json. - When a question is received, it searches for the most relevant content chunks.
- It builds a prompt for the LLM that includes only those chunks and instructs the model to answer using only that information.
- The LLM's response is returned to the user.
- Change the Model: Edit
ollama-proxy.mjsto use a different model (e.g.,mistral,phi3). - Improve Retrieval: For better search, consider using embeddings and semantic search libraries.
- Expand/Refresh Content: Re-run the crawler script to update the knowledge base.
- If you get
No relevant Blackboard Learn content found for your question., try re-crawling or adjusting the search logic. - If you see errors about missing modules, ensure all dependencies are installed.
- Ollama must be running and the model must be pulled before starting the proxy.
MIT
Questions or suggestions? Open an issue or PR!