English
AI Assistant
The AI Assistant is an operations assistant built into the admin panel: ask in natural language about transactions, refunds, allocation, transfers, merchant profiles and audit logs, or ask directly for trade statistics. It is read-only — it never initiates refunds, closes orders or changes any configuration, and its conclusions should still be verified on the business pages.
Entry: after signing in to the admin panel, click the robot icon in the top bar to open the chat drawer (requires the
plugin:ai:viewpermission, with the feature enabled and the model configured). Configuration entry: System Management → System Config → Platform Config → AI Config.
Scope and Boundaries
- Read-only queries: 23 built-in query tools covering transactions, refunds, allocation, transfers, merchant profiles, notification tasks and audit logs; there are no write operations.
- Platform-wide view: the tools are designed for the admin panel and can query across merchants without a merchant context; therefore they are only available on the admin panel — there is no entry in the merchant panel.
- Verify conclusions: the model summarizes tool results in natural language and may omit details or misinterpret them; for fund-related actions, trust Payment Order Management, Refund Management and similar pages.
- Access control: the entry and all chat endpoints check
plugin:ai:viewand are granted per role; turning off the platform master switch makes the whole domain unavailable.
Query Tools
The tools are grouped by business domain into six groups and registered automatically with the plugin; the model chooses which to call and may chain several tools for one question.
| Tool group | Tools (method names) | Count |
|---|---|---|
| Trade statistics | tradeOverview overview, tradeTrend payment trend, refundTrend refund trend, providerSuccess channel success rate, providerDist channel distribution, merchantRank merchant ranking by volume | 6 |
| Trade queries | queryPayTrade payment trade, queryPayOrder payment order, queryGatewayPayOrder gateway order, queryAllocOrder allocation order, queryTransferTrade transfer, queryAbnormalOrder abnormal order | 6 |
| Refund queries | queryRefundOrder by refund No., queryRefundsByTrade all refunds of a trade | 2 |
| Merchant profiles | queryMerchant merchant, queryApp app, queryAppsByMerchant merchant app list, queryStore store, queryChannelMerchant channel merchant | 5 |
| Notification queries | queryNoticeByBizNo notification tasks and delivery records by business No. | 1 |
| Audit logs | queryUnipayApiLog API logs, queryOperateLog operation logs, queryLoginLog login logs | 3 |
Conventions:
- Paged tools return only the latest 10 rows, tell the model the total, and the answer must state "showing the first 10 only";
- The trade overview supports today / yesterday (today by default); trend and ranking tools support the last N days (7 by default) or a custom date range; merchant ranking returns 10 by default and at most 50;
- Audit-log tools filter by keywords only and return summary fields such as time, account, API, success and latency — never raw request/response payloads.
Usage
Click the robot icon in the top bar to open the drawer: the left side is the current account's session list (new, switch, rename, delete) and the right side is the conversation. Opening the drawer loads the session history automatically.

Figure: AI assistant chat drawer: session list on the left, conversation and example questions on the right
Conversations and Sessions
- Press Enter to send and Shift+Enter for a new line; click "Stop" to abort while generating.
- Streaming display: answers are pushed in chunks over SSE (
/admin/ai/chat/stream) and appear segment by segment in the bubble; the first content arrives only after the model completes the whole answer, so "time to first character" includes model thinking and any chained tool execution. - Tool execution: while streaming, the tool steps are shown live (query name, running / succeeded / failed / aborted, duration); when done they collapse into a summary "N queries executed" that can be expanded.
- Action links: answers about trades, orders, refunds, merchants or apps include "View details" links that jump to the corresponding list with the number pre-filled as a filter (payment trades / payment orders / refund orders / merchant list / merchant apps).
- Regenerate / Copy: regenerate the last answer (reruns the last user question) or copy the full text.
- Reasoning: when "Show reasoning" is enabled and the model returns
reasoning_content, a collapsible reasoning block appears above the answer. - Session isolation: sessions are isolated per signed-in user; the session title is the first 30 characters of the first question. Each turn carries at most the latest 20 history messages (about 10 rounds).
- Rate limit: at most 20 chat requests per user per minute; exceeding it prompts the user to retry later.
Empty State and Examples
A new conversation shows a welcome message and three example questions (trade and refund overview, look up a trade by fund trade No., how to query order status). Clicking one fills the input box so it can be edited before sending.

