Skip to content

AI Assistant ​

Updated: 12/1/26, 5:47:01 PM

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:view permission, 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:view and 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 groupTools (method names)Count
Trade statisticstradeOverview overview, tradeTrend payment trend, refundTrend refund trend, providerSuccess channel success rate, providerDist channel distribution, merchantRank merchant ranking by volume6
Trade queriesqueryPayTrade payment trade, queryPayOrder payment order, queryGatewayPayOrder gateway order, queryAllocOrder allocation order, queryTransferTrade transfer, queryAbnormalOrder abnormal order6
Refund queriesqueryRefundOrder by refund No., queryRefundsByTrade all refunds of a trade2
Merchant profilesqueryMerchant merchant, queryApp app, queryAppsByMerchant merchant app list, queryStore store, queryChannelMerchant channel merchant5
Notification queriesqueryNoticeByBizNo notification tasks and delivery records by business No.1
Audit logsqueryUnipayApiLog API logs, queryOperateLog operation logs, queryLoginLog login logs3

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.

AI assistant drawer

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.

AI assistant empty state

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.

SettingDescriptionDefault / range
Enable AI AssistantMaster switch; when off the entry is hidden and chat, regenerate, session query/rename/delete are all disabled; history is preservedOff on a fresh install; existing configs missing the field are treated as enabled
Service endpointOpenAI-compatible API base URL, e.g. https://open.bigmodel.cn/api/paas/v4Defaults to the Zhipu open-platform endpoint; required, must start with http(s)://
API KeyKey for the model service; leave blank to keep the saved key; masked on read (first and last 6 characters)Required (first time)
ModelModel identifier, e.g. glm-4.7, glm-5.3, deepseek-flashDefault glm-4.7
TemperatureSampling temperature; lower is more stable0~2, default 0.7
Top PLeave empty to omit0~1
Max output tokensMaximum tokens in the answer; leave empty to omit1~32768
Frequency / presence penaltyReduce repeated wording / encourage new topics; leave empty to omit-2~2
TimeoutPer-request timeout in milliseconds5000~300000, default 60000
Max retriesRetry attempts on failure0~5, default 2
Reasoning effortOnly effective for OpenAI reasoning models; leave empty to omitminimal / low / medium / high
Extra request paramsJSON 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 reasoningReceive and display reasoning_content from the modelOff by default

AI config

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 codePurpose
plugin:ai:viewShow/hide the top-bar entry; all chat, regenerate and session query/rename/delete endpoints
system:ai-config:viewView the AI Config page (tab visibility on the Platform Config page)
system:ai-config:manageSave 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 type ai) 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 (module AI对话), 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/status returns enabled and configured; the entry appears only when both are true.

API Reference ​

MethodPathDescription
GET/admin/ai/statusSwitch and configuration-completeness status (drives entry visibility)
POST/admin/ai/chatSynchronous chat (fallback when SSE is unavailable)
POST/admin/ai/chat/streamStreaming chat (SSE: meta / reasoning / tool / error)
POST/admin/ai/chat/regenerateRegenerate (synchronous)
POST/admin/ai/chat/regenerate/streamRegenerate (streaming)
GET/admin/ai/session/pageCurrent user's sessions, paged
GET/admin/ai/session/messagesSession messages (chronological)
POST/admin/ai/session/renameRename a session
POST/admin/ai/session/deleteDelete a session and all its messages
GET/platform/config/ai/getRead AI config (key masked)
POST/platform/config/ai/checkConnectivity check
POST/platform/config/ai/updateSave 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.