Home > Projects > Lightweight Virtual Assistant

Lightweight Virtual Assistant

EECE 2140 · Computing Fundamentals for Engineers

Final project

A chatbot that handles the common stuff with plain rules first and only falls back to a local language model when nothing matches. Rule-based intent detection, a class that keeps conversation state, a summary feature, and an optional Ollama-backed GGUF fallback, all behind a Gradio web chat.

Tools: Python · Gradio · Ollama · Llama 3.1 8B (GGUF)

GitHub

More info

Why

Sending "thanks" or "ok" through a multi-billion-parameter model is wasteful. The assistant tries a rule-based decision tree first and only calls a local LLM (Llama 3.1 8B through Ollama, running on my own PC) for open-ended questions it has no rule for.

How it works

  1. The message is stripped and lowercased, and a turn counter increments.
  2. detectIntent looks for word patterns and returns one of a fixed set of intents: greeting, goodbye, name, mood, project info, project tech, exam, study, thanks, help, small talk, summary.
  3. Each intent has its own handler method on the VirtualAssistant class, which stores the user's name, a mood history, the topics seen (a set), and the recent chat history.
  4. If nothing matches, ggufFallback builds a short system prompt (who the user is, their mood) plus the last few turns and POSTs it to the Ollama API.
  5. The reply is personalised (sometimes uses your name, matches your casing: type in lowercase and it replies in lowercase) and shown in the Gradio chat.

Results

The rule-based path answers instantly and predictably; the LLM fallback is flexible but slow and heavy. The 22-page technical report covers the architecture, pseudocode for the main components, the data structures used and why, and test conversations.


« Back to all projects