feat(ai): 完善可插拔 AI Provider 并优先使用 Qwen 模型 - #19
Merged
Conversation
added 12 commits
July 29, 2026 10:46
There was a problem hiding this comment.
Found two correctness/security issues in the provider routing and realtime credential configuration. The backend test suite passes (mvn test).
Findings without inline locations
backend/unispeaking-server/src/main/java/com/unispeaking/infrastructure/ai/qwen/RealtimeProperties.java:39: This acceptshttpfor the temporary-key endpoint even thoughRealtimeCredentialServiceImplsends the permanentDASHSCOPE_API_KEYin theAuthorizationheader to this URL. A misconfigured or intercepted endpoint can therefore expose the permanent credential; require HTTPS (and ideally validate the expected DashScope host) before allowing startup.
| List<String> models = model.isBlank() | ||
| ? route(AiCapability.REALTIME) | ||
| : List.of(model); | ||
| if (!model.isBlank()) { |
There was a problem hiding this comment.
When requestedModel is blank, this branch builds the route from configuration but never validates requestedProvider. A caller that supplies (for example) ProviderType.OPENAI with no model is silently routed to the configured Qwen model, whereas the previous implementation rejected a provider/model mismatch for both explicit and default models. Either reject a non-null provider hint that does not own the selected route, or select the requested provider's default model.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
执行结果:
使用新的
.env.example验证 Spring 配置加载:UNISPEAKING_ENV_FILE=/path/to/UniSpeaking/deploy/env/.env.example \ ./mvnw -Dtest=UniSpeakingApplicationTests test执行结果:
同时执行:
执行结果:未发现空白字符或补丁格式问题。
GitHub Actions
环境变量
.env.example新增或补充的主要环境变量包括:
备用模型所需的 DeepSeek、豆包和 MiniMax 凭证也已在
.env.example中预留。风险说明
用户登录
不受影响。
本次未修改认证、用户信息、Token 登录校验及权限相关代码。
实时语音会话
存在较低影响风险。
Realtime Provider 调用接口进行了统一,但临时 Key 获取流程、有效期管理和 SDP 交换流程保持不变,并已通过相关测试。
WebRTC 连接
存在较低影响风险。
Realtime SDP 返回值由旧 DTO 调整为直接返回
String answerSdp。业务层对外返回结构未改变,相关连接和主备路由测试已通过。RequestID
不受影响。
本次未修改业务 RequestID 生成与传递逻辑。原 Realtime Provider 的
aiCallId为null,调整后仍保持相同行为。用量统计
不受影响。
本次未修改用量采集、会话计量及统计逻辑。
计费链路
不受影响。
本次未修改配额预留、扣减、结算或计费相关代码。
其他风险
AI_PROVIDER_ROUTE_*配置。