跳转到主要内容

HugeGraph-AI

hugegraph-ai 提供 HugeGraph 的 Python 客户端、图机器学习工具,以及面向知识图谱构建和 GraphRAG 的 LLM 工具。

Apache License 2.0 · Ask DeepWiki

模块

仓库使用 uv workspace,其成员是 hugegraph-llm 和 hugegraph-python-client。hugegraph-ml 和 vermeer-python-client 是可编辑的路径依赖,不在 workspace members 中。当前仓库版本为 1.7.0。客户端源码目录叫 hugegraph-python-client,但发行包名是 hugegraph-python。

环境要求

  • HugeGraph-AI 根目录 workspace:Python 3.10 或更高版本;HugeGraph-LLM 还要求低于 3.12
  • HugeGraph-ML:Python 3.10 或更高版本
  • PyPI 上的 hugegraph-python 1.5.0:Python 3.9 或更高版本;当前仓库源码随 workspace 使用 Python 3.10 或更高版本
  • Vermeer Python 客户端:当前源码要求 Python 3.10 或更高版本;发行元数据仍声明 >=3.9,详见客户端页
  • uv 0.7 或更高版本
  • HugeGraph Server 1.5.0 或更高版本;当前 workspace 的 Python 客户端会拒绝可探测到的更低版本

可选依赖组

根项目为每个模块声明一个 extra,另有几个组合项:

Extra安装内容
llmhugegraph-llm
mlhugegraph-ml
python-clienthugegraph-python(源码目录 hugegraph-python-client)
vermeervermeer-python-client
devpytest、pytest-cov、coverage、pylint、ruff、mypy、ty、pre-commit
nk-llmhugegraph-llm、hugegraph-python-client,以及编译镜像所需的 Nuitka
all四个模块包

hugegraph-llm 自身还声明了 vectordb extra,用于安装 pymilvus 和 qdrant-client。

Docker Compose 部署

仓库提供同时启动 HugeGraph Server 和 RAG 服务的 Compose 文件:

git clone https://github.com/apache/hugegraph-ai.git
cd hugegraph-ai
cp docker/env.template docker/.env
# 编辑 docker/.env,将 PROJECT_PATH 改为当前仓库的绝对路径
touch hugegraph-llm/.env
# 在 hugegraph-llm/.env 中设置 GRAPH_URL=server:8080,并填写匹配 Server 的账号
cd docker
docker compose -f docker-compose-network.yml up -d

默认地址:

  • HugeGraph Server:http://localhost:8080
  • RAG 服务和 Web 界面:http://localhost:8001

从源码启动 RAG 服务

git clone https://github.com/apache/hugegraph-ai.git
cd hugegraph-ai
uv sync --extra llm
source .venv/bin/activate
cd hugegraph-llm
python -m hugegraph_llm.demo.rag_demo.app

uv sync 会在仓库根目录创建 .venv。从根目录安装可让 uv 一起解析 workspace 成员和路径依赖。当前仓库不跟踪 uv.lock;uv sync 会按 pyproject.toml 中的依赖声明和版本约束解析依赖。

安装 ML 依赖

cd hugegraph-ai
uv sync --extra ml
source .venv/bin/activate
cd hugegraph-ml/src

示例脚本位于 hugegraph-ml/src/hugegraph_ml/examples/。

后续阅读