79 lines
2.2 KiB
Markdown
79 lines
2.2 KiB
Markdown
# Agent Foundation
|
|
|
|
Java Spring Boot base platform for multiple enterprise agents (CRM assistant, knowledge-base assistant, customer service assistant).
|
|
|
|
## Core API
|
|
- POST `/v1/chat/completions`
|
|
- 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
|
|
- Callback URL: `/v1/integrations/wecom/callback`
|
|
- Receive enterprise WeCom text messages and route to `crm-assistant`
|
|
- Send the model response back to the same WeCom user
|
|
|
|
### Required env vars
|
|
- `DEEPSEEK_API_KEY`
|
|
- `WECOM_CORP_ID`
|
|
- `WECOM_AGENT_ID`
|
|
- `WECOM_SECRET`
|
|
- `WECOM_TOKEN`
|
|
|
|
### WeCom backend settings
|
|
1. Create a WeCom self-built app.
|
|
2. Enable message receive API and set callback URL to:
|
|
- `https://your-domain/v1/integrations/wecom/callback`
|
|
3. Set callback Token equal to `WECOM_TOKEN`.
|
|
4. Make sure app has send-message permission to internal users.
|
|
|
|
## Run
|
|
1. Set env vars.
|
|
2. Start app from IDE or `mvn spring-boot:run`.
|