Merge pull request '[AC-INIT] 提交一个 稳定可和ai中台联调的版本' (#16) from feat/multi-channel-framework into main

Reviewed-on: #16
This commit is contained in:
MerCry 2026-02-26 13:05:35 +00:00
commit 078f46c028
6 changed files with 18 additions and 6 deletions

View File

@ -13,5 +13,7 @@ public class AiServiceConfig {
private int timeout = 5000; private int timeout = 5000;
private String tenantId = "szmp@ash@2026"; private String tenantId = "default@ash@2026";
private String apiKey = "tDXu09--IZutcI2h06DCR5WkK9Oi9waTKyUxhaxl5oE";
} }

View File

@ -12,7 +12,7 @@ public class RestTemplateConfig {
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(5000); factory.setConnectTimeout(5000);
factory.setReadTimeout(30000); factory.setReadTimeout(60000);
return new RestTemplate(factory); return new RestTemplate(factory);
} }
} }

View File

@ -11,6 +11,7 @@ import java.util.List;
@ConfigurationProperties(prefix = "transfer") @ConfigurationProperties(prefix = "transfer")
public class TransferConfig { public class TransferConfig {
private boolean enabled = true;
private List<String> keywords; private List<String> keywords;
private double confidenceThreshold; private double confidenceThreshold;
private int maxFailRounds; private int maxFailRounds;

View File

@ -18,6 +18,11 @@ public class TransferService {
private final TransferConfig transferConfig; private final TransferConfig transferConfig;
public boolean shouldTransferToManual(String message, double confidence, int messageCount, LocalDateTime sessionCreatedAt) { public boolean shouldTransferToManual(String message, double confidence, int messageCount, LocalDateTime sessionCreatedAt) {
if (!transferConfig.isEnabled()) {
log.info("转人工功能已关闭,不转人工");
return false;
}
if (containsKeywords(message)) { if (containsKeywords(message)) {
log.info("触发转人工: 关键词匹配"); log.info("触发转人工: 关键词匹配");
return true; return true;

View File

@ -38,6 +38,8 @@ public class AiServiceClientImpl implements AiServiceClient {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("X-Tenant-Id", aiServiceConfig.getTenantId()); headers.set("X-Tenant-Id", aiServiceConfig.getTenantId());
headers.set("X-API-Key", aiServiceConfig.getApiKey());
HttpEntity<ChatRequest> entity = new HttpEntity<>(request, headers); HttpEntity<ChatRequest> entity = new HttpEntity<>(request, headers);
ResponseEntity<ChatResponse> response = restTemplate.postForEntity( ResponseEntity<ChatResponse> response = restTemplate.postForEntity(

View File

@ -1,5 +1,5 @@
server: server:
port: 8080 port: 8883
spring: spring:
application: application:
@ -24,21 +24,23 @@ wecom:
callback-url: /wecom/callback callback-url: /wecom/callback
transfer: transfer:
enabled: false
keywords: keywords:
- 人工 - 人工
- 转人工 - 转人工
- 投诉 - 投诉
- 客服 - 客服
- 人工客服 - 人工客服
confidence-threshold: 0.6 confidence-threshold: 0.35
max-fail-rounds: 3 max-fail-rounds: 3
max-session-duration: 180000000 max-session-duration: 180000000
max-message-rounds: 50 max-message-rounds: 50
ai-service: ai-service:
url: http://localhost:8000 url: http://ashai.com.cn:8182
timeout: 5000 timeout: 30000
tenantId: szmp@ash@2026 tenantId: szmp@ash@2026
apiKey: tDXu09--IZutcI2h06DCR5WkK9Oi9waTKyUxhaxl5oE
channel: channel:
default-channel: wechat default-channel: wechat