AI Campus • Project guide

Custom Knowledge AI Chatbot

Build a local chat baseline, then add editable guidelines, session storage and a streaming web interface.

Build guide and prerequisites

Follow this roadmap to implement and validate your own application, then record your observed results.

  • Basic Python functions and JSON; basic React for the web extension.
  • A small local model that fits your available memory and a short non-sensitive guidelines document.

Required tools and free options

  • Python
  • Ollama with an explicitly local model
  • SQLite
  • Optional React or Next.js frontend

Cost: The local route needs no paid API subscription. Model downloads require bandwidth and enough disk/RAM; runtime uses your own hardware. Hosted APIs and deployment are optional and may cost money.

Start with a smaller working example

Downloadable local chatbot baseline →

This starter is a local chat baseline. It does not implement the streaming full-stack interface, document retrieval or persistent history described in the extended project.

Build it step by step

  1. 1. Establish the local baseline

    Open the linked starter, follow its setup and run one question using an explicitly local Ollama model. Record the model name and confirm you receive a response before adding a browser interface.

  2. 2. Define the chat contract

    Write a guidelines.txt file covering purpose, tone and an explicit uncertainty response. Represent messages as role/content objects. Keep the guidelines separate from user text and limit message lengths. Guidelines alone do not provide reliable document retrieval.

  3. 3. Store separate conversations

    Create SQLite sessions and messages tables with a session ID, role, content and timestamp. Save each completed exchange in a transaction. Load only the selected session and a bounded recent history to fit the context window.

  4. 4. Add the server boundary

    Implement a local server route that validates the conversation ID and user message before calling Ollama on loopback. Keep inference server addresses on the server; return a clear error if the model is unavailable.

  5. 5. Build the browser interaction

    Render chat messages and expose send, cancel and new-conversation actions. Add loading and error states first. For streaming, read incremental response chunks and append only the current assistant message; cancelling must stop the active request.

  6. 6. Check and document the result

    Test a normal question, a question outside the guidelines, empty input, model disconnection and two separate sessions. Save a screenshot and a README distinguishing observed behavior from intended behavior. Do not claim document grounding until you add retrieval and test citations.

Expected output and validation

A local chat application with identifiable sessions, recoverable errors and a documented model. The streaming interface and persistence are work you implement after the supplied baseline.

  • Two sessions must not show one another’s messages.
  • A cancelled response stops growing and a later message still works.
  • Unavailable models produce a useful error without deleting previous messages.

From setup to a working demo

  1. Check Python: python --version. On Windows, if it is not found, try py --version.
  2. Run the smallest local example first. Use the guide’s inputs, expected output and failure cases before adding more features.
  3. API keys: The local starters need none. If you choose a cloud provider later, keep its key in a server environment variable and out of browser code and Git.
  4. Setup stuck? Record the exact command, Python version and redacted error. “Module not found” usually means the package was installed in a different environment; use the same Python executable to install and run.
  5. Before sharing: Add a local demo video or screenshot, README and observed tests. For public hosting, follow your framework’s deployment guide and check environment variables, secrets and hosting costs first.

Three checkpoints before your demo

  • Run the sample from the guide and record the actual output in your README.
  • Change one input, write down what you expect, then compare it with what happens.
  • Give a classmate just your README. Fix one thing that gets in their way when they try to run it.

Optional framework starter: Vercel Chatbot ↗. Follow its current README; model access and hosting may require paid services.

Share a build or ask for feedback

Share your build or setup question without leaving AI Campus. Admin replies appear on your private status link. Review depends on availability; no response time is promised.

Include the exact command and redacted error for setup help. Do not send API keys, passwords, private resumes or personal documents. This does not subscribe or unsubscribe you.

Official references

Free to read. Software setup, model access and hosted services have their own requirements. References checked 3 November 2026.

AI Campus Weekly Dispatch

Keep learning with AI Campus

Get AI news, tools, skills and opportunities in the weekly dispatch.

Get a welcome AI briefing and weekly Sunday updates. Unsubscribe anytime in 1 click.

Learn and build with BrandMint AI

Learning opportunities with BrandMint AI

Explore AI news, tools and skills on AI Campus. When you want to learn further, choose BrandMint AI courses, mentoring or learning apps below.

AI Campus guides are free. Check each platform for course fees and availability.

Courses and mentoring

Learn AI foundations or develop practical software skills.

Learning apps

Practise AI skills or explore CBSE learning support.

Marketing and filmmaking

Build a portfolio through creative and practical learning.

Essential cookies keep the site working. Language and subscription preferences stay on your device. We do not currently use optional analytics or advertising cookies.

Details and settings