Team Ai
Apppublic

hanbit-church/hanbit-knowledge-base

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

Hanbit Church Knowledge Base Assistant

A comprehensive church information system powered by AI, providing up-to-date information about Hanbit Church ministries, events, and community through an intelligent assistant with multilingual RAG (Retrieval-Augmented Generation) capabilities.

Features

πŸ›οΈ Church-Focused AI Assistant

  • β€”Hanbit Church Information: Specialized assistant providing current information about church ministries, events, and community
  • β€”Multilingual Support: Full Korean and English conversation support
  • β€”Knowledge Base Priority: Uses church documents as primary source, supplements with general Christian knowledge
  • β€”Source Attribution: Always cites church documents when providing information

πŸ€– Advanced AI Capabilities

  • β€”Real-time Streaming: Live response streaming for responsive user experience
  • β€”RAG Integration: Retrieval-Augmented Generation with multilingual embeddings
  • β€”Conversation History: Persistent conversation tracking across sessions
  • β€”Dual LLM Support: Ollama (local) and OpenAI (production) integration

πŸ“š Knowledge Management

  • β€”Document Upload: Support for PDF, Word, and Markdown documents
  • β€”Vector Database: Qdrant-powered semantic search with multilingual embeddings
  • β€”Smart Chunking: Intelligent document processing with overlap for better context
  • β€”Multilingual Embeddings: Using intfloat/multilingual-e5-large for 100+ language support

πŸ–₯️ User Interfaces

  • β€”Web Interface: Modern Gradio-based UI with optional drag-and-drop file upload
  • β€”Terminal Interface: Command-line chat with streaming responses
  • β€”File Management: Upload, search, and manage church documents (when enabled)
  • β€”Chat History: Clear conversation history and restore initial greeting
  • β€”Configurable UI: File upload can be disabled via environment variable for deployment flexibility

Prerequisites

  • β€”Python 3.10+
  • β€”Ollama installed and running locally (for local development)
  • β€”Qdrant vector database (local or cloud)
  • β€”OpenAI API key (for production deployment)

Setup Options

Local Development Setup
bash
# Install Ollama (macOS)
brew install ollama

# Start Ollama service
ollama serve

# Pull the qwen2.5-coder model
ollama pull qwen2.5-coder

# Install and start Qdrant
docker run -p 6333:6333 qdrant/qdrant
Production Setup
  • β€”OpenAI API account and key
  • β€”Qdrant Cloud instance or self-hosted Qdrant
  • β€”Environment variables configured for production

Installation

  1. 1.Clone the repository
bash
git clone <repository-url>
cd hanbit-knowledge-base
  1. 1.Install dependencies using uv (recommended) or pip
bash
# Using uv (recommended)
uv install

# Or using pip
pip install -r requirements.txt
  1. 1.Configure environment variables
bash
cp .env.example .env
# Edit .env file with your configuration:
# - LLM_PROVIDER (ollama/openai)
# - LLM_MODEL (optional)
# - EMBEDDING_MODEL (optional)
# - OPENAI_API_KEY (if using OpenAI)
# - QDRANT_URL and QDRANT_API_KEY (if using Qdrant Cloud)

Usage

Running the Applications

Web Interface (Recommended)
bash
uv run python app.py

Open your browser and go to http://localhost:7860 for the modern Hanbit Church assistant interface with:

  • β€”Real-time streaming chat
  • β€”Document upload and management
  • β€”Multilingual support (Korean/English)
  • β€”Initial greeting explaining church assistant capabilities
Terminal Interface
bash
uv run python main.py

Interactive command-line chat with streaming responses and church-focused greeting.

Using the Church Assistant

Church Information Queries
python
from src.agents.chat_agent import ChatAgent
from src.rag.knowledge_base import KnowledgeBase
from src.llm.factory import create_llm_provider

# Initialize the Hanbit Church assistant
llm_provider = create_llm_provider()
knowledge_base = KnowledgeBase()
agent = ChatAgent(llm_provider=llm_provider, knowledge_base=knowledge_base)

# Get initial greeting
print(agent.get_initial_greeting())

# Ask about church services
response = agent.chat("ν•œκ΅­μ–΄ 예배 μ‹œκ°„μ΄ μ–Έμ œμΈκ°€μš”?")  # Korean
print(response)

# Ask about ministries
response = agent.chat("What ministries are available for children?")  # English
print(response)

# Streaming responses
for chunk in agent.chat_stream("Tell me about upcoming events"):
    print(chunk, end="", flush=True)
Document Management
python
# Add church documents to knowledge base
success = knowledge_base.add_document(
    content="Church service times and information...",
    filename="service_schedule.pdf",
    file_type="pdf"
)

# Search for similar content
results = knowledge_base.search_similar("service times", limit=5)
print(results)

Available Methods

