Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions code/chapter8/docker/docker-compse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3.8'

services:
# Qdrant 向量数据库
qdrant:
image: qdrant/qdrant:latest
container_name: qdrant
ports:
- "6333:6333" # REST API
- "6334:6334" # gRPC API
volumes:
- qdrant_storage:/qdrant/storage
environment:
- QDRANT__SERVICE__GRPC_PORT=6334
restart: unless-stopped
networks:
- hello_agents_network

# Neo4j 图数据库
neo4j:
image: neo4j:latest
container_name: neo4j
ports:
- "7474:7474" # HTTP
- "7687:7687" # Bolt
volumes:
- neo4j_data:/data
- neo4j_logs:/logs
- neo4j_import:/var/lib/neo4j/import
- neo4j_plugins:/plugins
environment:
- NEO4J_AUTH=neo4j/hello-agents-password
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
- NEO4J_dbms_memory_pagecache_size=512M
- NEO4J_dbms_memory_heap_initial__size=512M
- NEO4J_dbms_memory_heap_max__size=1G
restart: unless-stopped
networks:
- hello_agents_network

volumes:
qdrant_storage:
driver: local
neo4j_data:
driver: local
neo4j_logs:
driver: local
neo4j_import:
driver: local
neo4j_plugins:
driver: local

networks:
hello_agents_network:
driver: bridge
22 changes: 22 additions & 0 deletions docs/chapter8/Chapter8-Memory-and-Retrieval.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,28 @@ EMBED_API_KEY=
EMBED_BASE_URL=
```

The local deployment approach is as follows:

```bash
# First, check if Docker is installed
>> docker -v
Docker version 27.0.3, build 7d4bcd8

# Start qdrant and neo4j services simultaneously using docker-compose
>> cd project_to_path/code/chapter8
>> docker-compose -f docker/docker-compse.yml

# Configure .env for your local deployment of qdrant and neo4j
# Comment out cloud configuration and use local Qdrant (requires Docker)
QDRANT_URL=http://localhost:6333
QDRANT_API_KEY=

# Comment out cloud configuration and use local Neo4j (requires Docker)
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=hello-agents-password
```

Learning in this chapter can be done in two ways:

1. **Experiential Learning**: Directly install the framework using `pip`, run example code, and quickly experience various functions
Expand Down
32 changes: 29 additions & 3 deletions docs/chapter8/第八章 记忆与检索.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,40 @@ NEO4J_MAX_CONNECTION_LIFETIME=3600
NEO4J_MAX_CONNECTION_POOL_SIZE=50
NEO4J_CONNECTION_TIMEOUT=60

# ==========================
# ==========================
# 嵌入(Embedding)配置示例 - 可从阿里云控制台获取:https://dashscope.aliyun.com/
# ==========================
# - 若为空,dashscope 默认 text-embedding-v3;local 默认 sentence-transformers/all-MiniLM-L6-v2
EMBED_MODEL_TYPE=dashscope
EMBED_MODEL_NAME=
EMBED_API_KEY=
EMBED_BASE_URL=
EMBED_MODEL_NAME=text-embedding-v4
# - 方案 1:如提供 base_url,则优先使用 OpenAI 兼容的 REST 接口(POST {base_url}/embeddings)。
EMBED_API_KEY=sk-xxx
EMBED_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
# - 方案 2:否则使用官方 dashscope SDK 的 TextEmbedding.call。EMBED_BASE_URL为空,配置DASHSCOPE_API_KEY
# DASHSCOPE_API_KEY=sk-xx
# EMBED_BASE_URL=
```

本地部署方案如下:
```bash
#先检查 docker 是否已安装。
>> docker -v
Docker version 27.0.3, build 7d4bcd8

# 用docker-compose同时启动 qdrant 和 neo4j服务。
>> cd project_to_path/code/chapter8
>> docker-compose -f docker/docker-compse.yml

# 在.env中配置本地部署的 qdrant 和 neo4j
# 注释掉云端配置,使用本地Qdrant (需要Docker)
QDRANT_URL=http://localhost:6333
QDRANT_API_KEY=

#注释掉云端配置,使用本地Neo4j (需要Docker)
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=hello-agents-password
```

本章的学习可以采用两种方式:
Expand Down