逻辑分离
This commit is contained in:
parent
ba0c3460ec
commit
1a7f4d16a1
48
README.md
48
README.md
@ -6,6 +6,54 @@ Java Spring Boot base platform for multiple enterprise agents (CRM assistant, kn
|
|||||||
- POST `/v1/chat/completions`
|
- POST `/v1/chat/completions`
|
||||||
- GET `/v1/healthz`
|
- GET `/v1/healthz`
|
||||||
|
|
||||||
|
## Agent Gateway Architecture
|
||||||
|
`agent-foundation` is the company AI gateway and agent orchestration service.
|
||||||
|
It should stay focused on:
|
||||||
|
|
||||||
|
- WeCom / API entrypoints
|
||||||
|
- user identity and permission context
|
||||||
|
- intent recognition
|
||||||
|
- capability routing
|
||||||
|
- model gateway calls
|
||||||
|
- logs, audit, and runtime diagnostics
|
||||||
|
|
||||||
|
Business-heavy features such as CRM data, knowledge base, PPT generation,
|
||||||
|
bidding documents, reports, and media operations should be implemented as
|
||||||
|
separate capability handlers first, and can later be split into independent
|
||||||
|
services.
|
||||||
|
|
||||||
|
Current runtime flow:
|
||||||
|
|
||||||
|
```text
|
||||||
|
WeCom / API
|
||||||
|
-> AgentOrchestratorService
|
||||||
|
-> IntentRecognitionService
|
||||||
|
-> CapabilityRegistry
|
||||||
|
-> AgentCapabilityHandler
|
||||||
|
```
|
||||||
|
|
||||||
|
To add a new business skill:
|
||||||
|
|
||||||
|
1. Add a new intent in `AgentIntent`.
|
||||||
|
2. Add keyword / LLM routing rules in `IntentRecognitionService`.
|
||||||
|
3. Implement `AgentCapabilityHandler`.
|
||||||
|
4. Mark it as a Spring `@Component`.
|
||||||
|
5. Test it through `/v1/agent/messages` or WeCom.
|
||||||
|
|
||||||
|
## Agent Runtime API
|
||||||
|
- POST `/v1/agent/messages`
|
||||||
|
- GET `/v1/agent/capabilities`
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST "http://127.0.0.1:8880/v1/agent/messages" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "X-Agent-Id: crm-assistant" \
|
||||||
|
-H "X-Internal-Key: crm-dev-key" \
|
||||||
|
-d '{"wecomUserId":"YiNianYiQingJing","message":"今日客资情况"}'
|
||||||
|
```
|
||||||
|
|
||||||
## WeCom CRM Bot Integration
|
## WeCom CRM Bot Integration
|
||||||
- Callback URL: `/v1/integrations/wecom/callback`
|
- Callback URL: `/v1/integrations/wecom/callback`
|
||||||
- Receive enterprise WeCom text messages and route to `crm-assistant`
|
- Receive enterprise WeCom text messages and route to `crm-assistant`
|
||||||
|
|||||||
@ -1,7 +1,26 @@
|
|||||||
package com.company.agentfoundation;
|
package com.company.agentfoundation;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class AgentFoundationApplication {
|
public class AgentFoundationApplication {
|
||||||
public static void main(String[] args) { SpringApplication.run(AgentFoundationApplication.class, args); }
|
private static final Logger log = LoggerFactory.getLogger(AgentFoundationApplication.class);
|
||||||
|
|
||||||
|
@Value("${server.port:8080}")
|
||||||
|
private String serverPort;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(AgentFoundationApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
|
public void onApplicationReady() {
|
||||||
|
log.info("agent-foundation startup success port={} health=/v1/healthz wecomCallback=/v1/integrations/wecom/callback agentMessages=/v1/agent/messages", serverPort);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.company.agentfoundation.agent;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
public record AgentMessageRequest(
|
||||||
|
@NotBlank String message,
|
||||||
|
String wecomUserId
|
||||||
|
) {
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.company.agentfoundation.agent;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
public record AgentMessageResponse(
|
||||||
|
String agentId,
|
||||||
|
String wecomUserId,
|
||||||
|
String reply,
|
||||||
|
Instant timestamp
|
||||||
|
) {
|
||||||
|
public static AgentMessageResponse of(String agentId, String wecomUserId, String reply) {
|
||||||
|
return new AgentMessageResponse(agentId, wecomUserId, reply, Instant.now());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -32,7 +32,7 @@ public class AgentOrchestratorService {
|
|||||||
AgentIntent intent = intentRecognitionService.recognize(agentId, userText);
|
AgentIntent intent = intentRecognitionService.recognize(agentId, userText);
|
||||||
log.info("agent orchestrator route fromUser={} intent={} group={}", fromUser, intent.code(), intent.mcpGroup());
|
log.info("agent orchestrator route fromUser={} intent={} group={}", fromUser, intent.code(), intent.mcpGroup());
|
||||||
if (intent != AgentIntent.GENERAL_CHAT) {
|
if (intent != AgentIntent.GENERAL_CHAT) {
|
||||||
return toWecomText(operationReportService.handle(intent));
|
return toWecomText(operationReportService.handle(intent, AgentRequestContext.of(agentId, fromUser, userText)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatRequest request = new ChatRequest(
|
ChatRequest request = new ChatRequest(
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.company.agentfoundation.agent;
|
||||||
|
|
||||||
|
public record AgentRequestContext(
|
||||||
|
String agentId,
|
||||||
|
String wecomUserId,
|
||||||
|
String userText
|
||||||
|
) {
|
||||||
|
public static AgentRequestContext of(String agentId, String wecomUserId, String userText) {
|
||||||
|
return new AgentRequestContext(agentId, wecomUserId, userText == null ? "" : userText);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package com.company.agentfoundation.agent;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.security.AgentAuthService;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/v1/agent")
|
||||||
|
public class AgentRuntimeController {
|
||||||
|
private final AgentAuthService authService;
|
||||||
|
private final AgentOrchestratorService agentOrchestratorService;
|
||||||
|
|
||||||
|
public AgentRuntimeController(AgentAuthService authService, AgentOrchestratorService agentOrchestratorService) {
|
||||||
|
this.authService = authService;
|
||||||
|
this.agentOrchestratorService = agentOrchestratorService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/messages")
|
||||||
|
public ResponseEntity<AgentMessageResponse> handleMessage(
|
||||||
|
@RequestHeader("X-Agent-Id") String agentId,
|
||||||
|
@RequestHeader("X-Internal-Key") String internalKey,
|
||||||
|
@Valid @RequestBody AgentMessageRequest request
|
||||||
|
) {
|
||||||
|
authService.authenticate(agentId, internalKey);
|
||||||
|
String reply = agentOrchestratorService.handleMessage(agentId, request.wecomUserId(), request.message());
|
||||||
|
return ResponseEntity.ok(AgentMessageResponse.of(agentId, request.wecomUserId(), reply));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,7 @@
|
|||||||
package com.company.agentfoundation.agent;
|
package com.company.agentfoundation.agent;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.capability.AgentCapabilityDescriptor;
|
||||||
|
import com.company.agentfoundation.agent.capability.CapabilityRegistry;
|
||||||
import com.company.agentfoundation.security.AgentAuthService;
|
import com.company.agentfoundation.security.AgentAuthService;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -12,10 +14,18 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
public class OperationReportController {
|
public class OperationReportController {
|
||||||
private final AgentAuthService authService;
|
private final AgentAuthService authService;
|
||||||
private final OperationReportService operationReportService;
|
private final OperationReportService operationReportService;
|
||||||
|
private final CapabilityRegistry capabilityRegistry;
|
||||||
|
|
||||||
public OperationReportController(AgentAuthService authService, OperationReportService operationReportService) {
|
public OperationReportController(AgentAuthService authService, OperationReportService operationReportService, CapabilityRegistry capabilityRegistry) {
|
||||||
this.authService = authService;
|
this.authService = authService;
|
||||||
this.operationReportService = operationReportService;
|
this.operationReportService = operationReportService;
|
||||||
|
this.capabilityRegistry = capabilityRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ResponseEntity<java.util.List<AgentCapabilityDescriptor>> listCapabilities(@RequestHeader("X-Agent-Id") String agentId, @RequestHeader("X-Internal-Key") String internalKey) {
|
||||||
|
authService.authenticate(agentId, internalKey);
|
||||||
|
return ResponseEntity.ok(capabilityRegistry.listCapabilities());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/data-sync/status")
|
@GetMapping("/data-sync/status")
|
||||||
|
|||||||
@ -1,77 +1,45 @@
|
|||||||
package com.company.agentfoundation.agent;
|
package com.company.agentfoundation.agent;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.capability.CapabilityRegistry;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OperationReportService {
|
public class OperationReportService {
|
||||||
public AgentCapabilityResponse handle(AgentIntent intent) {
|
private final CapabilityRegistry capabilityRegistry;
|
||||||
return switch (intent) {
|
|
||||||
case DATA_SYNC_STATUS -> dataSyncStatus();
|
public OperationReportService(CapabilityRegistry capabilityRegistry) {
|
||||||
case CUSTOMER_DASHBOARD_DAILY -> customerDashboardDaily();
|
this.capabilityRegistry = capabilityRegistry;
|
||||||
case STUDENT_ATTENDANCE_DAILY -> studentAttendanceDaily();
|
}
|
||||||
case WECOM_OPERATION_DAILY -> wecomOperationDaily();
|
|
||||||
case EC_CALL_COMPLIANCE_DAILY -> ecCallComplianceDaily();
|
public AgentCapabilityResponse handle(AgentIntent intent, AgentRequestContext context) {
|
||||||
case PERIOD_SUMMARY_REPORT -> periodSummaryReport();
|
return capabilityRegistry.execute(intent, context);
|
||||||
case CONTENT_GENERATION -> contentGeneration();
|
|
||||||
case GENERAL_CHAT -> AgentCapabilityResponse.placeholder(intent, "\u901a\u7528\u5bf9\u8bdd\u80fd\u529b\u6b63\u5728\u5b8c\u5584\u4e2d\u3002", List.of("DeepSeek"));
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCapabilityResponse dataSyncStatus() {
|
public AgentCapabilityResponse dataSyncStatus() {
|
||||||
return AgentCapabilityResponse.placeholder(
|
return handle(AgentIntent.DATA_SYNC_STATUS, AgentRequestContext.of(null, null, null));
|
||||||
AgentIntent.DATA_SYNC_STATUS,
|
|
||||||
"\u4e09\u7cfb\u7edf\u63a5\u53e3\u6253\u901a\u4e0e\u6570\u636e\u540c\u6b65\u80fd\u529b\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u63a5\u5165\u5b66\u90a6\u6559\u52a1\u7cfb\u7edf\u3001\u4f01\u4e1a\u5fae\u4fe1\u3001EC \u7535\u8bdd\u76d1\u63a7\u5e73\u53f0\u3002",
|
|
||||||
List.of("\u5b66\u90a6\u6559\u52a1\u7cfb\u7edf", "\u4f01\u4e1a\u5fae\u4fe1", "EC \u7535\u8bdd\u76d1\u63a7\u5e73\u53f0")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCapabilityResponse customerDashboardDaily() {
|
public AgentCapabilityResponse customerDashboardDaily() {
|
||||||
return AgentCapabilityResponse.placeholder(
|
return handle(AgentIntent.CUSTOMER_DASHBOARD_DAILY, AgentRequestContext.of(null, null, null));
|
||||||
AgentIntent.CUSTOMER_DASHBOARD_DAILY,
|
|
||||||
"\u5ba2\u8d44\u5927\u76d8\u6570\u636e\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u8986\u76d6\u5ba2\u8d44\u65b0\u589e\u3001\u5206\u914d\u3001\u8ddf\u8fdb\u3001\u8f6c\u5316\u3001\u6d41\u5931\u4e0e\u5f02\u5e38\u98ce\u9669\u9884\u8b66\u3002",
|
|
||||||
List.of("\u5b66\u90a6\u6559\u52a1\u7cfb\u7edf", "\u4f01\u4e1a\u5fae\u4fe1", "CRM \u6570\u636e\u5e93")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCapabilityResponse studentAttendanceDaily() {
|
public AgentCapabilityResponse studentAttendanceDaily() {
|
||||||
return AgentCapabilityResponse.placeholder(
|
return handle(AgentIntent.STUDENT_ATTENDANCE_DAILY, AgentRequestContext.of(null, null, null));
|
||||||
AgentIntent.STUDENT_ATTENDANCE_DAILY,
|
|
||||||
"\u5b66\u5458\u6559\u5b66\u51fa\u52e4\u65e5\u62a5\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u6c47\u603b\u6392\u8bfe\u3001\u7b7e\u5230\u51fa\u52e4\u3001\u8bfe\u540e\u8bc4\u4ef7\u548c\u8bfe\u7a0b\u6210\u679c\u7d20\u6750\u3002",
|
|
||||||
List.of("\u5b66\u90a6\u6559\u52a1\u7cfb\u7edf")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCapabilityResponse wecomOperationDaily() {
|
public AgentCapabilityResponse wecomOperationDaily() {
|
||||||
return AgentCapabilityResponse.placeholder(
|
return handle(AgentIntent.WECOM_OPERATION_DAILY, AgentRequestContext.of(null, null, null));
|
||||||
AgentIntent.WECOM_OPERATION_DAILY,
|
|
||||||
"\u4f01\u4e1a\u5fae\u4fe1\u5ba2\u6237\u8fd0\u8425\u65e5\u62a5\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u7edf\u8ba1\u5ba2\u6237\u65b0\u589e\u3001\u6c9f\u901a\u6d3b\u8dc3\u5ea6\u3001\u89e6\u8fbe\u6548\u679c\u4e0e\u5ba2\u6237\u6d41\u5931\u3002",
|
|
||||||
List.of("\u4f01\u4e1a\u5fae\u4fe1")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCapabilityResponse ecCallComplianceDaily() {
|
public AgentCapabilityResponse ecCallComplianceDaily() {
|
||||||
return AgentCapabilityResponse.placeholder(
|
return handle(AgentIntent.EC_CALL_COMPLIANCE_DAILY, AgentRequestContext.of(null, null, null));
|
||||||
AgentIntent.EC_CALL_COMPLIANCE_DAILY,
|
|
||||||
"EC \u7535\u8bdd\u5408\u89c4\u76d1\u63a7\u65e5\u62a5\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u7edf\u8ba1\u5916\u547c\u603b\u91cf\u3001\u63a5\u901a\u7387\u3001\u6709\u6548\u901a\u8bdd\u65f6\u957f\u3001\u5f55\u97f3\u5408\u89c4\u4e0e\u8d26\u53f7\u98ce\u63a7\u3002",
|
|
||||||
List.of("EC \u7535\u8bdd\u76d1\u63a7\u5e73\u53f0")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCapabilityResponse periodSummaryReport() {
|
public AgentCapabilityResponse periodSummaryReport() {
|
||||||
return AgentCapabilityResponse.placeholder(
|
return handle(AgentIntent.PERIOD_SUMMARY_REPORT, AgentRequestContext.of(null, null, null));
|
||||||
AgentIntent.PERIOD_SUMMARY_REPORT,
|
|
||||||
"\u5468\u671f\u5316\u7ecf\u8425\u5468\u62a5\u3001\u6708\u62a5\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u6574\u5408\u4e09\u5e73\u53f0\u6bcf\u65e5\u6570\u636e\u7528\u4e8e\u7ba1\u7406\u590d\u76d8\u548c\u7ecf\u8425\u5206\u6790\u3002",
|
|
||||||
List.of("\u5b66\u90a6\u6559\u52a1\u7cfb\u7edf", "\u4f01\u4e1a\u5fae\u4fe1", "EC \u7535\u8bdd\u76d1\u63a7\u5e73\u53f0")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgentCapabilityResponse contentGeneration() {
|
public AgentCapabilityResponse contentGeneration() {
|
||||||
return AgentCapabilityResponse.placeholder(
|
return handle(AgentIntent.CONTENT_GENERATION, AgentRequestContext.of(null, null, null));
|
||||||
AgentIntent.CONTENT_GENERATION,
|
|
||||||
"\u7ecf\u8425\u5185\u5bb9\u667a\u80fd\u751f\u6210\u80fd\u529b\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u652f\u6301\u5ba2\u670d\u8bdd\u672f\u3001\u670d\u52a1 SOP\u3001\u8425\u9500\u6d3b\u52a8\u65b9\u6848\u3001\u83b7\u5ba2\u6587\u6848\u548c\u7ba1\u7406\u5236\u5ea6\u751f\u6210\u3002",
|
|
||||||
List.of("DeepSeek", "\u8fd0\u8425\u77e5\u8bc6\u5e93")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.AgentCapabilityResponse;
|
||||||
|
import com.company.agentfoundation.agent.AgentIntent;
|
||||||
|
import com.company.agentfoundation.agent.AgentRequestContext;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
abstract class AbstractPlaceholderCapabilityHandler implements AgentCapabilityHandler {
|
||||||
|
private final AgentIntent intent;
|
||||||
|
private final String message;
|
||||||
|
private final List<String> dataSources;
|
||||||
|
|
||||||
|
protected AbstractPlaceholderCapabilityHandler(AgentIntent intent, String message, List<String> dataSources) {
|
||||||
|
this.intent = intent;
|
||||||
|
this.message = message;
|
||||||
|
this.dataSources = dataSources;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AgentIntent intent() {
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AgentCapabilityResponse handle(AgentRequestContext context) {
|
||||||
|
return AgentCapabilityResponse.placeholder(intent, message, dataSources);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
public record AgentCapabilityDescriptor(
|
||||||
|
String intentCode,
|
||||||
|
String title,
|
||||||
|
String mcpGroup,
|
||||||
|
String handlerClass
|
||||||
|
) {
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.AgentCapabilityResponse;
|
||||||
|
import com.company.agentfoundation.agent.AgentIntent;
|
||||||
|
import com.company.agentfoundation.agent.AgentRequestContext;
|
||||||
|
|
||||||
|
public interface AgentCapabilityHandler {
|
||||||
|
AgentIntent intent();
|
||||||
|
|
||||||
|
AgentCapabilityResponse handle(AgentRequestContext context);
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.AgentCapabilityResponse;
|
||||||
|
import com.company.agentfoundation.agent.AgentIntent;
|
||||||
|
import com.company.agentfoundation.agent.AgentRequestContext;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CapabilityRegistry {
|
||||||
|
private final Map<AgentIntent, AgentCapabilityHandler> handlers = new EnumMap<>(AgentIntent.class);
|
||||||
|
|
||||||
|
public CapabilityRegistry(List<AgentCapabilityHandler> handlerList) {
|
||||||
|
for (AgentCapabilityHandler handler : handlerList) {
|
||||||
|
handlers.put(handler.intent(), handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AgentCapabilityResponse execute(AgentIntent intent, AgentRequestContext context) {
|
||||||
|
AgentCapabilityHandler handler = handlers.get(intent);
|
||||||
|
if (handler == null) {
|
||||||
|
return AgentCapabilityResponse.placeholder(intent, "\u8be5\u80fd\u529b\u8fd8\u672a\u6ce8\u518c\uff0c\u8bf7\u5148\u589e\u52a0\u5bf9\u5e94\u7684 CapabilityHandler\u3002", List.of());
|
||||||
|
}
|
||||||
|
return handler.handle(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AgentCapabilityDescriptor> listCapabilities() {
|
||||||
|
return handlers.values().stream()
|
||||||
|
.map(handler -> new AgentCapabilityDescriptor(
|
||||||
|
handler.intent().code(),
|
||||||
|
handler.intent().title(),
|
||||||
|
handler.intent().mcpGroup(),
|
||||||
|
handler.getClass().getSimpleName()
|
||||||
|
))
|
||||||
|
.sorted(Comparator.comparing(AgentCapabilityDescriptor::intentCode))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.AgentIntent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ContentGenerationCapabilityHandler extends AbstractPlaceholderCapabilityHandler {
|
||||||
|
public ContentGenerationCapabilityHandler() {
|
||||||
|
super(
|
||||||
|
AgentIntent.CONTENT_GENERATION,
|
||||||
|
"\u7ecf\u8425\u5185\u5bb9\u667a\u80fd\u751f\u6210\u80fd\u529b\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u652f\u6301\u5ba2\u670d\u8bdd\u672f\u3001\u670d\u52a1 SOP\u3001\u8425\u9500\u6d3b\u52a8\u65b9\u6848\u3001\u83b7\u5ba2\u6587\u6848\u548c\u7ba1\u7406\u5236\u5ea6\u751f\u6210\u3002",
|
||||||
|
List.of("DeepSeek", "\u8fd0\u8425\u77e5\u8bc6\u5e93")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.AgentIntent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CustomerDashboardDailyCapabilityHandler extends AbstractPlaceholderCapabilityHandler {
|
||||||
|
public CustomerDashboardDailyCapabilityHandler() {
|
||||||
|
super(
|
||||||
|
AgentIntent.CUSTOMER_DASHBOARD_DAILY,
|
||||||
|
"\u5ba2\u8d44\u5927\u76d8\u6570\u636e\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u8986\u76d6\u5ba2\u8d44\u65b0\u589e\u3001\u5206\u914d\u3001\u8ddf\u8fdb\u3001\u8f6c\u5316\u3001\u6d41\u5931\u4e0e\u5f02\u5e38\u98ce\u9669\u9884\u8b66\u3002",
|
||||||
|
List.of("\u5b66\u90a6\u6559\u52a1\u7cfb\u7edf", "\u4f01\u4e1a\u5fae\u4fe1", "CRM \u6570\u636e\u5e93")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.AgentIntent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class DataSyncStatusCapabilityHandler extends AbstractPlaceholderCapabilityHandler {
|
||||||
|
public DataSyncStatusCapabilityHandler() {
|
||||||
|
super(
|
||||||
|
AgentIntent.DATA_SYNC_STATUS,
|
||||||
|
"\u4e09\u7cfb\u7edf\u63a5\u53e3\u6253\u901a\u4e0e\u6570\u636e\u540c\u6b65\u80fd\u529b\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u63a5\u5165\u5b66\u90a6\u6559\u52a1\u7cfb\u7edf\u3001\u4f01\u4e1a\u5fae\u4fe1\u3001EC \u7535\u8bdd\u76d1\u63a7\u5e73\u53f0\u3002",
|
||||||
|
List.of("\u5b66\u90a6\u6559\u52a1\u7cfb\u7edf", "\u4f01\u4e1a\u5fae\u4fe1", "EC \u7535\u8bdd\u76d1\u63a7\u5e73\u53f0")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.AgentIntent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class EcCallComplianceDailyCapabilityHandler extends AbstractPlaceholderCapabilityHandler {
|
||||||
|
public EcCallComplianceDailyCapabilityHandler() {
|
||||||
|
super(
|
||||||
|
AgentIntent.EC_CALL_COMPLIANCE_DAILY,
|
||||||
|
"EC \u7535\u8bdd\u5408\u89c4\u76d1\u63a7\u65e5\u62a5\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u7edf\u8ba1\u5916\u547c\u603b\u91cf\u3001\u63a5\u901a\u7387\u3001\u6709\u6548\u901a\u8bdd\u65f6\u957f\u3001\u5f55\u97f3\u5408\u89c4\u4e0e\u8d26\u53f7\u98ce\u63a7\u3002",
|
||||||
|
List.of("EC \u7535\u8bdd\u76d1\u63a7\u5e73\u53f0")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.AgentIntent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PeriodSummaryReportCapabilityHandler extends AbstractPlaceholderCapabilityHandler {
|
||||||
|
public PeriodSummaryReportCapabilityHandler() {
|
||||||
|
super(
|
||||||
|
AgentIntent.PERIOD_SUMMARY_REPORT,
|
||||||
|
"\u5468\u671f\u5316\u7ecf\u8425\u5468\u62a5\u3001\u6708\u62a5\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u6574\u5408\u4e09\u5e73\u53f0\u6bcf\u65e5\u6570\u636e\u7528\u4e8e\u7ba1\u7406\u590d\u76d8\u548c\u7ecf\u8425\u5206\u6790\u3002",
|
||||||
|
List.of("\u5b66\u90a6\u6559\u52a1\u7cfb\u7edf", "\u4f01\u4e1a\u5fae\u4fe1", "EC \u7535\u8bdd\u76d1\u63a7\u5e73\u53f0")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.AgentIntent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class StudentAttendanceDailyCapabilityHandler extends AbstractPlaceholderCapabilityHandler {
|
||||||
|
public StudentAttendanceDailyCapabilityHandler() {
|
||||||
|
super(
|
||||||
|
AgentIntent.STUDENT_ATTENDANCE_DAILY,
|
||||||
|
"\u5b66\u5458\u6559\u5b66\u51fa\u52e4\u65e5\u62a5\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u6c47\u603b\u6392\u8bfe\u3001\u7b7e\u5230\u51fa\u52e4\u3001\u8bfe\u540e\u8bc4\u4ef7\u548c\u8bfe\u7a0b\u6210\u679c\u7d20\u6750\u3002",
|
||||||
|
List.of("\u5b66\u90a6\u6559\u52a1\u7cfb\u7edf")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.company.agentfoundation.agent.capability;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.agent.AgentIntent;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class WecomOperationDailyCapabilityHandler extends AbstractPlaceholderCapabilityHandler {
|
||||||
|
public WecomOperationDailyCapabilityHandler() {
|
||||||
|
super(
|
||||||
|
AgentIntent.WECOM_OPERATION_DAILY,
|
||||||
|
"\u4f01\u4e1a\u5fae\u4fe1\u5ba2\u6237\u8fd0\u8425\u65e5\u62a5\u6b63\u5728\u5b8c\u5584\u4e2d\uff0c\u540e\u7eed\u5c06\u7edf\u8ba1\u5ba2\u6237\u65b0\u589e\u3001\u6c9f\u901a\u6d3b\u8dc3\u5ea6\u3001\u89e6\u8fbe\u6548\u679c\u4e0e\u5ba2\u6237\u6d41\u5931\u3002",
|
||||||
|
List.of("\u4f01\u4e1a\u5fae\u4fe1")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user