Skip to content

Domain-Chatbot — A fully local, domain-aware AI chatbot with Chat, Coding, and Exam modes, featuring real-time streaming, syntax highlighting, and KaTeX math rendering using Ollama.

License

Notifications You must be signed in to change notification settings

Sabithulla-16/Domain-Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Domain-Chatbot

A Local Domain-Based AI Chatbot

Developer: Sabithulla


📌 Overview

Domain-Chatbot is a fully local, domain-aware AI chatbot that changes its behavior based on the selected domain:

  • 💬 Chat → Friendly, casual conversations
  • 💻 Coding → Programming help with syntax highlighting
  • 📚 Exam → Exam-oriented answers with structured points and formulas

The project runs 100% offline, uses Ollama for local LLMs, and supports real-time streaming, KaTeX math rendering, and code highlighting — all without any API keys.


✨ Why Domain-Chatbot?

Most chatbots treat every question the same.

Domain-Chatbot doesn’t.

  • 💬 Chat mode → friendly, human-like conversation
  • 💻 Coding mode → clean code + syntax highlighting
  • 📘 Exam mode → structured answers + KaTeX formulas

All of this runs locally — no API keys, no internet dependency.


🖼️ Screenshots

💬 Chat Domain

Chat Domain

💻 Coding Domain

Coding Domain

📘 Exam Domain (KaTeX formulas)

Exam Domain


🧪 Example Prompts

Chat

Explain black holes like I'm 10 years old

Coding

Write a Python program to check whether a number is palindrome

Exam

Derive Ohm’s law and explain with formula


✨ Key Features

  • 🔁 Real-time streaming responses
  • 🧠 Domain-based AI behavior
  • 🧮 Automatic KaTeX rendering for formulas
  • 🖍️ Syntax highlighting for code
  • 💡 Centered suggestion prompts (one-time per domain)
  • 🔒 Fully offline & privacy-friendly
  • ⚡ Lightweight frontend (no frameworks)

🧠 Domain Behavior

Domain Behavior Special Handling
Chat Friendly & conversational Natural responses
Coding Developer-focused Highlight.js for code
Exam Exam-oriented KaTeX for formulas

🏗️ Architecture

Frontend (HTML + CSS + JavaScript)

FastAPI Backend

Ollama Local Models


🧮 Smart Formula Detection (KaTeX Logic)

The chatbot intelligently decides what should be rendered as math.

Rules:

  • Text inside ** ** containing math symbols (= + - * / ^) → rendered using KaTeX
  • Text inside ** ** without math symbols → rendered as bold text
  • Normal text remains unchanged

Examples:

  • R = V / I → KaTeX formula
  • Resistance → Bold text
  • Explanation: → Normal text

This avoids converting headings or explanations into formulas.


🛠️ Tech Stack

Backend

  • Python 3.9+
  • FastAPI
  • Uvicorn
  • Requests
  • Ollama (Local LLM runtime)

Frontend

  • HTML
  • CSS
  • JavaScript
  • KaTeX (Math rendering)
  • Highlight.js (Code highlighting)

AI Models (via Ollama)

  • qwen2.5:0.5b → Chat
  • qwen2.5-coder:0.5b → Coding
  • gemma:2b → Exam

📂 Project Structure

Domain-Chatbot
├── backend
│ ├── main.py
│ ├── router.py
├── frontend
│ ├── index.html
├── assets
│ ├── chat.png
│ ├── coding.png
│ ├── exam.png
├── README.md


⚙️ Installation & Setup

Requirements

  • Python 3.9 or above
  • Ollama installed locally

Ollama Models Required

  • qwen2.5:0.5b
  • qwen2.5-coder:0.5b
  • gemma:2b

Python Dependencies

  • fastapi
  • uvicorn
  • requests

▶️ How to Run

  1. Start Ollama locally
  2. Run FastAPI backend
  3. Open frontend/index.html in browser
  4. Select a domain
  5. Use suggestion prompts or type your own query
  6. Watch responses stream live

👨‍💻 Developer

Sabithulla
Built with curiosity, logic, and a focus on clean AI user experience.


⭐ Support

If you found this project useful:

  • ⭐ Star the repository
  • 🍴 Fork it
  • 🧠 Extend it with new domains

🔮 Roadmap

  • Voice input and output
  • Mobile-friendly UI
  • More domains (Medical, Legal, Interview)
  • Model selector in UI

📜 License

This project can be released under the MIT License. You are free to use, modify, and distribute it.

About

Domain-Chatbot — A fully local, domain-aware AI chatbot with Chat, Coding, and Exam modes, featuring real-time streaming, syntax highlighting, and KaTeX math rendering using Ollama.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •