- 后端新增 /ai/endpoint/test 和 /ai/endpoint/stream 接口,支持直接端点测试 - 前端增加行内测试功能(场景绑定+接口工作流) - 测试对话框增加动态参数表单和参数定义编辑 - 支持 _meta 格式的默认输入参数处理 - web、web-admin 本地开发环境 API 调用改为线上域名 https://lifescript.happylifeos.com Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4.3 KiB
AI Endpoint Test Fix Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Make every AI provider endpoint in web-admin open with complete editable test parameters and make Coze/Dify workflow tests succeed through the backend runtime without breaking existing user-facing AI flows.
Architecture: Keep backend as the only place that knows provider credentials and provider-specific request formats. Add backend test sample generation for endpoint and scene tests, then update web-admin to load those samples when opening the dialog. Patch Coze/Dify provider adapters to match documented and historically working request/stream formats while preserving the current /ai/runtime/stream and /ai/endpoint/stream contracts.
Tech Stack: Spring Boot, FastJSON2, RestTemplate streaming, Element Plus, Vue 3, TypeScript, MySQL.
Task 1: Backend Test Sample Contract
Files:
-
Create:
backend-single/src/main/java/com/emotion/dto/response/ai/AiTestTemplateResponse.java -
Modify:
backend-single/src/main/java/com/emotion/service/AiRuntimeService.java -
Modify:
backend-single/src/main/java/com/emotion/service/impl/AiRuntimeServiceImpl.java -
Modify:
backend-single/src/main/java/com/emotion/controller/AiRoutingController.java -
Add a response DTO with
sceneCode,endpointId,endpointCode,providerType,inputs, andparamFields. -
Add service methods
buildEndpointTestTemplate(String endpointId)andbuildSceneTestTemplate(String sceneCode). -
Generate complete sample inputs even when
defaultInputsis{}or empty. -
Expose
GET /ai/endpoints/test-template?id=...andGET /ai/scenes/test-template?sceneCode=....
Task 2: Provider Runtime Compatibility
Files:
-
Modify:
backend-single/src/main/java/com/emotion/service/ai/ProviderHttpSupport.java -
Modify:
backend-single/src/main/java/com/emotion/service/ai/CozeProviderAdapter.java -
Modify:
backend-single/src/main/java/com/emotion/service/ai/DifyProviderAdapter.java -
Add
Accept: text/event-streamfor stream requests. -
Make Coze workflow body match historical calls:
workflow_id,user_id,stream,parameters, and optionalbot_id. -
Make Coze chat body include
type: questioninadditional_messages. -
Parse Coze workflow events from
output,content,answer,data.output,data.content, and nested message fields. -
Keep Dify chat body aligned with
docs/dify平台接口.md:query,inputs,response_mode,user, optionalconversation_id. -
Emit provider error events when upstream SSE includes an error event.
Task 3: web-admin Test Dialog Defaults
Files:
-
Modify:
web-admin/src/types/aiconfig.ts -
Modify:
web-admin/src/api/aiconfig.ts -
Modify:
web-admin/src/views/aiconfig/AiRoutingList.vue -
Add
AiTestTemplateResponseTypeScript type. -
Add API helpers for endpoint and scene test templates.
-
When opening endpoint test dialog, request backend template and populate form fields plus JSON editor.
-
When opening scene test dialog, request backend template and populate JSON editor.
-
Validate required fields before running stream/non-stream tests.
-
Keep the existing editable JSON advanced area so testers can modify payloads.
Task 4: Database Default Input Backfill
Files:
-
Modify:
sql/2026-05-22-ai-scene-routing.sql -
Backfill
default_inputsfor existing Coze and Dify endpoints with realistic examples. -
Apply the SQL to the test database.
-
Verify all enabled endpoints have non-empty
default_inputs.
Task 5: Verification
Commands:
-
mvn test -
mvn -DskipTests clean package -
npm run buildinweb-admin -
MySQL query for endpoint default inputs.
-
Backend tests pass.
-
Backend package succeeds.
-
web-admin build succeeds.
-
Coze endpoint test returns stream output or a provider business error with full request/log context.
-
Dify endpoint test returns stream output or a provider business error with full request/log context.
-
Existing scene runtime endpoints remain unchanged for web, life-script, and mini-program clients.