This file provides guidance to AI coding tools and developers when working with code in this repository.
HugeGraph-LLM is a comprehensive toolkit that bridges graph databases and large language models, part of the Apache HugeGraph AI ecosystem. It enables seamless integration between HugeGraph and LLMs for building intelligent applications with three main capabilities: Knowledge Graph Construction, Graph-Enhanced RAG, and Text2Gremlin query generation.
- Language: Python 3.10+ (uv package manager required)
- Framework: FastAPI + Gradio for web interfaces
- Graph Database: HugeGraph Server 1.5+
- LLM Integration: LiteLLM (supports OpenAI, Ollama, Qianfan, etc.)
- Vector Operations: FAISS, NumPy, and will support multiple Vector DB soon
- Code style: ruff & mypy (on the way, soon)
- Key Dependencies: hugegraph-python-client
# Install dependencies and create virtual environment (uv already installed)
uv sync
# Activate virtual environment
source .venv/bin/activate
# Launch main RAG demo application
python -m hugegraph_llm.demo.rag_demo.app
# Custom host/port
python -m hugegraph_llm.demo.rag_demo.app --host 127.0.0.1 --port 18001pytest src/tests/
# Or using unittest
python -m unittest discover src/tests/PS: we skip Docker Deployment details here.
src/hugegraph_llm/api/- FastAPI endpoints (rag_api.py, admin_api.py)src/hugegraph_llm/demo/rag_demo/- Main Gradio UI applicationsrc/hugegraph_llm/operators/- Core processing pipelinessrc/hugegraph_llm/models/- LLM, embedding, reranker implementationssrc/hugegraph_llm/indices/- Vector and graph indexingsrc/hugegraph_llm/config/- Configuration managementsrc/hugegraph_llm/utils/- Utilities, logging, decorators
-
KG Construction (
operators/kg_construction_task.py)- Text chunking and vectorization pipeline
- Schema management and validation
- Information extraction using LLMs
- Graph data commitment to HugeGraph
-
Graph RAG (
operators/graph_rag_task.py)- Multi-modal retrieval (vector, graph, hybrid)
- Keyword extraction and entity matching
- Graph traversal and Gremlin query generation
- Result merging and reranking
-
Text2Gremlin (
operators/gremlin_generate_task.py)- Natural language to Gremlin query conversion
- Template-based and few-shot learning approaches
- Main config:
.envfile (generate withconfig.generatemodule) - Prompt config:
src/hugegraph_llm/resources/demo/config_prompt.yaml - HugeGraph connection settings in environment variables
- LLM provider configuration through
LiteLLM&openai/ollamaclient
- Prerequisites: Ensure HugeGraph Server is running and LLM provider is configured
- Environment Setup: Use UV for dependency management, activate virtual environment
- Configuration: Generate configs and set up .env file with proper credentials
- Development: Use Gradio demo for interactive testing, FastAPI for programmatic access
- Testing: Unit tests use standard unittest framework in src/tests/
- Always use
uvpackage manager instead ofpipfor dependency management - HugeGraph Server must be accessible while running the app
- The system supports multiple LLM providers through
LiteLLMabstraction - Each file should be better < 600 lines for maintainability