feat: add more

This commit is contained in:
Sun-ZhenXing
2025-10-06 21:48:39 +08:00
parent f330e00fa0
commit 3c609b5989
120 changed files with 7698 additions and 59 deletions

73
src/langfuse/README.md Normal file
View File

@@ -0,0 +1,73 @@
# Langfuse
[English](./README.md) | [中文](./README.zh.md)
This service deploys Langfuse, an open-source LLM engineering platform for observability, metrics, evaluations, and prompt management.
## Services
- `langfuse-server`: The main Langfuse application server.
- `langfuse-db`: PostgreSQL database for Langfuse.
## Environment Variables
| Variable Name | Description | Default Value |
| ------------------------------------- | ----------------------------------------------- | ----------------------- |
| LANGFUSE_VERSION | Langfuse image version | `3.115.0` |
| LANGFUSE_PORT | Host port mapping for Langfuse web interface | `3000` |
| POSTGRES_VERSION | PostgreSQL image version | `17.2-alpine3.21` |
| POSTGRES_USER | PostgreSQL username | `postgres` |
| POSTGRES_PASSWORD | PostgreSQL password | `postgres` |
| POSTGRES_DB | PostgreSQL database name | `langfuse` |
| NEXTAUTH_URL | Public URL of your Langfuse instance | `http://localhost:3000` |
| NEXTAUTH_SECRET | Secret for NextAuth.js (required, generate one) | `""` |
| SALT | Salt for encryption (required, generate one) | `""` |
| TELEMETRY_ENABLED | Enable telemetry | `true` |
| LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES | Enable experimental features | `false` |
**Important**: You must set `NEXTAUTH_SECRET` and `SALT` for production use. Generate them using:
```bash
# For NEXTAUTH_SECRET
openssl rand -base64 32
# For SALT
openssl rand -base64 32
```
Please create a `.env` file and modify it as needed for your use case.
## Volumes
- `langfuse_db_data`: A volume for storing PostgreSQL data.
## Getting Started
1. Create a `.env` file with required secrets:
```env
NEXTAUTH_SECRET=your-generated-secret-here
SALT=your-generated-salt-here
POSTGRES_PASSWORD=your-secure-password
```
2. Start the services:
```bash
docker compose up -d
```
3. Access Langfuse at `http://localhost:3000`
4. Create your first account on the setup page
## Documentation
For more information, visit the [official Langfuse documentation](https://langfuse.com/docs).
## Security Notes
- Change default passwords in production
- Use strong, randomly generated values for `NEXTAUTH_SECRET` and `SALT`
- Consider using a reverse proxy with SSL/TLS in production
- Regularly backup the PostgreSQL database

73
src/langfuse/README.zh.md Normal file
View File

@@ -0,0 +1,73 @@
# Langfuse
[English](./README.md) | [中文](./README.zh.md)
此服务部署 Langfuse,一个用于 LLM 应用可观测性、指标、评估和提示管理的开源平台。
## 服务
- `langfuse-server`: Langfuse 主应用服务器。
- `langfuse-db`: Langfuse 的 PostgreSQL 数据库。
## 环境变量
| 变量名 | 描述 | 默认值 |
| ------------------------------------- | ------------------------------- | ----------------------- |
| LANGFUSE_VERSION | Langfuse 镜像版本 | `3.115.0` |
| LANGFUSE_PORT | Langfuse Web 界面的主机端口映射 | `3000` |
| POSTGRES_VERSION | PostgreSQL 镜像版本 | `17.2-alpine3.21` |
| POSTGRES_USER | PostgreSQL 用户名 | `postgres` |
| POSTGRES_PASSWORD | PostgreSQL 密码 | `postgres` |
| POSTGRES_DB | PostgreSQL 数据库名 | `langfuse` |
| NEXTAUTH_URL | Langfuse 实例的公开 URL | `http://localhost:3000` |
| NEXTAUTH_SECRET | NextAuth.js 密钥(必需,需要生成) | `""` |
| SALT | 加密盐值(必需,需要生成) | `""` |
| TELEMETRY_ENABLED | 启用遥测 | `true` |
| LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES | 启用实验性功能 | `false` |
**重要提示**: 在生产环境中必须设置 `NEXTAUTH_SECRET``SALT`。使用以下命令生成:
```bash
# 生成 NEXTAUTH_SECRET
openssl rand -base64 32
# 生成 SALT
openssl rand -base64 32
```
请创建 `.env` 文件并根据需要进行修改。
## 数据卷
- `langfuse_db_data`: 用于存储 PostgreSQL 数据的卷。
## 快速开始
1. 创建包含必需密钥的 `.env` 文件:
```env
NEXTAUTH_SECRET=your-generated-secret-here
SALT=your-generated-salt-here
POSTGRES_PASSWORD=your-secure-password
```
2. 启动服务:
```bash
docker compose up -d
```
3. 访问 `http://localhost:3000`
4. 在设置页面创建您的第一个账户
## 文档
更多信息请访问 [Langfuse 官方文档](https://langfuse.com/docs)。
## 安全提示
- 在生产环境中更改默认密码
- 为 `NEXTAUTH_SECRET` 和 `SALT` 使用强随机生成的值
- 在生产环境中考虑使用带 SSL/TLS 的反向代理
- 定期备份 PostgreSQL 数据库

View File

@@ -0,0 +1,63 @@
x-default: &default
restart: unless-stopped
volumes:
- &localtime /etc/localtime:/etc/localtime:ro
- &timezone /etc/timezone:/etc/timezone:ro
logging:
driver: json-file
options:
max-size: 100m
services:
langfuse-server:
<<: *default
image: langfuse/langfuse:${LANGFUSE_VERSION:-3.115.0}
container_name: langfuse-server
ports:
- "${LANGFUSE_PORT:-3000}:3000"
environment:
- DATABASE_URL=postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@langfuse-db:5432/${POSTGRES_DB:-langfuse}
- NEXTAUTH_URL=${NEXTAUTH_URL:-http://localhost:3000}
- NEXTAUTH_SECRET=${NEXTAUTH_SECRET}
- SALT=${SALT}
- TELEMETRY_ENABLED=${TELEMETRY_ENABLED:-true}
- LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES=${LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES:-false}
depends_on:
langfuse-db:
condition: service_healthy
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
langfuse-db:
<<: *default
image: postgres:${POSTGRES_VERSION:-17.2-alpine3.21}
container_name: langfuse-db
environment:
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
- POSTGRES_DB=${POSTGRES_DB:-langfuse}
volumes:
- langfuse_db_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
volumes:
langfuse_db_data: