mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
feat(usage): add per-call token usage records table
Expose a paginated endpoint and UI table that lists individual LLM call records (assistant messages with usage) per bot, showing time, session type, model, provider, and token counts. Respects existing date / model / session-type filters and adds full-height loaders plus a max-width layout to keep the usage page consistent with other top-level pages.
This commit is contained in:
@@ -2016,6 +2016,44 @@ definitions:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
handlers.TokenUsageRecord:
|
||||
properties:
|
||||
cache_read_tokens:
|
||||
type: integer
|
||||
cache_write_tokens:
|
||||
type: integer
|
||||
created_at:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
input_tokens:
|
||||
type: integer
|
||||
model_id:
|
||||
type: string
|
||||
model_name:
|
||||
type: string
|
||||
model_slug:
|
||||
type: string
|
||||
output_tokens:
|
||||
type: integer
|
||||
provider_name:
|
||||
type: string
|
||||
reasoning_tokens:
|
||||
type: integer
|
||||
session_id:
|
||||
type: string
|
||||
session_type:
|
||||
type: string
|
||||
type: object
|
||||
handlers.TokenUsageRecordsResponse:
|
||||
properties:
|
||||
items:
|
||||
items:
|
||||
$ref: '#/definitions/handlers.TokenUsageRecord'
|
||||
type: array
|
||||
total:
|
||||
type: integer
|
||||
type: object
|
||||
handlers.TokenUsageResponse:
|
||||
properties:
|
||||
by_model:
|
||||
@@ -6232,6 +6270,65 @@ paths:
|
||||
summary: Get token usage statistics
|
||||
tags:
|
||||
- token-usage
|
||||
/bots/{bot_id}/token-usage/records:
|
||||
get:
|
||||
description: Paginated list of individual LLM call records (assistant messages
|
||||
with usage) for a bot, with optional model and session type filters
|
||||
parameters:
|
||||
- description: Bot ID
|
||||
in: path
|
||||
name: bot_id
|
||||
required: true
|
||||
type: string
|
||||
- description: Start date (YYYY-MM-DD)
|
||||
in: query
|
||||
name: from
|
||||
required: true
|
||||
type: string
|
||||
- description: End date exclusive (YYYY-MM-DD)
|
||||
in: query
|
||||
name: to
|
||||
required: true
|
||||
type: string
|
||||
- description: Optional model UUID to filter by
|
||||
in: query
|
||||
name: model_id
|
||||
type: string
|
||||
- description: 'Optional session type: chat, heartbeat, or schedule'
|
||||
in: query
|
||||
name: session_type
|
||||
type: string
|
||||
- description: Page size (default 20, max 100)
|
||||
in: query
|
||||
name: limit
|
||||
type: integer
|
||||
- default: 0
|
||||
description: Offset
|
||||
in: query
|
||||
name: offset
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.TokenUsageRecordsResponse'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ErrorResponse'
|
||||
"403":
|
||||
description: Forbidden
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ErrorResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ErrorResponse'
|
||||
summary: List per-call token usage records
|
||||
tags:
|
||||
- token-usage
|
||||
/bots/{bot_id}/tools:
|
||||
post:
|
||||
description: MCP endpoint for tool discovery and invocation.
|
||||
|
||||
Reference in New Issue
Block a user