response-compliance
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenResponses Compliance Test
OpenResponses 合规测试
Run the official OpenResponses compliance test suite against the local (or remote) Response API endpoint.
对本地(或远程)Response API端点运行官方OpenResponses合规测试套件。
Quick Start
快速开始
bash
undefinedbash
undefinedFrom the openapi package directory
From the openapi package directory
cd lobehub/packages/openapi
cd lobehub/packages/openapi
Run all tests (dev mode, localhost:3010)
Run all tests (dev mode, localhost:3010)
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
Run specific tests only
Run specific tests only
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
--filter basic-response,streaming-response
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
--filter basic-response,streaming-response
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
--filter basic-response,streaming-response
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1
--filter basic-response,streaming-response
Verbose mode (shows request/response details)
Verbose mode (shows request/response details)
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 -v
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 -v
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 -v
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 -v
JSON output (for CI)
JSON output (for CI)
APP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 --json
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 --json
undefinedAPP_URL=http://localhost:3010 bun run test:response-compliance --
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 --json
--auth-header "lobe-auth-dev-backend-api" --no-bearer --api-key 1 --json
undefinedPrerequisites
前置要求
- Dev server running with in
ENABLE_MOCK_DEV_USER=true.env - The route registered (via
api/v1/responses)src/app/(backend)/api/v1/[[...route]]/route.ts
- 开发服务器已运行,且中配置了
.envENABLE_MOCK_DEV_USER=true - 已注册路由(通过
api/v1/responses)src/app/(backend)/api/v1/[[...route]]/route.ts
Auth Modes
认证模式
| Mode | Flags |
|---|---|
| Dev (mock user) | |
| API Key | |
| Custom | |
| 模式 | 标识参数 |
|---|---|
| 开发(模拟用户) | |
| API Key | |
| 自定义 | |
Test IDs
测试ID
Available values:
--filter| ID | Description | Related Issue |
|---|---|---|
| Simple text generation (non-streaming) | LOBE-5858 |
| SSE streaming lifecycle + events | LOBE-5859 |
| System role message handling | LOBE-5858 |
| Function tool definition + call output | LOBE-5860 |
| Multimodal image URL content | — |
| Conversation history via input items | LOBE-5861 |
可用的参数值:
--filter| ID | 描述 | 关联Issue |
|---|---|---|
| 简单文本生成(非流式) | LOBE-5858 |
| SSE流式生命周期 + 事件 | LOBE-5859 |
| 系统角色消息处理 | LOBE-5858 |
| 函数工具定义 + 调用输出 | LOBE-5860 |
| 多模态图片URL内容 | — |
| 基于输入项的对话历史 | LOBE-5861 |
Environment Variables
环境变量
| Variable | Default | Description |
|---|---|---|
| | Server base URL (auto-appends |
| — | API key (alternative to |
| 变量名 | 默认值 | 说明 |
|---|---|---|
| | 服务端基础URL(自动拼接 |
| — | API密钥(可替代 |
How It Works
工作原理
The script () clones the official openresponses/openresponses repo into (gitignored) and runs its CLI test runner. First run clones; subsequent runs update from upstream.
lobehub/packages/openapi/scripts/compliance-test.shscripts/openresponses-compliance/脚本()会将官方openresponses/openresponses仓库克隆到目录(已加入gitignore)并运行其CLI测试运行器。首次运行会执行克隆操作,后续运行会从上游仓库拉取更新。
lobehub/packages/openapi/scripts/compliance-test.shscripts/openresponses-compliance/Debugging Failures
失败调试
- Run with to see full request/response payloads
-v - Common failure patterns:
- "Failed to parse JSON": Auth failed, server returned HTML redirect
- "Response has no output items": LLM execution not yet implemented
- "Expected number, received null": Missing required field in response schema
- "Invalid input": Zod validation on response schema — check field format
- 加上参数运行即可查看完整的请求/响应负载
-v - 常见失败场景:
- "Failed to parse JSON":认证失败,服务端返回HTML重定向
- "Response has no output items":LLM执行功能尚未实现
- "Expected number, received null":响应schema中缺少必填字段
- "Invalid input":响应schema未通过Zod校验,请检查字段格式
Key Files
关键文件
- Types:
lobehub/packages/openapi/src/types/responses.type.ts - Service:
lobehub/packages/openapi/src/services/responses.service.ts - Controller:
lobehub/packages/openapi/src/controllers/responses.controller.ts - Route:
lobehub/packages/openapi/src/routes/responses.route.ts - Test script:
lobehub/packages/openapi/scripts/compliance-test.sh - Cloud route:
src/app/(backend)/api/v1/[[...route]]/route.ts
- 类型定义:
lobehub/packages/openapi/src/types/responses.type.ts - 服务层:
lobehub/packages/openapi/src/services/responses.service.ts - 控制层:
lobehub/packages/openapi/src/controllers/responses.controller.ts - 路由定义:
lobehub/packages/openapi/src/routes/responses.route.ts - 测试脚本:
lobehub/packages/openapi/scripts/compliance-test.sh - 云端路由:
src/app/(backend)/api/v1/[[...route]]/route.ts