> ## Documentation Index
> Fetch the complete documentation index at: https://docs.siliconflow.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Chat2Graph

> 更新日期：2025年5月23日

## 关于 Chat2Graph

[Chat2Graph](https://github.com/TuGraph-family/chat2graph) 是一个图原生的智能体系统（Graph Native Agentic System），通过利用图数据结构在关系建模、可解释性等符号主义的天然优势，对智能体的推理、规划、记忆、知识、工具协作等关键能力进行增强，同时借助智能体技术推进图数据库智能化，降低用图门槛，加速内容生成，实现与图对话。做到图计算技术与人工智能技术的深度融合。

<Frame>
  <img src="https://mintcdn.com/siliconflow-37161621/tCRvDTXiZEw0OYru/images/usercases/chat2graph/head.webp?fit=max&auto=format&n=tCRvDTXiZEw0OYru&q=85&s=1b9373972e00a7cdec679ebfe0b77c79" width="1200" height="442" data-path="images/usercases/chat2graph/head.webp" />
</Frame>

## 获取 API Key

1. 打开 [SiliconFlow](https://cloud.siliconflow.cn/) 官网 并注册账号（如果注册过，直接登录即可）。
2. 完成注册后，打开 [API密钥](https://cloud.siliconflow.cn/account/ak) ，创建新的 API Key，点击密钥进行复制，以备后续使用。

## 部署 Chat2Graph

### 下载 Chat2Graph

```yaml theme={null}
git clone https://github.com/TuGraph-family/chat2graph.git
```

### 准备执行环境

准备符合要求的 Python 和 NodeJS 版本。

* **Python**: 推荐[Python == 3.10](https://www.python.org/downloads)。
* **NodeJS**: 推荐[NodeJS >= v16](https://nodejs.org/en/download)。

您可以使用 `conda` 等工具来管理您的 Python 环境：

```yaml theme={null}
conda create -n chat2graph_env python=3.10
conda activate chat2graph_env
```

### 构建 Chat2Graph

一键构建 Chat2Graph：

```yaml theme={null}
cd chat2graph
./bin/build.sh
```

### 配置 SiliconFlow 模型

准备 `.env` 配置文件：

```yaml theme={null}
cp .env.template .env && vim .env
```

填写 SiliconFlow 模型配置：

```yaml theme={null}
LLM_NAME=deepseek-ai/DeepSeek-V3
LLM_ENDPOINT=https://api.siliconflow.cn/v1
LLM_APIKEY={your-siliconflow-api-key}
EMBEDDING_MODEL_NAME=BAAI/bge-large-zh-v1.5
EMBEDDING_MODEL_ENDPOINT=https://api.siliconflow.cn/v1/embeddings
EMBEDDING_MODEL_APIKEY={your-siliconflow-api-key}
```

### 启动 Chat2Graph

一键启动 Chat2Graph：

```yaml theme={null}
./bin/start.sh
```

当看到如下日志时，表示 Chat2Graph 已成功启动：

```latex theme={null}
Starting server...
Web resources location: /Users/florian/code/chat2graph/app/server/web
System database url: sqlite:////Users/florian/.chat2graph/system/chat2graph.db
Loading AgenticService from app/core/sdk/chat2graph.yml with encoding utf-8
Init application: Chat2Graph
Init the Leader agent
Init the Expert agents
  ____ _           _   ____   ____                 _     
 / ___| |__   __ _| |_|___ \ / ___|_ __ __ _ _ __ | |__  
| |   | '_ \ / _` | __| __) | |  _| '__/ _` | '_ \| '_ \ 
| |___| | | | (_| | |_ / __/| |_| | | | (_| | |_) | | | |
 \____|_| |_|\__,_|\__|_____|\____|_|  \__,_| .__/|_| |_|
                                            |_|          

 * Serving Flask app 'bootstrap'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5010
 * Running on http://192.168.1.1:5010
Chat2Graph server started success !
```

## 使用 Chat2Graph

你可以在浏览器访问 [http://localhost:5010/](http://localhost:5010/) 使用 Chat2Graph。

<Frame>
  <img src="https://mintcdn.com/siliconflow-37161621/tCRvDTXiZEw0OYru/images/usercases/chat2graph/index.webp?fit=max&auto=format&n=tCRvDTXiZEw0OYru&q=85&s=5c79b5d43b33cabf0279f6eb418d44dc" width="1200" height="325" data-path="images/usercases/chat2graph/index.webp" />
</Frame>

### 注册图数据库

提前注册图数据库实例，可以体验完整的 Chat2Graph 的「与图对话」功能。当前支持 [Neo4j](https://neo4j.com/) 和 [TuGraph](https://tugraph.tech/) 图数据库。

<Frame>
  <img src="https://mintcdn.com/siliconflow-37161621/tCRvDTXiZEw0OYru/images/usercases/chat2graph/gdb-mng.webp?fit=max&auto=format&n=tCRvDTXiZEw0OYru&q=85&s=65bcc3ae9893648e7f0b3bbbd7a2f564" width="1200" height="221" data-path="images/usercases/chat2graph/gdb-mng.webp" />
</Frame>

启动 Neo4j 实例：

```plain theme={null}
docker pull neo4j:latest
docker run -d -p 7474:7474 -p 7687:7687 --name neo4j-server --env NEO4J_AUTH=none \
  --env NEO4J_PLUGINS='["apoc", "graph-data-science"]' neo4j:latest
```

启动 TuGraph 实例：

```latex theme={null}
docker pull tugraph/tugraph-runtime-centos7:4.5.1
docker run -d -p 7070:7070 -p 7687:7687 -p 9090:9090 --name tugraph-server \
  tugraph/tugraph-runtime-centos7:latest lgraph_server -d run --enable_plugin true
```

### 与图轻松对话

自动完成知识图谱的构建与分析任务：

<Frame>
  <img src="https://mintcdn.com/siliconflow-37161621/tCRvDTXiZEw0OYru/images/usercases/chat2graph/chat-layout-2.webp?fit=max&auto=format&n=tCRvDTXiZEw0OYru&q=85&s=d0a78c00d38a2b2321050a0c193d3337" width="1200" height="646" data-path="images/usercases/chat2graph/chat-layout-2.webp" />
</Frame>

支持图模型与图数据的实时渲染。

<Frame>
  <img src="https://mintcdn.com/siliconflow-37161621/tCRvDTXiZEw0OYru/images/usercases/chat2graph/chat-layout-3.webp?fit=max&auto=format&n=tCRvDTXiZEw0OYru&q=85&s=f955b5fa8eedb1d878df32252bd28dc2" width="1200" height="646" data-path="images/usercases/chat2graph/chat-layout-3.webp" />
</Frame>

## 集成 Chat2Graph

Chat2Graph 提供了清晰简洁的 SDK API，让你轻松定制智能体系统。

配置 SiliconFlow 模型：

```latex theme={null}
SystemEnv.LLM_NAME="deepseek-ai/DeepSeek-V3"
SystemEnv.LLM_ENDPOINT="https://api.siliconflow.cn/v1"
SystemEnv.LLM_APIKEY="{your-siliconflow-api-key}"
SystemEnv.EMBEDDING_MODEL_NAME="BAAI/bge-large-zh-v1.5"
SystemEnv.EMBEDDING_MODEL_ENDPOINT="https://api.siliconflow.cn/v1/embeddings"
SystemEnv.EMBEDDING_MODEL_APIKEY="{your-siliconflow-api-key}"
```

仿写 `chat2graph.yml` 文件，一键初始化智能体：

```latex theme={null}
chat2graph = AgenticService.load("app/core/sdk/chat2graph.yml")
```

同步调用智能体：

```latex theme={null}
answer = chat2graph.execute("What is TuGraph ?").get_payload()
```

异步调用智能体：

```latex theme={null}
job = chat2graph.session().submit("What is TuGraph ?")
answer = job.wait().get_payload()
```