Figure: New conversation empty state: welcome message and three example questions that fill the input on click
Platform Configuration
Menu path: System Management → System Config → Platform Config → AI Config. The form is organized into four sections: Basic Configuration / Generation / Connection & Retries / Reasoning.
| Setting | Description | Default / range |
|---|---|---|
| Enable AI Assistant | Master switch; when off the entry is hidden and chat, regenerate, session query/rename/delete are all disabled; history is preserved | Off on a fresh install; existing configs missing the field are treated as enabled |
| Service endpoint | OpenAI-compatible API base URL, e.g. https://open.bigmodel.cn/api/paas/v4 | Defaults to the Zhipu open-platform endpoint; required, must start with http(s):// |
| API Key | Key for the model service; leave blank to keep the saved key; masked on read (first and last 6 characters) | Required (first time) |
| Model | Model identifier, e.g. glm-4.7, glm-5.3, deepseek-flash | Default glm-4.7 |
| Temperature | Sampling temperature; lower is more stable | 0~2, default 0.7 |
| Top P | Leave empty to omit | 0~1 |
| Max output tokens | Maximum tokens in the answer; leave empty to omit | 1~32768 |
| Frequency / presence penalty | Reduce repeated wording / encourage new topics; leave empty to omit | -2~2 |
| Timeout | Per-request timeout in milliseconds | 5000~300000, default 60000 |
| Max retries | Retry attempts on failure | 0~5, default 2 |
| Reasoning effort | Only effective for OpenAI reasoning models; leave empty to omit | minimal / low / medium / high |
| Extra request params | JSON object of provider-specific parameters (e.g. {"thinking":{"type":"enabled"}}); must not override protocol core fields (model, messages, stream, tools, temperature, etc.) | Up to 2000 characters |
| Show reasoning | Receive and display reasoning_content from the model | Off by default |

Figure: Platform Config → AI Config: enable switch, service endpoint, model, key and generation parameters
Test connection and save
"Test connection" sends a minimal chat request using the current form values (the saved key is used when the key field is blank) and returns latency plus a reply excerpt; it does not affect the live chat configuration. Saving immediately rebuilds the model client. A masked API Key returned to the form is recognized as "unchanged" and is never saved as the real key.
Turning the switch off does not lock the config page
When the master switch is off the whole AI assistant domain is unavailable (including session history), but the AI Config page remains readable and editable — avoiding the deadlock where "turning it off means you can never open it again".
Permission Codes
| Permission code | Purpose |
|---|---|
plugin:ai:view | Show/hide the top-bar entry; all chat, regenerate and session query/rename/delete endpoints |
system:ai-config:view | View the AI Config page (tab visibility on the Platform Config page) |
system:ai-config:manage | Save the AI config and run the connectivity test |
The AI assistant menu (plugin:ai) is a hidden subpage and does not occupy the sidebar; AI Config (system:ai-config) lives as a tab under Platform Config and is not shown as a standalone menu either.
Deployment Notes
- Egress network: the backend server must be able to reach the configured service endpoint (HTTPS, including DNS and the TLS certificate chain); if a proxy or firewall allowlist is needed, allow the model provider's domains. The platform receives no callbacks from the model side, so no inbound port is required.
- Key storage: the AI config is stored in the platform encrypted-config table (
system_platform_encrypt_config, config typeai) with AES-256-GCM encryption and depends on the platform's unified data encryption key; keep the existing platform encryption configuration and avoid changing it at will, otherwise old configs may become undecryptable. - Data trail: sessions and messages are stored in
ai_chat_session/ai_chat_message, isolated per user and logically deleted; operation audits go to System Management → Log Management → Operation Logs (moduleAI对话), recording only message length, a SHA256 digest and tool names/durations/success, never full question or answer text. - Dependencies: rate limiting uses Redis (a Lua script counter) and shares the existing platform Redis; no extra middleware is needed.
- Availability check:
GET /admin/ai/statusreturnsenabledandconfigured; the entry appears only when both are true.
API Reference
| Method | Path | Description |
|---|---|---|
| GET | /admin/ai/status | Switch and configuration-completeness status (drives entry visibility) |
| POST | /admin/ai/chat | Synchronous chat (fallback when SSE is unavailable) |
| POST | /admin/ai/chat/stream | Streaming chat (SSE: meta / reasoning / tool / error) |
| POST | /admin/ai/chat/regenerate | Regenerate (synchronous) |
| POST | /admin/ai/chat/regenerate/stream | Regenerate (streaming) |
| GET | /admin/ai/session/page | Current user's sessions, paged |
| GET | /admin/ai/session/messages | Session messages (chronological) |
| POST | /admin/ai/session/rename | Rename a session |
| POST | /admin/ai/session/delete | Delete a session and all its messages |
| GET | /platform/config/ai/get | Read AI config (key masked) |
| POST | /platform/config/ai/check | Connectivity check |
| POST | /platform/config/ai/update | Save AI config |
SSE event meanings: meta carries the session id (new sessions included); reasoning is a reasoning chunk; tool is a tool execution event (start / end with tool name, duration and success); error is a failure message; unnamed data events are answer text chunks.
FAQ
No robot icon in the top bar? Check in order: whether the master switch is on, whether endpoint / key / model are complete, and whether the current role has plugin:ai:view.
The answer takes a long time and then appears all at once? The model call returns the whole answer before it is split into chunks (not token-by-token streaming); if the question triggers several chained tools, the first content waits for all of them to finish.
"Model call failed"? Open the AI Config page and click "Test connection" to confirm the endpoint is reachable, the key is valid and the model name is correct; the error summary appears in the check result.
Is history kept after turning the switch off? Yes, data is preserved and viewable again after re-enabling.
Can the merchant panel use it? No. The AI Assistant is an admin-panel-only capability; merchant users should use the Merchant App or the Web merchant panel.
Related Links
- Permissions and Menu Management: role grants and menu visibility
- Logs and Monitoring: AI chat audit records (operation logs)
- Payment Platform Config: platform endpoint, storage and security configuration
- Payment Order Management: the authoritative query entry for trade and fund data