An intelligent knowledge base system for the Hulo programming language, powered by RAG (Retrieval-Augmented Generation), vector databases, and large language models.
- π Semantic Search: Advanced vector-based document search with multi-round retrieval
- π€ AI-Powered Q&A: Get intelligent answers based on Hulo documentation
- π Multi-language Support: Handle both English and Chinese documentation
- ποΈ Modular Architecture: Pluggable vector stores (Memory/ChromaDB) and LLM providers
- β‘ High Performance: Async processing with FastAPI
- π Privacy-First: Support for local LLM deployment with Ollama
- π Rich Analytics: Document statistics and search insights
- π οΈ Developer Friendly: RESTful API with automatic documentation
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Document β β Vector Store β β LLM Service β
β Processor βββββΆβ (Memory/ βββββΆβ (OpenAI/ β
β β β ChromaDB) β β Ollama) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Knowledge β β FastAPI β β Multi-round β
β Service ββββββ HTTP API βββββ Retrieval β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
-
Clone the repository
git clone https://github.com/your-username/hulo-knowledge-base.git cd hulomind
-
Initialize the documentation submodule
git submodule update --init --recursive
-
Install dependencies
uv sync
-
Set up environment variables
cp env.example .env # Edit .env with your configuration
-
Initialize the knowledge base
uv run python scripts/init_knowledge_base.py
-
Start the server
uv run python -m src.main
-
Access the API
- API Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
curl -X POST "http://localhost:8000/api/search" \
-H "Content-Type: application/json" \
-d '{"query": "function definition in Hulo"}'
curl -X POST "http://localhost:8000/api/ask" \
-H "Content-Type: application/json" \
-d '{"query": "What is the difference between let and var in Hulo?"}'
curl "http://localhost:8000/api/stats"
curl "http://localhost:8000/api/documents?category=grammar&language=en&limit=10"
uv run python -m tests.test_api
import requests
# Search for documents
response = requests.post("http://localhost:8000/api/search", json={
"query": "variable declaration"
})
results = response.json()
print(f"Found {results['total_results']} documents")
# Ask a question
response = requests.post("http://localhost:8000/api/ask", json={
"query": "How do I create a function in Hulo?"
})
answer = response.json()
print(f"Answer: {answer['answer']}")
Variable | Description | Default |
---|---|---|
API_HOST |
API server host | 0.0.0.0 |
API_PORT |
API server port | 8000 |
DEBUG |
Enable debug mode | false |
OPENAI_API_KEY |
OpenAI API key | - |
DASHSCOPE_API_KEY |
Qwen API key | - |
DEFAULT_VECTOR_STORE |
Vector store type (memory /chroma ) |
memory |
CHROMA_PERSIST_DIRECTORY |
ChromaDB persistence directory | ./data/chroma |
EMBEDDING_MODEL |
Sentence transformer model | sentence-transformers/all-MiniLM-L6-v2 |
DOCS_PATH |
Documentation path | ./docs/src |
The system supports multiple LLM providers with automatic fallback:
- OpenAI (requires
OPENAI_API_KEY
) - Qwen API (requires
DASHSCOPE_API_KEY
) - Local Ollama (requires Ollama running with
qwen2.5:7b
) - Mock Service (fallback for testing)
- Memory Store: Fast, in-memory storage (default)
- ChromaDB: Persistent, production-ready storage
uv run pytest
uv run black src/
uv run isort src/
uv run mypy src/
uv run ruff check src/
hulo-knowledge-base/
βββ src/
β βββ config/ # Configuration management
β βββ models/ # Data models
β βββ processors/ # Document processing
β βββ vectorstore/ # Vector storage backends
β βββ services/ # Business logic services
β βββ mcp/ # MCP protocol support
β βββ main.py # FastAPI application
βββ scripts/ # Utility scripts
βββ tests/ # Test suite
βββ docs/ # Documentation (submodule)
βββ data/ # Data storage
βββ pyproject.toml # Project configuration
The system uses a sophisticated two-stage retrieval process:
- Broad Search: Low threshold (0.3) to capture more candidates
- Refined Search: High threshold (0.7) to filter high-quality results
- Merge & Deduplicate: Combine results and remove duplicates
Documents are intelligently split based on Markdown headers rather than fixed line counts, preserving semantic integrity.
from src.vectorstore import VectorStoreFactory
# Use memory store
memory_store = VectorStoreFactory.create("memory")
# Use ChromaDB store
chroma_store = VectorStoreFactory.create("chroma")
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.