Compare commits
4 Commits
70b646700b
...
078f46c028
| Author | SHA1 | Date |
|---|---|---|
|
|
078f46c028 | |
|
|
8f5ab8a44b | |
|
|
98ae3a96ba | |
|
|
ab6fb374b9 |
|
|
@ -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";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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(
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue