Skip to content

Commit bf5f0b1

Browse files
committed
Merge upstream PR 666ghj#374: pluggable graph backends (Zep Cloud + Graphiti local)
2 parents a88aa74 + 78897c1 commit bf5f0b1

83 files changed

Lines changed: 7786 additions & 9529 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
1-
# =============================================================================
2-
# Copy to .env and fill in real values. Never commit .env.
3-
# =============================================================================
4-
#
5-
# LLM — OpenAI-compatible HTTP API (used by backend OpenAI SDK).
6-
#
7-
# --- Option A: Hosted (e.g. Alibaba DashScope) ---
1+
# LLM API configuration (supports any LLM API compatible with the OpenAI SDK format)
2+
# Recommended: use the qwen-plus model on Alibaba Bailian: https://bailian.console.aliyun.com/
3+
# Note: usage can be expensive, so try simulations with fewer than 40 rounds first
84
LLM_API_KEY=your_api_key_here
9-
LLM_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
10-
LLM_MODEL_NAME=qwen-plus
11-
#
12-
# --- Option B: Local Ollama (open-weight models on your machine) ---
13-
# 1) Install: https://ollama.com or brew install ollama
14-
# 2) Run the Ollama app (or `ollama serve`). Check: curl http://127.0.0.1:11434/api/tags
15-
# 3) Pull a model (pick one; larger = better quality, more RAM/GPU):
16-
# ollama pull qwen2.5:7b
17-
# ollama pull llama3.2:3b
18-
# 4) In .env, set (use the same name as `ollama list` shows):
19-
# LLM_API_KEY=ollama
20-
# LLM_BASE_URL=http://127.0.0.1:11434/v1
21-
# LLM_MODEL_NAME=qwen2.5:7b
22-
# Note: MiroFish needs a non-empty LLM_API_KEY; Ollama does not validate it.
23-
# Note: Some flows use JSON mode; very small models may return invalid JSON.
5+
LLM_BASE_URL=https://api.openai.com/v1
6+
LLM_MODEL_NAME=gpt-4o
247

25-
# ===== ZEP 记忆图谱(必填;与 LLM 无关)=====
26-
# 注册后在控制台创建 API Key:https://app.getzep.com/
27-
# 无法用本地 Hugging Face 模型替代;这是独立的云服务。
8+
# ===== Graph backend selection =====
9+
# Use zep_cloud for hosted Zep, or graphiti_local for local Neo4j + Graphiti
10+
GRAPH_BACKEND=zep_cloud
11+
12+
# ===== Zep Cloud configuration =====
13+
# Required only when GRAPH_BACKEND=zep_cloud
2814
ZEP_API_KEY=your_zep_api_key_here
2915

30-
# ===== 加速 LLM(可选;仅部分脚本使用)=====
31-
# 若不用,不要在 .env 中出现这些变量。
32-
# LLM_BOOST_API_KEY=your_api_key_here
33-
# LLM_BOOST_BASE_URL=your_base_url_here
34-
# LLM_BOOST_MODEL_NAME=your_model_name_here
16+
# ===== Local Graphiti + Neo4j configuration =====
17+
# Required only when GRAPH_BACKEND=graphiti_local
18+
# Note: the local Graphiti backend stores all graphs in one Neo4j database
19+
# and isolates each MiroFish graph by Graphiti `group_id`.
20+
NEO4J_URI=bolt://localhost:7687
21+
NEO4J_USER=neo4j
22+
NEO4J_PASSWORD=your_neo4j_password_here
23+
NEO4J_DATABASE=neo4j
24+
GRAPHITI_AUTO_INIT=true
25+
GRAPHITI_TELEMETRY_ENABLED=false
26+
GRAPHITI_MAX_COROUTINES=10
27+
GRAPHITI_SEARCH_RERANKER=rrf
28+
29+
# Optional: override Graphiti model settings
30+
# If omitted, Graphiti falls back to the main LLM settings above
31+
GRAPHITI_LLM_API_KEY=
32+
GRAPHITI_LLM_BASE_URL=
33+
GRAPHITI_LLM_MODEL=
34+
GRAPHITI_EMBEDDER_API_KEY=
35+
GRAPHITI_EMBEDDER_BASE_URL=
36+
GRAPHITI_EMBEDDER_MODEL=text-embedding-3-small
37+
GRAPHITI_RERANKER_API_KEY=
38+
GRAPHITI_RERANKER_BASE_URL=
39+
GRAPHITI_RERANKER_MODEL=
40+
41+
# ===== Accelerated LLM configuration (optional) =====
42+
# If you are not using accelerated configuration, do not include the fields below in your env file
43+
LLM_BOOST_API_KEY=your_api_key_here
44+
LLM_BOOST_BASE_URL=your_base_url_here
45+
LLM_BOOST_MODEL_NAME=your_model_name_here

Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
FROM python:3.11
22

