AI Campus • Practical resources
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. 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. 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. 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. 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. 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. 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.
Official references
Free to read. Software setup, model access and hosted services have their own requirements. References checked 3 November 2026.