feat: add sim & pingap
This commit is contained in:
67
apps/langflow/.env.example
Normal file
67
apps/langflow/.env.example
Normal file
@@ -0,0 +1,67 @@
|
||||
# Langflow Configuration
|
||||
|
||||
# Versions
|
||||
LANGFLOW_VERSION=1.1.1
|
||||
POSTGRES_VERSION=16-alpine
|
||||
|
||||
# Port Configuration
|
||||
LANGFLOW_PORT_OVERRIDE=7860
|
||||
|
||||
# PostgreSQL Configuration
|
||||
POSTGRES_DB=langflow
|
||||
POSTGRES_USER=langflow
|
||||
POSTGRES_PASSWORD=langflow
|
||||
|
||||
# Storage Configuration
|
||||
LANGFLOW_CONFIG_DIR=/app/langflow
|
||||
|
||||
# Server Configuration
|
||||
LANGFLOW_HOST=0.0.0.0
|
||||
LANGFLOW_WORKERS=1
|
||||
|
||||
# Authentication - IMPORTANT: Configure for production!
|
||||
# Set LANGFLOW_AUTO_LOGIN=false to require login
|
||||
LANGFLOW_AUTO_LOGIN=true
|
||||
LANGFLOW_SUPERUSER=langflow
|
||||
LANGFLOW_SUPERUSER_PASSWORD=langflow
|
||||
|
||||
# Security - IMPORTANT: Generate a secure secret key for production!
|
||||
# Use: python -c "from secrets import token_urlsafe; print(token_urlsafe(32))"
|
||||
LANGFLOW_SECRET_KEY=
|
||||
|
||||
# Features
|
||||
LANGFLOW_AUTO_SAVING=true
|
||||
LANGFLOW_AUTO_SAVING_INTERVAL=1000
|
||||
LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true
|
||||
LANGFLOW_FALLBACK_TO_ENV_VAR=true
|
||||
|
||||
# Optional: Custom components directory
|
||||
LANGFLOW_COMPONENTS_PATH=
|
||||
|
||||
# Optional: Load flows from directory on startup
|
||||
LANGFLOW_LOAD_FLOWS_PATH=
|
||||
|
||||
# Logging
|
||||
LANGFLOW_LOG_LEVEL=error
|
||||
|
||||
# Timezone
|
||||
TZ=UTC
|
||||
|
||||
# Analytics
|
||||
DO_NOT_TRACK=false
|
||||
|
||||
# Resource Limits - Langflow
|
||||
LANGFLOW_CPU_LIMIT=2.0
|
||||
LANGFLOW_MEMORY_LIMIT=2G
|
||||
LANGFLOW_CPU_RESERVATION=0.5
|
||||
LANGFLOW_MEMORY_RESERVATION=512M
|
||||
|
||||
# Resource Limits - PostgreSQL
|
||||
POSTGRES_CPU_LIMIT=1.0
|
||||
POSTGRES_MEMORY_LIMIT=1G
|
||||
POSTGRES_CPU_RESERVATION=0.25
|
||||
POSTGRES_MEMORY_RESERVATION=256M
|
||||
|
||||
# Logging Configuration
|
||||
LOG_MAX_SIZE=100m
|
||||
LOG_MAX_FILE=3
|
||||
336
apps/langflow/README.md
Normal file
336
apps/langflow/README.md
Normal file
@@ -0,0 +1,336 @@
|
||||
# Langflow
|
||||
|
||||
Langflow is a low-code visual framework for building AI applications. It's Python-based and agnostic to any model, API, or database, making it easy to build RAG applications, multi-agent systems, and custom AI workflows.
|
||||
|
||||
## Features
|
||||
|
||||
- **Visual Flow Builder**: Drag-and-drop interface for building AI applications
|
||||
- **Multi-Model Support**: Works with OpenAI, Anthropic, Google, HuggingFace, and more
|
||||
- **RAG Components**: Built-in support for vector databases and retrieval
|
||||
- **Custom Components**: Create your own Python components
|
||||
- **Agent Support**: Build multi-agent systems with memory and tools
|
||||
- **Real-Time Monitoring**: Track executions and debug flows
|
||||
- **API Integration**: REST API for programmatic access
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Copy `.env.example` to `.env`:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
2. (Optional) Edit `.env` to customize settings:
|
||||
- Generate a secure `LANGFLOW_SECRET_KEY` for production
|
||||
- Set `LANGFLOW_AUTO_LOGIN=false` to require authentication
|
||||
- Configure superuser credentials
|
||||
- Add API keys for LLM providers
|
||||
|
||||
3. Start Langflow:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
4. Wait for services to be ready (usually takes 1-2 minutes)
|
||||
|
||||
5. Access Langflow UI at `http://localhost:7860`
|
||||
|
||||
6. Start building your AI application!
|
||||
|
||||
## Default Configuration
|
||||
|
||||
| Service | Port | Description |
|
||||
| ---------- | ---- | ------------------- |
|
||||
| Langflow | 7860 | Web UI and API |
|
||||
| PostgreSQL | 5432 | Database (internal) |
|
||||
|
||||
**Default Credentials** (if authentication enabled):
|
||||
|
||||
- Username: `langflow`
|
||||
- Password: `langflow`
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Key environment variables (see `.env.example` for full list):
|
||||
|
||||
| Variable | Description | Default |
|
||||
| ----------------------------- | ----------------------------- | ---------- |
|
||||
| `LANGFLOW_VERSION` | Langflow image version | `1.1.1` |
|
||||
| `LANGFLOW_PORT_OVERRIDE` | Host port for UI | `7860` |
|
||||
| `POSTGRES_PASSWORD` | Database password | `langflow` |
|
||||
| `LANGFLOW_AUTO_LOGIN` | Auto-login (disable for auth) | `true` |
|
||||
| `LANGFLOW_SUPERUSER` | Superuser username | `langflow` |
|
||||
| `LANGFLOW_SUPERUSER_PASSWORD` | Superuser password | `langflow` |
|
||||
| `LANGFLOW_SECRET_KEY` | Secret key for sessions | (empty) |
|
||||
| `LANGFLOW_COMPONENTS_PATH` | Custom components directory | (empty) |
|
||||
| `LANGFLOW_LOAD_FLOWS_PATH` | Auto-load flows directory | (empty) |
|
||||
| `TZ` | Timezone | `UTC` |
|
||||
|
||||
## Resource Requirements
|
||||
|
||||
**Minimum**:
|
||||
|
||||
- CPU: 1 core
|
||||
- RAM: 1GB
|
||||
- Disk: 5GB
|
||||
|
||||
**Recommended**:
|
||||
|
||||
- CPU: 2+ cores
|
||||
- RAM: 2GB+
|
||||
- Disk: 20GB+
|
||||
|
||||
## Volumes
|
||||
|
||||
- `postgres_data`: PostgreSQL database data
|
||||
- `langflow_data`: Langflow configuration, flows, and logs
|
||||
|
||||
## Using Langflow
|
||||
|
||||
### Building Your First Flow
|
||||
|
||||
1. Access the UI at `http://localhost:7860`
|
||||
2. Click "New Flow" or use a template
|
||||
3. Drag components from the sidebar to the canvas
|
||||
4. Connect components by dragging between ports
|
||||
5. Configure component parameters
|
||||
6. Click "Run" to test your flow
|
||||
7. Use the API or integrate with your application
|
||||
|
||||
### Adding LLM Providers
|
||||
|
||||
To use external LLM providers, configure their API keys:
|
||||
|
||||
1. In Langflow UI, go to Settings > Global Variables
|
||||
2. Add your API keys (e.g., `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`)
|
||||
3. Reference these variables in your flow components
|
||||
|
||||
Alternatively, add them to your `.env` file and restart:
|
||||
|
||||
```bash
|
||||
# Example LLM API Keys (add to .env)
|
||||
OPENAI_API_KEY=sk-...
|
||||
ANTHROPIC_API_KEY=sk-ant-...
|
||||
GOOGLE_API_KEY=...
|
||||
```
|
||||
|
||||
### Custom Components
|
||||
|
||||
To add custom components:
|
||||
|
||||
1. Create a directory for your components (e.g., `./custom_components`)
|
||||
2. Update `.env`:
|
||||
|
||||
```bash
|
||||
LANGFLOW_COMPONENTS_PATH=/app/langflow/custom_components
|
||||
```
|
||||
|
||||
3. Mount the directory in `docker-compose.yaml`:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./custom_components:/app/langflow/custom_components
|
||||
```
|
||||
|
||||
4. Restart Langflow
|
||||
|
||||
### Auto-Loading Flows
|
||||
|
||||
To automatically load flows on startup:
|
||||
|
||||
1. Export your flows as JSON files
|
||||
2. Create a directory (e.g., `./flows`)
|
||||
3. Update `.env`:
|
||||
|
||||
```bash
|
||||
LANGFLOW_LOAD_FLOWS_PATH=/app/langflow/flows
|
||||
```
|
||||
|
||||
4. Mount the directory in `docker-compose.yaml`:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./flows:/app/langflow/flows
|
||||
```
|
||||
|
||||
5. Restart Langflow
|
||||
|
||||
## API Usage
|
||||
|
||||
Langflow provides a REST API for running flows programmatically.
|
||||
|
||||
### Get Flow ID
|
||||
|
||||
1. Open your flow in the UI
|
||||
2. The flow ID is in the URL: `http://localhost:7860/flow/{flow_id}`
|
||||
|
||||
### Run Flow via API
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:7860/api/v1/run/{flow_id} \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"inputs": {
|
||||
"input_field": "your input value"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### With Authentication
|
||||
|
||||
If authentication is enabled, first get a token:
|
||||
|
||||
```bash
|
||||
# Login
|
||||
curl -X POST http://localhost:7860/api/v1/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"username": "langflow",
|
||||
"password": "langflow"
|
||||
}'
|
||||
|
||||
# Use token in subsequent requests
|
||||
curl -X POST http://localhost:7860/api/v1/run/{flow_id} \
|
||||
-H "Authorization: Bearer {token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"inputs": {
|
||||
"input_field": "your input value"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
## Production Deployment
|
||||
|
||||
For production deployments:
|
||||
|
||||
1. **Enable Authentication**:
|
||||
|
||||
```bash
|
||||
LANGFLOW_AUTO_LOGIN=false
|
||||
LANGFLOW_SUPERUSER=admin
|
||||
LANGFLOW_SUPERUSER_PASSWORD=<strong-password>
|
||||
```
|
||||
|
||||
2. **Set Secret Key**:
|
||||
|
||||
```bash
|
||||
# Generate a secure key
|
||||
python -c "from secrets import token_urlsafe; print(token_urlsafe(32))"
|
||||
|
||||
# Add to .env
|
||||
LANGFLOW_SECRET_KEY=<generated-key>
|
||||
```
|
||||
|
||||
3. **Use Strong Database Password**:
|
||||
|
||||
```bash
|
||||
POSTGRES_PASSWORD=<strong-password>
|
||||
```
|
||||
|
||||
4. **Enable SSL/TLS**: Use a reverse proxy (nginx, traefik) with SSL certificates
|
||||
|
||||
5. **Configure Resource Limits**: Adjust CPU and memory limits based on your workload
|
||||
|
||||
6. **Backup Database**: Regularly backup the PostgreSQL data volume
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Langflow Won't Start
|
||||
|
||||
- Check logs: `docker compose logs langflow`
|
||||
- Ensure PostgreSQL is healthy: `docker compose ps postgres`
|
||||
- Verify port 7860 is not in use
|
||||
|
||||
### Components Not Loading
|
||||
|
||||
- Check custom components path is correct
|
||||
- Ensure Python dependencies are installed in custom components
|
||||
- Check logs for component errors
|
||||
|
||||
### Slow Performance
|
||||
|
||||
- Increase resource limits in `.env`
|
||||
- Reduce `LANGFLOW_WORKERS` if low on memory
|
||||
- Optimize your flows (reduce unnecessary components)
|
||||
|
||||
### Database Connection Errors
|
||||
|
||||
- Verify PostgreSQL is running: `docker compose ps postgres`
|
||||
- Check database credentials in `.env`
|
||||
- Ensure `LANGFLOW_DATABASE_URL` is correct
|
||||
|
||||
## Maintenance
|
||||
|
||||
### Backup
|
||||
|
||||
Backup volumes:
|
||||
|
||||
```bash
|
||||
docker compose down
|
||||
docker run --rm -v compose-anything_postgres_data:/data -v $(pwd):/backup alpine tar czf /backup/postgres-backup.tar.gz -C /data .
|
||||
docker run --rm -v compose-anything_langflow_data:/data -v $(pwd):/backup alpine tar czf /backup/langflow-backup.tar.gz -C /data .
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### Restore
|
||||
|
||||
Restore from backup:
|
||||
|
||||
```bash
|
||||
docker compose down
|
||||
docker run --rm -v compose-anything_postgres_data:/data -v $(pwd):/backup alpine sh -c "cd /data && tar xzf /backup/postgres-backup.tar.gz"
|
||||
docker run --rm -v compose-anything_langflow_data:/data -v $(pwd):/backup alpine sh -c "cd /data && tar xzf /backup/langflow-backup.tar.gz"
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### Upgrade
|
||||
|
||||
To upgrade Langflow:
|
||||
|
||||
1. Update version in `.env`:
|
||||
|
||||
```bash
|
||||
LANGFLOW_VERSION=1.2.0
|
||||
```
|
||||
|
||||
2. Pull new image and restart:
|
||||
|
||||
```bash
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
3. Check for breaking changes in release notes
|
||||
|
||||
## Useful Commands
|
||||
|
||||
```bash
|
||||
# View logs
|
||||
docker compose logs -f langflow
|
||||
|
||||
# Restart Langflow
|
||||
docker compose restart langflow
|
||||
|
||||
# Access PostgreSQL
|
||||
docker compose exec postgres psql -U langflow -d langflow
|
||||
|
||||
# Check resource usage
|
||||
docker stats
|
||||
|
||||
# Clean up
|
||||
docker compose down -v # WARNING: Deletes all data
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [Official Documentation](https://docs.langflow.org/)
|
||||
- [GitHub Repository](https://github.com/langflow-ai/langflow)
|
||||
- [Component Documentation](https://docs.langflow.org/components/)
|
||||
- [API Documentation](https://docs.langflow.org/api/)
|
||||
- [Community Discord](https://discord.gg/langflow)
|
||||
|
||||
## License
|
||||
|
||||
MIT - See [LICENSE](https://github.com/langflow-ai/langflow/blob/main/LICENSE)
|
||||
336
apps/langflow/README.zh.md
Normal file
336
apps/langflow/README.zh.md
Normal file
@@ -0,0 +1,336 @@
|
||||
# Langflow
|
||||
|
||||
Langflow 是一个低代码可视化框架,用于构建 AI 应用。它基于 Python,与任何模型、API 或数据库无关,可轻松构建 RAG 应用、多智能体系统和自定义 AI 工作流。
|
||||
|
||||
## 功能特点
|
||||
|
||||
- **可视化流构建器**:拖放界面构建 AI 应用
|
||||
- **多模型支持**:支持 OpenAI、Anthropic、Google、HuggingFace 等
|
||||
- **RAG 组件**:内置向量数据库和检索支持
|
||||
- **自定义组件**:创建您自己的 Python 组件
|
||||
- **智能体支持**:构建具有记忆和工具的多智能体系统
|
||||
- **实时监控**:跟踪执行并调试流程
|
||||
- **API 集成**:用于编程访问的 REST API
|
||||
|
||||
## 快速开始
|
||||
|
||||
1. 复制 `.env.example` 到 `.env`:
|
||||
|
||||
```bash
|
||||
copy .env.example .env
|
||||
```
|
||||
|
||||
2. (可选)编辑 `.env` 自定义设置:
|
||||
- 为生产环境生成安全的 `LANGFLOW_SECRET_KEY`
|
||||
- 设置 `LANGFLOW_AUTO_LOGIN=false` 以要求身份验证
|
||||
- 配置超级用户凭证
|
||||
- 为 LLM 提供商添加 API 密钥
|
||||
|
||||
3. 启动 Langflow:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
4. 等待服务就绪(通常需要 1-2 分钟)
|
||||
|
||||
5. 访问 Langflow UI:`http://localhost:7860`
|
||||
|
||||
6. 开始构建您的 AI 应用!
|
||||
|
||||
## 默认配置
|
||||
|
||||
| 服务 | 端口 | 说明 |
|
||||
| ---------- | ---- | -------------- |
|
||||
| Langflow | 7860 | Web UI 和 API |
|
||||
| PostgreSQL | 5432 | 数据库(内部) |
|
||||
|
||||
**默认凭证**(如果启用了身份验证):
|
||||
|
||||
- 用户名:`langflow`
|
||||
- 密码:`langflow`
|
||||
|
||||
## 环境变量
|
||||
|
||||
主要环境变量(完整列表请参阅 `.env.example`):
|
||||
|
||||
| 变量 | 说明 | 默认值 |
|
||||
| ----------------------------- | ------------------------------ | ---------- |
|
||||
| `LANGFLOW_VERSION` | Langflow 镜像版本 | `1.1.1` |
|
||||
| `LANGFLOW_PORT_OVERRIDE` | UI 的主机端口 | `7860` |
|
||||
| `POSTGRES_PASSWORD` | 数据库密码 | `langflow` |
|
||||
| `LANGFLOW_AUTO_LOGIN` | 自动登录(禁用以启用身份验证) | `true` |
|
||||
| `LANGFLOW_SUPERUSER` | 超级用户用户名 | `langflow` |
|
||||
| `LANGFLOW_SUPERUSER_PASSWORD` | 超级用户密码 | `langflow` |
|
||||
| `LANGFLOW_SECRET_KEY` | 会话密钥 | (空) |
|
||||
| `LANGFLOW_COMPONENTS_PATH` | 自定义组件目录 | (空) |
|
||||
| `LANGFLOW_LOAD_FLOWS_PATH` | 自动加载流目录 | (空) |
|
||||
| `TZ` | 时区 | `UTC` |
|
||||
|
||||
## 资源需求
|
||||
|
||||
**最低要求**:
|
||||
|
||||
- CPU:1 核心
|
||||
- 内存:1GB
|
||||
- 磁盘:5GB
|
||||
|
||||
**推荐配置**:
|
||||
|
||||
- CPU:2+ 核心
|
||||
- 内存:2GB+
|
||||
- 磁盘:20GB+
|
||||
|
||||
## 数据卷
|
||||
|
||||
- `postgres_data`:PostgreSQL 数据库数据
|
||||
- `langflow_data`:Langflow 配置、流和日志
|
||||
|
||||
## 使用 Langflow
|
||||
|
||||
### 构建您的第一个流
|
||||
|
||||
1. 访问 UI:`http://localhost:7860`
|
||||
2. 点击 "New Flow" 或使用模板
|
||||
3. 从侧边栏拖动组件到画布
|
||||
4. 通过在端口之间拖动来连接组件
|
||||
5. 配置组件参数
|
||||
6. 点击 "Run" 测试您的流
|
||||
7. 使用 API 或与您的应用集成
|
||||
|
||||
### 添加 LLM 提供商
|
||||
|
||||
要使用外部 LLM 提供商,请配置其 API 密钥:
|
||||
|
||||
1. 在 Langflow UI 中,转到 Settings > Global Variables
|
||||
2. 添加您的 API 密钥(例如,`OPENAI_API_KEY`、`ANTHROPIC_API_KEY`)
|
||||
3. 在您的流组件中引用这些变量
|
||||
|
||||
或者,将它们添加到您的 `.env` 文件并重启:
|
||||
|
||||
```bash
|
||||
# LLM API 密钥示例(添加到 .env)
|
||||
OPENAI_API_KEY=sk-...
|
||||
ANTHROPIC_API_KEY=sk-ant-...
|
||||
GOOGLE_API_KEY=...
|
||||
```
|
||||
|
||||
### 自定义组件
|
||||
|
||||
要添加自定义组件:
|
||||
|
||||
1. 为您的组件创建一个目录(例如,`./custom_components`)
|
||||
2. 更新 `.env`:
|
||||
|
||||
```bash
|
||||
LANGFLOW_COMPONENTS_PATH=/app/langflow/custom_components
|
||||
```
|
||||
|
||||
3. 在 `docker-compose.yaml` 中挂载目录:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./custom_components:/app/langflow/custom_components
|
||||
```
|
||||
|
||||
4. 重启 Langflow
|
||||
|
||||
### 自动加载流
|
||||
|
||||
要在启动时自动加载流:
|
||||
|
||||
1. 将您的流导出为 JSON 文件
|
||||
2. 创建一个目录(例如,`./flows`)
|
||||
3. 更新 `.env`:
|
||||
|
||||
```bash
|
||||
LANGFLOW_LOAD_FLOWS_PATH=/app/langflow/flows
|
||||
```
|
||||
|
||||
4. 在 `docker-compose.yaml` 中挂载目录:
|
||||
|
||||
```yaml
|
||||
volumes:
|
||||
- ./flows:/app/langflow/flows
|
||||
```
|
||||
|
||||
5. 重启 Langflow
|
||||
|
||||
## API 使用
|
||||
|
||||
Langflow 提供 REST API 用于以编程方式运行流。
|
||||
|
||||
### 获取流 ID
|
||||
|
||||
1. 在 UI 中打开您的流
|
||||
2. 流 ID 在 URL 中:`http://localhost:7860/flow/{flow_id}`
|
||||
|
||||
### 通过 API 运行流
|
||||
|
||||
```bash
|
||||
curl -X POST http://localhost:7860/api/v1/run/{flow_id} \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"inputs": {
|
||||
"input_field": "your input value"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### 使用身份验证
|
||||
|
||||
如果启用了身份验证,首先获取令牌:
|
||||
|
||||
```bash
|
||||
# 登录
|
||||
curl -X POST http://localhost:7860/api/v1/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"username": "langflow",
|
||||
"password": "langflow"
|
||||
}'
|
||||
|
||||
# 在后续请求中使用令牌
|
||||
curl -X POST http://localhost:7860/api/v1/run/{flow_id} \
|
||||
-H "Authorization: Bearer {token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"inputs": {
|
||||
"input_field": "your input value"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
## 生产部署
|
||||
|
||||
对于生产部署:
|
||||
|
||||
1. **启用身份验证**:
|
||||
|
||||
```bash
|
||||
LANGFLOW_AUTO_LOGIN=false
|
||||
LANGFLOW_SUPERUSER=admin
|
||||
LANGFLOW_SUPERUSER_PASSWORD=<强密码>
|
||||
```
|
||||
|
||||
2. **设置密钥**:
|
||||
|
||||
```bash
|
||||
# 生成安全密钥
|
||||
python -c "from secrets import token_urlsafe; print(token_urlsafe(32))"
|
||||
|
||||
# 添加到 .env
|
||||
LANGFLOW_SECRET_KEY=<生成的密钥>
|
||||
```
|
||||
|
||||
3. **使用强数据库密码**:
|
||||
|
||||
```bash
|
||||
POSTGRES_PASSWORD=<强密码>
|
||||
```
|
||||
|
||||
4. **启用 SSL/TLS**:使用带有 SSL 证书的反向代理(nginx、traefik)
|
||||
|
||||
5. **配置资源限制**:根据您的工作负载调整 CPU 和内存限制
|
||||
|
||||
6. **备份数据库**:定期备份 PostgreSQL 数据卷
|
||||
|
||||
## 故障排除
|
||||
|
||||
### Langflow 无法启动
|
||||
|
||||
- 查看日志:`docker compose logs langflow`
|
||||
- 确保 PostgreSQL 健康:`docker compose ps postgres`
|
||||
- 验证端口 7860 未被使用
|
||||
|
||||
### 组件未加载
|
||||
|
||||
- 检查自定义组件路径是否正确
|
||||
- 确保在自定义组件中安装了 Python 依赖项
|
||||
- 检查日志中的组件错误
|
||||
|
||||
### 性能缓慢
|
||||
|
||||
- 在 `.env` 中增加资源限制
|
||||
- 如果内存不足,减少 `LANGFLOW_WORKERS`
|
||||
- 优化您的流(减少不必要的组件)
|
||||
|
||||
### 数据库连接错误
|
||||
|
||||
- 验证 PostgreSQL 正在运行:`docker compose ps postgres`
|
||||
- 检查 `.env` 中的数据库凭证
|
||||
- 确保 `LANGFLOW_DATABASE_URL` 正确
|
||||
|
||||
## 维护
|
||||
|
||||
### 备份
|
||||
|
||||
备份数据卷:
|
||||
|
||||
```bash
|
||||
docker compose down
|
||||
docker run --rm -v compose-anything_postgres_data:/data -v $(pwd):/backup alpine tar czf /backup/postgres-backup.tar.gz -C /data .
|
||||
docker run --rm -v compose-anything_langflow_data:/data -v $(pwd):/backup alpine tar czf /backup/langflow-backup.tar.gz -C /data .
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### 恢复
|
||||
|
||||
从备份恢复:
|
||||
|
||||
```bash
|
||||
docker compose down
|
||||
docker run --rm -v compose-anything_postgres_data:/data -v $(pwd):/backup alpine sh -c "cd /data && tar xzf /backup/postgres-backup.tar.gz"
|
||||
docker run --rm -v compose-anything_langflow_data:/data -v $(pwd):/backup alpine sh -c "cd /data && tar xzf /backup/langflow-backup.tar.gz"
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
### 升级
|
||||
|
||||
升级 Langflow:
|
||||
|
||||
1. 在 `.env` 中更新版本:
|
||||
|
||||
```bash
|
||||
LANGFLOW_VERSION=1.2.0
|
||||
```
|
||||
|
||||
2. 拉取新镜像并重启:
|
||||
|
||||
```bash
|
||||
docker compose pull
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
3. 检查发布说明中的重大更改
|
||||
|
||||
## 常用命令
|
||||
|
||||
```bash
|
||||
# 查看日志
|
||||
docker compose logs -f langflow
|
||||
|
||||
# 重启 Langflow
|
||||
docker compose restart langflow
|
||||
|
||||
# 访问 PostgreSQL
|
||||
docker compose exec postgres psql -U langflow -d langflow
|
||||
|
||||
# 检查资源使用
|
||||
docker stats
|
||||
|
||||
# 清理
|
||||
docker compose down -v # 警告:删除所有数据
|
||||
```
|
||||
|
||||
## 参考资料
|
||||
|
||||
- [官方文档](https://docs.langflow.org/)
|
||||
- [GitHub 仓库](https://github.com/langflow-ai/langflow)
|
||||
- [组件文档](https://docs.langflow.org/components/)
|
||||
- [API 文档](https://docs.langflow.org/api/)
|
||||
- [社区 Discord](https://discord.gg/langflow)
|
||||
|
||||
## 许可证
|
||||
|
||||
MIT - 查看 [LICENSE](https://github.com/langflow-ai/langflow/blob/main/LICENSE)
|
||||
127
apps/langflow/docker-compose.yaml
Normal file
127
apps/langflow/docker-compose.yaml
Normal file
@@ -0,0 +1,127 @@
|
||||
# Langflow - Visual Framework for Building AI Applications
|
||||
# https://github.com/langflow-ai/langflow
|
||||
#
|
||||
# Langflow is a low-code app builder for RAG and multi-agent AI applications.
|
||||
# It's Python-based and agnostic to any model, API, or database.
|
||||
#
|
||||
# Key Features:
|
||||
# - Visual flow builder for AI applications
|
||||
# - Support for multiple LLMs (OpenAI, Anthropic, Google, etc.)
|
||||
# - Built-in components for RAG, agents, and chains
|
||||
# - Custom component support
|
||||
# - Real-time monitoring and logging
|
||||
# - Multi-user support with authentication
|
||||
#
|
||||
# Default Access:
|
||||
# - Access UI at http://localhost:7860
|
||||
# - No authentication by default (set LANGFLOW_AUTO_LOGIN=false to enable)
|
||||
#
|
||||
# Security Notes:
|
||||
# - Set LANGFLOW_SECRET_KEY for production
|
||||
# - Use strong database passwords
|
||||
# - Enable authentication in production
|
||||
# - Store API keys as global variables, not in flows
|
||||
# - Enable SSL/TLS in production
|
||||
#
|
||||
# License: MIT (https://github.com/langflow-ai/langflow/blob/main/LICENSE)
|
||||
|
||||
x-defaults: &defaults
|
||||
restart: unless-stopped
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: ${LOG_MAX_SIZE:-100m}
|
||||
max-file: "${LOG_MAX_FILE:-3}"
|
||||
|
||||
services:
|
||||
langflow:
|
||||
<<: *defaults
|
||||
image: ${GLOBAL_REGISTRY:-}langflowai/langflow:${LANGFLOW_VERSION:-1.1.1}
|
||||
ports:
|
||||
- "${LANGFLOW_PORT_OVERRIDE:-7860}:7860"
|
||||
environment:
|
||||
# Database configuration
|
||||
- LANGFLOW_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
|
||||
|
||||
# Storage configuration
|
||||
- LANGFLOW_CONFIG_DIR=${LANGFLOW_CONFIG_DIR:-/app/langflow}
|
||||
|
||||
# Server configuration
|
||||
- LANGFLOW_HOST=${LANGFLOW_HOST:-0.0.0.0}
|
||||
- LANGFLOW_PORT=7860
|
||||
- LANGFLOW_WORKERS=${LANGFLOW_WORKERS:-1}
|
||||
|
||||
# Authentication - IMPORTANT: Configure for production
|
||||
- LANGFLOW_AUTO_LOGIN=${LANGFLOW_AUTO_LOGIN:-true}
|
||||
- LANGFLOW_SUPERUSER=${LANGFLOW_SUPERUSER:-langflow}
|
||||
- LANGFLOW_SUPERUSER_PASSWORD=${LANGFLOW_SUPERUSER_PASSWORD:-langflow}
|
||||
- LANGFLOW_SECRET_KEY=${LANGFLOW_SECRET_KEY:-}
|
||||
|
||||
# Features
|
||||
- LANGFLOW_AUTO_SAVING=${LANGFLOW_AUTO_SAVING:-true}
|
||||
- LANGFLOW_AUTO_SAVING_INTERVAL=${LANGFLOW_AUTO_SAVING_INTERVAL:-1000}
|
||||
- LANGFLOW_STORE_ENVIRONMENT_VARIABLES=${LANGFLOW_STORE_ENVIRONMENT_VARIABLES:-true}
|
||||
- LANGFLOW_FALLBACK_TO_ENV_VAR=${LANGFLOW_FALLBACK_TO_ENV_VAR:-true}
|
||||
|
||||
# Optional: Custom components path
|
||||
- LANGFLOW_COMPONENTS_PATH=${LANGFLOW_COMPONENTS_PATH:-}
|
||||
|
||||
# Optional: Load flows from directory
|
||||
- LANGFLOW_LOAD_FLOWS_PATH=${LANGFLOW_LOAD_FLOWS_PATH:-}
|
||||
|
||||
# Logging
|
||||
- LANGFLOW_LOG_LEVEL=${LANGFLOW_LOG_LEVEL:-error}
|
||||
|
||||
# Other settings
|
||||
- TZ=${TZ:-UTC}
|
||||
- DO_NOT_TRACK=${DO_NOT_TRACK:-false}
|
||||
|
||||
volumes:
|
||||
- langflow_data:${LANGFLOW_CONFIG_DIR:-/app/langflow}
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import requests; requests.get('http://localhost:7860/health_check', timeout=5)"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 60s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${LANGFLOW_CPU_LIMIT:-2.0}"
|
||||
memory: "${LANGFLOW_MEMORY_LIMIT:-2G}"
|
||||
reservations:
|
||||
cpus: "${LANGFLOW_CPU_RESERVATION:-0.5}"
|
||||
memory: "${LANGFLOW_MEMORY_RESERVATION:-512M}"
|
||||
|
||||
postgres:
|
||||
<<: *defaults
|
||||
image: ${GLOBAL_REGISTRY:-}postgres:${POSTGRES_VERSION:-16-alpine}
|
||||
environment:
|
||||
- POSTGRES_DB=${POSTGRES_DB:-langflow}
|
||||
- POSTGRES_USER=${POSTGRES_USER:-langflow}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-langflow}
|
||||
- POSTGRES_INITDB_ARGS=--encoding=UTF8
|
||||
- TZ=${TZ:-UTC}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-langflow} -d ${POSTGRES_DB:-langflow}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 10s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${POSTGRES_CPU_LIMIT:-1.0}"
|
||||
memory: "${POSTGRES_MEMORY_LIMIT:-1G}"
|
||||
reservations:
|
||||
cpus: "${POSTGRES_CPU_RESERVATION:-0.25}"
|
||||
memory: "${POSTGRES_MEMORY_RESERVATION:-256M}"
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
langflow_data:
|
||||
Reference in New Issue
Block a user