Skip to main content

K-CHAT — Universal Chatbot Engine. Anti-hallucination by construction.

Project description

K-CHAT — Universal Chatbot Engine

Zero-hallucination by construction.
Drop a folder of documents. Get a chatbot. No ML expertise needed.

pip install kchat
kchat init ./helpdesk --template government
kchat chat --data ./helpdesk

Three commands. Working bot. No API key required.


Quick Start

# Install
pip install kchat

# Create a bot from a pre-built template
kchat init ./my-bot --template restaurant

# Chat with it (uses SimulatedLLM — works offline, no API key)
kchat chat --data ./my-bot

# Or use OpenAI/DeepSeek
pip install kchat[openai]
# Edit my-bot/config.json → change llm.provider to "openai" or "deepseek"

Available templates

kchat templates
Template Description
government FAQ bot for passports, permits, taxes
restaurant Menu info, hours, reservations
healthcare General health information and clinic FAQ

How It Works

K-CHAT uses an Industry Pack — a folder of data files. No code changes needed to onboard a new domain.

my-industry-pack/
├── config.json       # Bot identity, LLM choice, retrieval settings
├── intents.json      # Intent taxonomy (optional)
├── refusal.json      # Fallback responses + escalation contact
├── knowledge/        # Documents the bot answers from
│   ├── overview.md
│   └── faq.md
├── context/          # Style guides, policies (optional)
├── SOUL.md           # Personality definition (optional)
├── skills/           # Custom Python workflows (optional)
└── tools/            # Custom API tools (optional)

The pipeline:

User Input → Sanitize → Ethics Check → Intent Classify → Emotion Detect
→ Cultural Adapt → Retrieve Knowledge → LLM (grounded prompt)
→ Anti-Hallucination Verify → Tone Apply → Response

Anti-Hallucination

K-CHAT never asks the LLM to recall facts. It:

  1. Injects only retrieved context into the prompt
  2. Verifies every response against the source documents
  3. Falls back to extractive answers if verification fails

Three verification strategies: entity consistency, citation coverage, text overlap.


CLI Reference

Command Description
kchat init <path> Create a new industry pack
kchat init <path> --template <name> Create from pre-built template
kchat templates List available templates
kchat chat --data <path> Interactive chat in terminal
kchat serve --data <path> REST API server (stdlib HTTP)
kchat validate --data <path> Validate pack structure
kchat curate --data <path> Audit knowledge quality
kchat info --data <path> Show resolved config
kchat audit --data <path> Full self-audit

Chat REPL

(My Bot) You > /help
  /quit   - Exit
  /clear  - Clear screen
  /multiline - Enter multiline mode (end line with """)
  /help   - Show this help

(My Bot) You > What are your hours?
Bot: We are open Monday to Saturday: Lunch 11-2:30, Dinner 5-10.
  sources: faq.md | confidence: High (0.93) | intent: info_lookup

REST API

kchat serve --data ./my-bot --port 8000
curl -X POST http://localhost:8000/chat \
  -H 'Content-Type: application/json' \
  -d '{"message": "What are your hours?"}'

Endpoints: GET /health, POST /chat, WS /ws, GET /info

Auth: set KCHAT_API_KEY env var. Rate limit: set KCHAT_RATE_LIMIT (req/min).


Extensions

Enable via config.json:

{
  "extensions": {
    "live": {"enabled": true},
    "conversational_memory": {"enabled": true},
    "multimodal": {"enabled": true},
    "predictive": {"enabled": true}
  }
}
Extension What it does
live Injects real-time data into context (prices, queues, sensors)
conversational_memory Tracks user preferences, mood, relationship stage
multiagent Routes queries to specialist agents
multimodal Enhances emotion detection (text + optional voice/visual)
adaptive Tracks strategy effectiveness, recommends adjustments
predictive Assesses risk based on mood patterns and conversation signals
rlhf Collects feedback and computes reward signals
voice STT → Bot.chat() → TTS pipeline

Import directly: from engine.extensions.voice import VoiceManager


Configuration

Minimal config.json:

{
  "name": "My Bot",
  "persona": "Helpful, accurate, and concise.",
  "llm": {"provider": "simulated"}
}

Available LLM providers: simulated (default, offline), openai, deepseek.

Full config reference: kchat info --data ./my-bot


Deployment

Railway

# Deploy from GitHub
# Set KCHAT_DATA=./my-bot
# Set PORT=8000

VPS / Docker

# Install, create pack, run server
pip install kchat
kchat init ./my-bot --template government
kchat serve --data ./my-bot --host 0.0.0.0 --port 8000

Vercel (serverless)

See clients/nail-art/ for a working Vercel deployment example.


Why K-CHAT?

Instead of... K-CHAT gives you...
LangChain (framework) A turnkey engine with a data contract
Building from scratch Anti-hallucination out of the box
Paying per chatbot One engine, infinite domains
Complex ML pipelines Deterministic, auditable verification

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kstudiochat-1.0.0.tar.gz (116.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kstudiochat-1.0.0-py3-none-any.whl (108.9 kB view details)

Uploaded Python 3

File details

Details for the file kstudiochat-1.0.0.tar.gz.

File metadata

  • Download URL: kstudiochat-1.0.0.tar.gz
  • Upload date:
  • Size: 116.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for kstudiochat-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f635425fa8e49e77aea7e678bbb8d4efebce816857459c4d9e7ab529460d040a
MD5 1eccf9bf9d628a597c2100cab1ad6652
BLAKE2b-256 0b58afa67db6085c8053acdd6816c738303bdcbff87238183444aeb9aa3b2c77

See more details on using hashes here.

File details

Details for the file kstudiochat-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: kstudiochat-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 108.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for kstudiochat-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5fbdae343180ee77a3ba0033c8a4efd10dc32dfec503f244fef24c03dd91416a
MD5 e72deb37f0bdba6b6ef35a264da02748
BLAKE2b-256 e81d8a508f85508743ac926152fdb06260ec7ea95a322cbe3d6fc229fb0adacd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page