Skip to content

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.

EndpointDescription
GET /api/chat/historyGet chat history records
GET /api/chat/platformsGet available platform list
GET /api/chat/personsGet user list for specified platform
DELETE /api/chat/historyClear chat history records
GET /api/chat/infoGet 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 nickname
  • platform: WebUI platform identifier
  • group_id: Chat room group ID
  • active_sessions: Number of currently active WebSocket connections

Statistics Dashboard

The statistics module provides visual statistics for model usage, costs, Token consumption, and other data.

EndpointDescription
GET /statistics/dashboardGet complete dashboard data
GET /statistics/summaryGet statistics summary
GET /statistics/modelsGet model dimension statistics

Dashboard Data

GET /statistics/dashboard accepts hours parameter (default 24) and returns the following data:

Summary Statistics (StatisticsSummary):

MetricDescription
total_requestsTotal number of requests
total_costTotal cost
total_tokensTotal number of tokens
online_timeOnline time (seconds)
total_messagesTotal number of messages
total_repliesTotal number of replies
avg_response_timeAverage response time
cost_per_hourCost per hour
tokens_per_hourTokens 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.

EndpointDescription
GET /person/listGet character list (pagination, search, filtering)
GET /person/{person_id}Get character details
PATCH /person/{person_id}Incrementally update character information
DELETE /person/{person_id}Delete character
GET /person/stats/summaryGet character statistics summary
POST /person/batch/deleteBatch 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 known
  • platform: Filter by platform

Character Information Fields

FieldDescription
person_idCharacter unique ID
person_nameName
nicknameNickname
platformBelonging platform
user_idPlatform user ID
is_knownWhether known
memory_pointsMemory points
know_timesNumber of times known
know_sinceFirst known time
last_knowLast interaction time
group_nick_nameList of group nicknames

Statistics Summary

GET /person/stats/summary returns the following data:

  • total: Total number of people
  • known: Number of known people
  • unknown: Number of unknown people
  • platforms: 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.

EndpointDescription
GET /expression/chatsGet chat list (for dropdown selection)
GET /expression/listGet expression method list
GET /expression/{expression_id}Get expression method details
POST /expression/Create expression method
PATCH /expression/{expression_id}Incrementally update expression method
DELETE /expression/{expression_id}Delete expression method
POST /expression/batch/deleteBatch delete
GET /expression/stats/summaryGet statistics

Expression Method Fields

FieldDescription
situationScenario description (when to use this expression)
styleExpression style (specific speaking style)
chat_idBelonging chat session
last_active_timeLast active time
create_dateCreation time

Review Function

EndpointDescription
GET /expression/review/statsGet review statistics
GET /expression/review/listGet review list
POST /expression/review/batchBatch 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.

EndpointDescription
GET /jargon/chatsGet chat list with jargon records
GET /jargon/listGet jargon list
GET /jargon/{jargon_id}Get jargon details
GET /jargon/stats/summaryGet statistics
POST /jargon/Create jargon
PATCH /jargon/{jargon_id}Incrementally update jargon
DELETE /jargon/{jargon_id}Delete jargon
POST /jargon/batch/deleteBatch delete
POST /jargon/batch/set-jargonBatch set jargon confirmation status

Jargon Fields

FieldDescription
contentJargon content
raw_contentRaw content
meaningMeaning explanation
chat_idBelonging chat
is_jargonWhether confirmed as jargon (true / false / null pending confirmation)
is_completeWhether information is complete
inference_with_contextInference result with context
inference_content_onlyInference result with content only
countUsage count

List Query

GET /jargon/list supports:

  • search: Search keywords (match content, meaning, raw content)
  • chat_id: Filter by chat
  • is_jargon: Filter by confirmation status (true / false / not passed for all)

Statistics Summary

GET /jargon/stats/summary returns:

  • total: Total count
  • confirmed_jargon: Confirmed as jargon
  • confirmed_not_jargon: Confirmed not jargon
  • pending: Pending confirmation
  • complete_count: Complete information count
  • chat_count: Number of chats involved
  • top_chats: Top 5 chats with most jargon

Emoji Management

The emoji module manages emojis collected and used by MaiBot.

EndpointDescription
GET /emoji/listGet emoji list
GET /emoji/{emoji_id}Get emoji details
PATCH /emoji/{emoji_id}Incrementally update emoji
DELETE /emoji/{emoji_id}Delete emoji
GET /emoji/stats/summaryGet statistics
POST /emoji/{emoji_id}/registerRegister emoji
POST /emoji/{emoji_id}/banBan emoji
GET /emoji/{emoji_id}/thumbnailGet thumbnail
POST /emoji/uploadUpload emoji
POST /emoji/batch/uploadBatch upload
POST /emoji/batch/deleteBatch delete

List Query

GET /emoji/list supports:

  • search: Search keywords (match description, hash value)
  • is_registered: Filter by registration status
  • is_banned: Filter by ban status
  • sort_by: Sort field (query_count / register_time / record_time / last_used_time)
  • sort_order: Sort direction (asc / desc)

Emoji Status

Emojis have three statuses:

  • Registered (is_registered=true): Can be used by MaiMai
  • Unregistered (is_registered=false, is_banned=false): Collected but not enabled
  • Banned (is_banned=true): Marked as unavailable

Thumbnail Cache

EndpointDescription
GET /emoji/thumbnail-cache/statsThumbnail cache statistics
POST /emoji/thumbnail-cache/cleanupClean up orphaned cache
POST /emoji/thumbnail-cache/preheatPreheat cache (generate by usage frequency priority)
DELETE /emoji/thumbnail-cache/clearClear 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