源码构建
源码构建适合需要在 Server 侧开发调试的场景。
- Go 1.27+
- PostgreSQL 17+(需 pgvector 扩展)— 推荐
pgvector/pgvector:pg17镜像 - Redis 7+
- LLM API — Claude 或 OpenAI 兼容接口
1. 克隆代码
Section titled “1. 克隆代码”git clone https://github.com/rtc-agent/server.gitcd server2. 启动基础设施
Section titled “2. 启动基础设施”使用开发 Docker Compose 启动 PostgreSQL、Redis 等:
# 启动开发依赖(PostgreSQL:15432, Redis:16379, Jaeger, Mock OAuth2 等)go run main.go dev dependencies start或手动启动 Docker:
docker compose -f etc/dev/docker-compose.yml up -d复制配置模板并编辑:
cp etc/config.example.yaml etc/config.local.yaml编辑 etc/config.local.yaml,至少修改以下字段:
database: dsn: "postgres://rtc_agent:rtc_agent@localhost:15432/rtc_agent?sslmode=disable"
redis: addr: "localhost:16379"
llm: provider: "claude" # 或 "openai" api_key: "${LLM_API_KEY}" # 通过环境变量注入,启动前 export LLM_API_KEY="your-key" model: "claude-sonnet-4-20250514"配置合并机制:Server 启动时自动加载
etc/config.yaml(基线)+etc/config.local.yaml(覆盖)。config.local.yaml已在.gitignore中,不会被提交。只需写差异项。🔐 API Key 安全:
api_key支持${ENV_VAR}形式引用环境变量,避免明文写入配置文件。启动前通过export LLM_API_KEY="your-key"设置即可。
4. 构建 & 运行
Section titled “4. 构建 & 运行”# 构建go build -o bin/rtc-agent .
# 数据库迁移(首次部署)./bin/rtc-agent migrate
# 启动服务./bin/rtc-agent serve服务启动在 http://localhost:8888。
curl http://localhost:8888/healthz# {"status":"ok"}6. 嵌入前端
Section titled “6. 嵌入前端”Server 启动后,在你的网页中添加 <rtc-agent> 组件:
<script type="module" src="https://cdn.example.com/rtc-agent/index.js"></script><rtc-agent></rtc-agent>