3-
# 安装 Node.js (满足 >=18)及必要工具
3+
# Install Node.js (version 18 or later) and required tools
44
RUN apt-get update \
55
&& apt-get install -y --no-install-recommends nodejs npm \
66
&& rm -rf /var/lib/apt/lists/*
77

8-
# 从 uv 官方镜像复制 uv
8+
# Copy `uv` from the official uv image
99
COPY --from=ghcr.io/astral-sh/uv:0.9.26 /uv /uvx /bin/
1010

1111
WORKDIR /app
1212

13-
# 先复制依赖描述文件以利用缓存
13+
# Copy dependency manifests first to take advantage of layer caching
1414
COPY package.json package-lock.json ./
1515
COPY frontend/package.json frontend/package-lock.json ./frontend/
1616
COPY backend/pyproject.toml backend/uv.lock ./backend/
1717

18-
# 安装依赖(Node + Python
18+
# Install dependencies (Node + Python)
1919
RUN npm ci \
2020
&& npm ci --prefix frontend \
21-
&& cd backend && uv sync --frozen
21+
&& cd backend && uv sync --frozen \
22+
&& uv pip install --python .venv/bin/python --no-deps graphiti-core==0.28.2
2223

23-
# 复制项目源码
24+
# Copy the project source
2425
COPY . .
2526

2627
EXPOSE 3000 5001
2728

28-
# 同时启动前后端(开发模式)
29-
CMD ["npm", "run", "dev"]
29+
# Start both frontend and backend services (development mode)
30+
CMD ["npm", "run", "dev"]

README-EN.md

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<a href="https://trendshift.io/repositories/16144" target="_blank"><img src="https://trendshift.io/api/badge/repositories/16144" alt="666ghj%2FMiroFish | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
66

7-
简洁通用的群体智能引擎,预测万物
7+
A simple, universal swarm intelligence engine for predicting anything
88
</br>
99
<em>A Simple and Universal Swarm Intelligence Engine, Predicting Anything</em>
1010

@@ -20,7 +20,7 @@
2020
[![X](https://img.shields.io/badge/X-Follow-000000?style=flat-square&logo=x&logoColor=white)](https://x.com/mirofish_ai)
2121
[![Instagram](https://img.shields.io/badge/Instagram-Follow-E4405F?style=flat-square&logo=instagram&logoColor=white)](https://www.instagram.com/mirofish_ai/)
2222

23-
[English](./README-EN.md) | [中文文档](./README.md)
23+
[README](./README.md) | [English Copy](./README-EN.md)
2424

2525
</div>
2626

@@ -49,16 +49,16 @@ Welcome to visit our online demo environment and experience a prediction simulat
4949
<div align="center">
5050
<table>
5151
<tr>
52-
<td><img src="./static/image/Screenshot/运行截图1.png" alt="Screenshot 1" width="100%"/></td>
53-
<td><img src="./static/image/Screenshot/运行截图2.png" alt="Screenshot 2" width="100%"/></td>
52+
<td><img src="./static/image/Screenshot/screenshot-1.png" alt="Screenshot 1" width="100%"/></td>
53+
<td><img src="./static/image/Screenshot/screenshot-2.png" alt="Screenshot 2" width="100%"/></td>
5454
</tr>
5555
<tr>
56-
<td><img src="./static/image/Screenshot/运行截图3.png" alt="Screenshot 3" width="100%"/></td>
57-
<td><img src="./static/image/Screenshot/运行截图4.png" alt="Screenshot 4" width="100%"/></td>
56+
<td><img src="./static/image/Screenshot/screenshot-3.png" alt="Screenshot 3" width="100%"/></td>
57+
<td><img src="./static/image/Screenshot/screenshot-4.png" alt="Screenshot 4" width="100%"/></td>
5858
</tr>
5959
<tr>
60-
<td><img src="./static/image/Screenshot/运行截图5.png" alt="Screenshot 5" width="100%"/></td>
61-
<td><img src="./static/image/Screenshot/运行截图6.png" alt="Screenshot 6" width="100%"/></td>
60+
<td><img src="./static/image/Screenshot/screenshot-5.png" alt="Screenshot 5" width="100%"/></td>
61+
<td><img src="./static/image/Screenshot/screenshot-6.png" alt="Screenshot 6" width="100%"/></td>
6262
</tr>
6363
</table>
6464
</div>
@@ -68,15 +68,15 @@ Welcome to visit our online demo environment and experience a prediction simulat
6868
### 1. Wuhan University Public Opinion Simulation + MiroFish Project Introduction
6969

7070
<div align="center">
71-
<a href="https://www.bilibili.com/video/BV1VYBsBHEMY/" target="_blank"><img src="./static/image/武大模拟演示封面.png" alt="MiroFish Demo Video" width="75%"/></a>
71+
<a href="https://www.bilibili.com/video/BV1VYBsBHEMY/" target="_blank"><img src="./static/image/wuhan-demo-cover.png" alt="MiroFish Demo Video" width="75%"/></a>
7272

7373
Click the image to watch the complete demo video for prediction using BettaFish-generated "Wuhan University Public Opinion Report"
7474
</div>
7575

7676
### 2. Dream of the Red Chamber Lost Ending Simulation
7777

7878
<div align="center">
79-
<a href="https://www.bilibili.com/video/BV1cPk3BBExq" target="_blank"><img src="./static/image/红楼梦模拟推演封面.jpg" alt="MiroFish Demo Video" width="75%"/></a>
79+
<a href="https://www.bilibili.com/video/BV1cPk3BBExq" target="_blank"><img src="./static/image/dream-of-red-chamber-cover.jpg" alt="MiroFish Demo Video" width="75%"/></a>
8080

8181
Click the image to watch MiroFish's deep prediction of the lost ending based on hundreds of thousands of words from the first 80 chapters of "Dream of the Red Chamber"
8282
</div>
@@ -122,9 +122,21 @@ LLM_API_KEY=your_api_key
122122
LLM_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
123123
LLM_MODEL_NAME=qwen-plus
124124
125-
# Zep Cloud Configuration
126-
# Free monthly quota is sufficient for simple usage: https://app.getzep.com/
125+
# Graph backend selection
126+
# Use zep_cloud for hosted Zep, or graphiti_local for local Neo4j + Graphiti
127+
GRAPH_BACKEND=zep_cloud
128+
129+
# Zep Cloud configuration
130+
# Required only when GRAPH_BACKEND=zep_cloud
127131
ZEP_API_KEY=your_zep_api_key
132+
133+
# Local Graphiti + Neo4j configuration
134+
# Required only when GRAPH_BACKEND=graphiti_local
135+
# Note: the local Graphiti backend stores all graphs in one Neo4j database
136+
# and isolates each MiroFish graph by Graphiti `group_id`.
137+
NEO4J_URI=bolt://localhost:7687
138+
NEO4J_USER=neo4j
139+
NEO4J_PASSWORD=your_neo4j_password
128140
```
129141

130142
#### 2. Install Dependencies
@@ -151,6 +163,17 @@ npm run setup:backend
151163
npm run dev
152164
```
153165

166+
If you use `GRAPH_BACKEND=graphiti_local`, start Neo4j too:
167+
168+
```bash
169+
docker compose up -d neo4j
170+
```
171+
172+
The bundled `docker-compose.yml` uses `neo4j:5.26.22-enterprise` with
173+
`NEO4J_ACCEPT_LICENSE_AGREEMENT=yes` as the safe local default.
174+
The current local backend still keeps all graphs in the default Neo4j database
175+
and maps each MiroFish `graph_id` directly to a Graphiti `group_id`.
176+
154177
**Service URLs:**
155178
- Frontend: `http://localhost:3000`
156179
- Backend API: `http://localhost:5001`
@@ -175,11 +198,12 @@ docker compose up -d
175198
Reads `.env` from root directory by default, maps ports `3000 (frontend) / 5001 (backend)`
176199

177200
> Mirror address for faster pulling is provided as comments in `docker-compose.yml`, replace if needed.
201+
> When `GRAPH_BACKEND=graphiti_local`, the bundled compose stack starts a local Neo4j instance for Graphiti storage. The repo keeps the enterprise image as the default compose target because existing local stores may use the block format.
178202
179203
## 📬 Join the Conversation
180204

181205
<div align="center">
182-
<img src="./static/image/QQ群.png" alt="QQ Group" width="60%"/>
206+
<img src="./static/image/qq-group.png" alt="QQ Group" width="60%"/>
183207
</div>
184208

185209
&nbsp;
@@ -200,4 +224,4 @@ MiroFish's simulation engine is powered by **[OASIS (Open Agent Social Interacti
200224
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=666ghj/MiroFish&type=date&legend=top-left" />
201225
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=666ghj/MiroFish&type=date&legend=top-left" />
202226
</picture>
203-
</a>
227+
</a>

0 commit comments

Comments
 (0)