Skip to content

Bootstrap hong_kb_bot: educational LLM chatbot repo with docs, reusable package, and practice notebooks#1

Draft
MacroMagic with Copilot wants to merge 2 commits into
mainfrom
copilot/build-chat-bot-repo
Draft

Bootstrap hong_kb_bot: educational LLM chatbot repo with docs, reusable package, and practice notebooks#1
MacroMagic with Copilot wants to merge 2 commits into
mainfrom
copilot/build-chat-bot-repo

Conversation

Copilot AI commented Apr 4, 2026

Copy link
Copy Markdown

Builds the repo from scratch as a step-by-step learning resource for engineering a Python chatbot with open-source LLMs, structured for a future Phase 2 RAG/knowledge-base upgrade.

Package (src/hong_kb_bot/)

  • config.pyBotConfig via pydantic-settings; env-driven, supports HuggingFace / OpenAI / local (Ollama) providers with all generation hyperparameters (temperature, top_p, max_new_tokens, etc.)
  • memory.py — three interchangeable strategies sharing BaseMemory: BufferMemory (keep all), WindowMemory (last k turns), SummaryMemory (LLM-compressed old context)
  • chatbot.py — provider-agnostic Chatbot; dispatches to HF Inference API, OpenAI, or any OpenAI-compatible local server. _build_context() is a deliberate no-op stub — Phase 2 drops a retriever in there without touching anything else
# Switch providers with one argument — same application code throughout
bot = Chatbot(BotConfig(provider="huggingface", model="HuggingFaceH4/zephyr-7b-beta"))
bot = Chatbot(BotConfig(provider="local",       local_model="llama3"))
bot = Chatbot(BotConfig(provider="openai",      openai_model="gpt-4o"))

Documentation (docs/)

  • 01_overview.md — learning objectives, guiding principles
  • 02_llm_options.md — detailed comparison of OpenAI API / HF Inference API / local transformers / Ollama / LangChain with code examples, trade-off table, and decision guide
  • 03_architecture.md — component breakdown with ASCII diagrams; explains stateless LLM calls, token budget, and the Phase 2 retrieval hook
  • 04_roadmap.md — Phase 2 RAG plan: ingestion pipeline, retriever design, embedding model choices, vector store options (FAISS vs ChromaDB vs Pinecone)

Notebooks (notebooks/)

Five sequential Jupyter notebooks designed for hands-on practice:

Notebook Covers
01_hello_llm First HF API call, response anatomy, finish_reason, temperature effect
02_huggingface_basics Model catalogue, top_p / top_k / repetition_penalty, side-by-side model comparison
03_conversation_memory Stateless LLM problem, all 3 memory strategies, matplotlib token-budget visualisation
04_prompt_engineering System prompts, zero-shot, few-shot, chain-of-thought, JSON output control, reusable templates
05_rag_foundations Embeddings, cosine similarity heatmap, FAISS index, mini RAG pipeline, Phase 2 Retriever preview

Tests (tests/)

29 unit tests (all LLM calls mocked — no API keys required): 14 for memory strategies, 15 for Chatbot including multi-turn history accumulation, provider dispatch, and config validation.

Original prompt

Hi Copilot can you please build this repo for the purpose of teaching me how to engineer a chat bot using available llm models in python? I know there is hugging face where I can call open source models but I do not know how to set it up in a git repo. Can you help me build this repo to demonstrate how to build a chat bot step by step and explain why you recommend such method verses other options so that I can understand the reasoning behind the design? I would like to have such details and method comparisons in documentations, and have some notebooks designed for me to practice with each step for better understanding of the parameters for tuning the chat bots. The end goal of this repo is to retain my knowledge base and retrieve info based on it. But at this phase we do not need to connect to any actual knowledge base yet, still I would like to build the repo ready for the nest phase of upgrade to info retreiving.

Copilot AI changed the title [WIP] Create repo for building a chat bot using LLM models in Python Bootstrap hong_kb_bot: educational LLM chatbot repo with docs, reusable package, and practice notebooks Apr 4, 2026
Copilot AI requested a review from MacroMagic April 4, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants