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

# 安装

> 面向当前运行时安装并配置本地 Memorose 实例。

# 安装

Memorose 由 Rust API 服务和独立的仪表盘 UI 组成。

## 前置条件

* Rust 工具链
* Node.js 和 `pnpm`，用于仪表盘
* 用于 embedding 和 consolidation 的 LLM 提供商密钥
* 可选：`jq`，用于命令行示例

## 克隆仓库

```bash theme={null}
git clone https://github.com/ai-akashic/Memorose.git
cd Memorose
```

## 环境配置

复制示例环境文件：

```bash theme={null}
cp .env.example .env
```

至少需要设置提供商密钥和模型名：

```bash theme={null}
GOOGLE_API_KEY=your_google_api_key_here
LLM_MODEL=gemini-2.0-flash
EMBEDDING_MODEL=text-embedding-004
```

如果你想通过环境变量明确指定 provider，优先使用：

```bash theme={null}
MEMOROSE__LLM__PROVIDER=Gemini
```

或者：

```bash theme={null}
MEMOROSE__LLM__PROVIDER=OpenAI
OPENAI_API_KEY=your_openai_api_key_here
```

如果你不想看到默认仪表盘密码告警，还可以设置：

```bash theme={null}
DASHBOARD_ADMIN_PASSWORD=change-me
```

## 配置

请根据 `crates/memorose-common/src/config.rs` 中的当前 schema 自行创建 `config.toml`，也可以从 `config.example.toml` / `config.toml.example` 起步，并始终以 `config.rs` 作为最终权威来源。

一个最小起步配置如下：

```toml theme={null}
[llm]
provider = "Gemini"
model = "gemini-2.0-flash"
embedding_model = "text-embedding-004"

[storage]
root_dir = "./data/node-1"

[raft]
node_id = 1
raft_addr = "127.0.0.1:5001"
heartbeat_interval_ms = 500
election_timeout_min_ms = 1500
election_timeout_max_ms = 3000
snapshot_logs = 1000000
auto_initialize = true

[worker]
llm_concurrency = 5
decay_interval_secs = 60
prune_threshold = 0.1
consolidation_interval_ms = 1000
community_interval_ms = 1000
insight_interval_ms = 30000
enable_auto_planner = true
enable_task_reflection = true
auto_link_similarity_threshold = 0.6
tick_interval_ms = 100

[reranker]
type = "weighted"
```

如果要开启内部基于模型的 arbitration，可增加 reranker 配置段：

```toml theme={null}
[reranker]
type = "arbitrator"
model = "gemini-3.1-flash-lite-preview"
max_candidates = 32
fallback_to_weighted = true
```

## 启动服务栈

推荐的本地启动方式：

```bash theme={null}
./scripts/start_cluster.sh start --clean --build
```

这会在本地 cluster 模式下启动 `3000`、`3001`、`3002` 三个后端节点，并在 `3100` 启动仪表盘 UI。

如果你只想跑一个本地节点：

```bash theme={null}
./scripts/start_cluster.sh start --mode standalone
```

## 手动启动服务端

如果你只需要 API 服务：

```bash theme={null}
cargo run --release -p memorose-server
```

## Docker reranker 配置

Docker 镜像会在 `3000` 启动 API 服务，在 `3100` 启动仪表盘。Reranker 模式仍通过同一套 `MEMOROSE__*` 环境变量配置：

```bash theme={null}
docker run -d \
  --name memorose \
  -p 3000:3000 \
  -p 3100:3100 \
  -v memorose_data:/app/data \
  -e GOOGLE_API_KEY="your_google_api_key_here" \
  -e MEMOROSE__LLM__MODEL="gemini-3.1-flash-lite-preview" \
  -e MEMOROSE__LLM__EMBEDDING_MODEL="gemini-embedding-2-preview" \
  -e MEMOROSE__RERANKER__TYPE="arbitrator" \
  -e MEMOROSE__RERANKER__MODEL="gemini-3.1-flash-lite-preview" \
  -e MEMOROSE__RERANKER__MAX_CANDIDATES="32" \
  -e MEMOROSE__RERANKER__FALLBACK_TO_WEIGHTED="true" \
  dylan2024/memorose:latest
```

## 验证安装

检查根端点：

```bash theme={null}
curl http://127.0.0.1:3000/
```

预期响应：

```text theme={null}
Memorose is running.
```

## 仪表盘

* 仪表盘 UI：`http://127.0.0.1:3100/dashboard`
* API 重定向：`http://127.0.0.1:3000/dashboard`
* 默认登录：`admin` / `admin`

首次登录后，响应里可能包含 `must_change_password: true`，直到你设置新密码。

<Warning>
  如果你使用自己的 `docker-compose.yml` 或 `docker run` 部署仪表盘，必须在仪表盘容器上设置 `DASHBOARD_API_ORIGIN` 指向后端 API，例如 `DASHBOARD_API_ORIGIN=http://memorose-node-0:3000`。否则登录和仪表盘代理请求会因 `connect ECONNREFUSED 127.0.0.1:3000` 失败。
</Warning>
