Chat and Statistics
WebUI's chat and statistics module includes built-in chat rooms, chat history, statistics dashboard, and data management functions for character information, expression methods, jargon, and emojis. These functions are distributed across multiple route modules.
Built-in Chat Room
WebUI provides an independent chat room where you can directly chat with MaiMai on the web page. The chat room uses independent platform identifiers (WEBUI_CHAT_PLATFORM) and group ID (WEBUI_CHAT_GROUP_ID), isolated from external platform messages.
GET /api/chat/history— Get chat history recordsGET /api/chat/platforms— Get available platform listGET /api/chat/persons— Get user list for specified platformDELETE /api/chat/history— Clear chat history recordsGET /api/chat/info— Get chat room information
Chat History
GET /api/chat/history supports the following parameters:
limit: Number of messages to return (1-200, default 50)group_id: Specify group ID (defaults to WebUI chat room group)
Chat Room Information
GET /api/chat/info returns basic information about the current chat room:
bot_name: Robot nicknameplatform: WebUI platform identifiergroup_id: Chat room group IDactive_sessions: Number of currently active WebSocket connections
Statistics Dashboard
The statistics module provides visual statistics for model usage, costs, Token consumption, and other data.
GET /statistics/dashboard— Get complete dashboard dataGET /statistics/summary— Get statistics summaryGET /statistics/models— Get model dimension statistics
Dashboard Data
GET /statistics/dashboard accepts hours parameter (default 24) and returns the following data:
Summary Statistics (StatisticsSummary):
total_requests— Total number of requeststotal_cost— Total costtotal_tokens— Total number of tokensonline_time— Online time (seconds)total_messages— Total number of messagestotal_replies— Total number of repliesavg_response_time— Average response timecost_per_hour— Cost per hourtokens_per_hour— Tokens per hour
Model Statistics: Aggregate requests, costs, tokens, and average response time by model, returning up to the top 10 models.
Time Series:
hourly_data: Hourly data (within specified time range)daily_data: Daily data (last 7 days)
Each time point contains three metrics: requests, cost, tokens, and missing time periods will be filled with zeros.
Recent Activity: The last 10 model call records, including time, model, request type, token count, cost, and response time.
Character Information Management
The character information module manages all user data that MaiBot knows.
GET /person/list— Get character list (pagination, search, filtering)GET /person/{person_id}— Get character detailsPATCH /person/{person_id}— Incrementally update character informationDELETE /person/{person_id}— Delete characterGET /person/stats/summary— Get character statistics summaryPOST /person/batch/delete— Batch delete characters
List Query Parameters
GET /person/list supports the following filter conditions:
page/page_size: Pagination (1-100 items per page)search: Search keywords (match name, nickname, user ID)is_known: Filter by whether knownplatform: Filter by platform
Character Information Fields
person_id— Character unique IDperson_name— Namenickname— Nicknameplatform— Belonging platformuser_id— Platform user IDis_known— Whether knownmemory_points— Memory pointsknow_times— Number of times knownknow_since— First known timelast_know— Last interaction timegroup_nick_name— List of group nicknames
Statistics Summary
GET /person/stats/summary returns the following data:
total: Total number of peopleknown: Number of known peopleunknown: Number of unknown peopleplatforms: Distribution of people by platform
Incremental updates (PATCH) only update submitted fields and automatically update last_known_time.
Expression Method Management
Expression methods record MaiBot's speaking style in different scenarios.
GET /expression/chats— Get chat list (for dropdown selection)GET /expression/list— Get expression method listGET /expression/{expression_id}— Get expression method detailsPOST /expression/— Create expression methodPATCH /expression/{expression_id}— Incrementally update expression methodDELETE /expression/{expression_id}— Delete expression methodPOST /expression/batch/delete— Batch deleteGET /expression/stats/summary— Get statistics
Expression Method Fields
situation— Scenario description (when to use this expression)style— Expression style (specific speaking style)chat_id— Belonging chat sessionlast_active_time— Last active timecreate_date— Creation time
Review Function
GET /expression/review/stats— Get review statisticsGET /expression/review/list— Get review listPOST /expression/review/batch— Batch review
The review list supports filtering by unchecked (unchecked), passed (passed), rejected (rejected), all (all).
Jargon Management
The jargon module manages network terms and niche circle terminology that MaiBot has learned.
GET /jargon/chats— Get chat list with jargon recordsGET /jargon/list— Get jargon listGET /jargon/{jargon_id}— Get jargon detailsGET /jargon/stats/summary— Get statisticsPOST /jargon/— Create jargonPATCH /jargon/{jargon_id}— Incrementally update jargonDELETE /jargon/{jargon_id}— Delete jargonPOST /jargon/batch/delete— Batch deletePOST /jargon/batch/set-jargon— Batch set jargon confirmation status
Jargon Fields
content— Jargon contentraw_content— Raw contentmeaning— Meaning explanationchat_id— Belonging chatis_jargon— Whether confirmed as jargon (true/false/nullpending confirmation)is_complete— Whether information is completeinference_with_context— Inference result with contextinference_content_only— Inference result with content onlycount— Usage count
List Query
GET /jargon/list supports:
search: Search keywords (match content, meaning, raw content)chat_id: Filter by chatis_jargon: Filter by confirmation status (true/false/ not passed for all)
Statistics Summary
GET /jargon/stats/summary returns:
total: Total countconfirmed_jargon: Confirmed as jargonconfirmed_not_jargon: Confirmed not jargonpending: Pending confirmationcomplete_count: Complete information countchat_count: Number of chats involvedtop_chats: Top 5 chats with most jargon
Emoji Management
The emoji module manages emojis collected and used by MaiBot.
GET /emoji/list— Get emoji listGET /emoji/{emoji_id}— Get emoji detailsPATCH /emoji/{emoji_id}— Incrementally update emojiDELETE /emoji/{emoji_id}— Delete emojiGET /emoji/stats/summary— Get statisticsPOST /emoji/{emoji_id}/register— Register emojiPOST /emoji/{emoji_id}/ban— Ban emojiGET /emoji/{emoji_id}/thumbnail— Get thumbnailPOST /emoji/upload— Upload emojiPOST /emoji/batch/upload— Batch uploadPOST /emoji/batch/delete— Batch delete
List Query
GET /emoji/list supports:
search: Search keywords (match description, hash value)status: Filter by unified emoji status (known/unknown/adopted/discarded)format: Filter by file format (JPEG/PNG/GIF/WebP)sort_by: Sort field (query_count/register_time/record_time/last_used_time)sort_order: Sort direction (asc/desc)
Emoji Status
Emojis have four WebUI statuses:
- Known (
known): Has a description, but is not registered or banned - Unknown (
unknown): Has no description yet, and is not registered or banned - Adopted (
adopted): Registered and usable by MaiBot - Discarded (
discarded): Banned and unavailable
Manual uploads from WebUI are registered immediately as Adopted. If the uploaded image already exists in the database, WebUI reuses the existing record, updates its description from the submitted tags, clears the ban flag, and marks it as registered. Deleting an unregistered emoji removes both the local file and database record; deleting a registered emoji unloads it first, then removes the file and record.
Thumbnail Cache
GET /emoji/thumbnail-cache/stats— Thumbnail cache statisticsPOST /emoji/thumbnail-cache/cleanup— Clean up orphaned cachePOST /emoji/thumbnail-cache/preheat— Preheat cache (generate by usage frequency priority)DELETE /emoji/thumbnail-cache/clear— Clear all cache
Thumbnails are cached in WebP format. If cache doesn't exist when getting, it will be generated asynchronously in the background, and clients need to retry according to 202 status code + Retry-After header. Supported image formats: JPEG, PNG, GIF, WebP.
Upload Restrictions
- Supported formats: JPEG, PNG, GIF, WebP
- Upload will verify image validity through PIL
- Duplicate files (MD5 hash) are not allowed to be uploaded repeatedly