ChatAgent Methods
  • β€”get_initial_greeting() -> str: Get church-focused welcome message
  • β€”chat(message: str) -> str: Send message and get complete response
  • β€”chat_stream(message: str) -> Generator[str, None, None]: Stream response chunks in real-time
  • β€”clear_history(): Clear conversation history
  • β€”get_history() -> List[Dict[str, str]]: Get conversation history
  • β€”set_temperature(temperature: float): Adjust response creativity (0.0-1.0)
  • β€”set_rag_enabled(enabled: bool): Enable/disable knowledge base retrieval
KnowledgeBase Methods
  • β€”add_document(content, filename, file_type, metadata): Add document to knowledge base
  • β€”search_similar(query, limit): Semantic search for relevant content
  • β€”list_files(): List all uploaded documents
  • β€”delete_file(filename): Remove document from knowledge base

Environment Configuration

Create a .env file based on .env.example:

bash
# LLM Provider Configuration
LLM_PROVIDER=ollama  # Options: "ollama" or "openai"
LLM_MODEL=qwen2.5-coder  # Optional, uses provider defaults

# OpenAI Configuration (if using OpenAI)
OPENAI_API_KEY=your-openai-api-key

# Qdrant Configuration (optional, uses local by default)
QDRANT_URL=https://your-qdrant-instance.com:6333
QDRANT_API_KEY=your-api-key

# Embedding Model Configuration
EMBEDDING_MODEL=intfloat/multilingual-e5-large  # Default multilingual model

# Admin Configuration
IS_ADMIN=true  # Control admin features like file upload in web UI ("true" or "false")

# Logging Configuration
LOG_LEVEL=INFO
LOG_FORMAT=structured
Supported Models
  • β€”LLM Models: Any Ollama model or OpenAI model
  • β€”Embedding Models:
  • β€”intfloat/multilingual-e5-large (default, 1024 dims)
  • β€”intfloat/multilingual-e5-base (768 dims)
  • β€”intfloat/multilingual-e5-small (384 dims)
  • β€”all-MiniLM-L6-v2 (384 dims, English-only)

Development

Running Tests

bash
# Run all tests
PYTHONPATH=. uv run pytest tests/ -v

# Run specific test file
PYTHONPATH=. uv run pytest tests/agents/test_chat_agent.py -v

Project Structure

src/
 agents/
    chat_agent.py       # Main ChatAgent implementation
tests/
 agents/
    test_chat_agent.py  # Unit tests for ChatAgent
CLAUDE.md                   # Development instructions
README.md                   # This file
main.py                     # Terminal chat interface
app.py                      # Gradio web interface
.env.example               # Sample environment configuration
pyproject.toml             # Project configuration

Deployment Options

Local Development
  • β€”Uses Ollama for LLM inference
  • β€”Local Qdrant instance via Docker
  • β€”Multilingual embeddings for semantic search
Production Deployment
  • β€”OpenAI API for LLM inference
  • β€”Qdrant Cloud for vector database
  • β€”Environment variables for configuration
Hugging Face Spaces

Ready for deployment on Hugging Face Spaces with Gradio SDK.

Configuration for Different Deployments
  • β€”Admin Mode: Set IS_ADMIN=true for complete functionality with file upload
  • β€”User Mode: Set IS_ADMIN=false for simplified interface without admin features
  • β€”Restricted Environments: Disable admin features for security-sensitive deployments

Church-Specific Features

Multilingual Support

  • β€”Korean: Full conversation support in Korean
  • β€”English: Complete English language support
  • β€”Auto-detection: Responds in the language of the user's question

Knowledge Base Management

  • β€”Upload church documents (PDF, Word, Markdown)
  • β€”Semantic search across all uploaded content
  • β€”Source attribution for all church information
  • β€”Document versioning and management

Ministry Information

  • β€”Service schedules and locations
  • β€”Ministry programs and contacts
  • β€”Event announcements and details
  • β€”Community resources and support

Contributing

  1. 1.Follow TDD practices (write tests first)
  2. 2.Run tests after every change: PYTHONPATH=. uv run pytest tests/ -v
  3. 3.Update documentation as needed
  4. 4.Follow the existing code style and patterns
  5. 5.Ensure Hanbit Church focus in all features

License

[Add your license here]

Key Capabilities Summary

βœ… Church-Focused AI Assistant - Specialized for Hanbit Church information and community βœ… Multilingual Support - Korean and English conversation capabilities βœ… RAG Technology - Retrieval-Augmented Generation with semantic search βœ… Document Management - Upload, process, and search church documents βœ… Multiple Interfaces - Web UI and terminal-based chat βœ… Flexible Deployment - Local development and production-ready βœ… Source Attribution - Always cites church documents βœ… Christian Knowledge - Supplements with general Christian guidance when appropriate


Hanbit Church Knowledge Base Assistant - Connecting our community through intelligent, multilingual information access. πŸ›οΈ