Skip to content

ShannonH/chatbot-middleware

Repository files navigation

Blackboard Learn RAG Chatbot Proxy (Ollama)

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.

Features

  • 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 /chatbot with a question, get a focused answer.
  • Easy Content Updating: Re-crawl the site anytime to refresh the knowledge base.

Installation & Setup

1. Clone the Repository

git clone https://github.com/ShannonH/chatbot-middleware
cd chatbot-middleware

2. Install Dependencies

npm install

3. Install and Set Up Ollama

  • 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

4. Crawl Blackboard Learn Help Content

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.json in your project directory.
  • You can adjust the crawl limit in the script if you want more or fewer pages.

5. Start the Proxy Service

node ollama-proxy.mjs
  • The service will listen on port 4000 by default.

Usage

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..."
}

How It Works

  1. The proxy loads the crawled content from blackboard_learn_content.json.
  2. When a question is received, it searches for the most relevant content chunks.
  3. It builds a prompt for the LLM that includes only those chunks and instructs the model to answer using only that information.
  4. The LLM's response is returned to the user.

Customization

  • Change the Model: Edit ollama-proxy.mjs to 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.

Troubleshooting

  • 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.

License

MIT


Questions or suggestions? Open an issue or PR!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published