mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
feat: add session info panel with message count, context usage, cache stats, and skills
Add GET /bots/:bot_id/sessions/:session_id/info API endpoint that returns per-session message count, latest input token usage with model context window, aggregated KV cache hit rate, and skills invoked via use_skill tool calls. Frontend Info tab in the right sidebar now displays this data in a compact key-value layout with a context usage progress bar and clickable skill links.
This commit is contained in:
+105
@@ -4395,6 +4395,63 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bots/{bot_id}/sessions/{session_id}/info": {
|
||||
"get": {
|
||||
"description": "Get aggregated info for a chat session including message count, context usage, cache stats, and used skills",
|
||||
"tags": [
|
||||
"sessions"
|
||||
],
|
||||
"summary": "Get session info",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Bot ID",
|
||||
"name": "bot_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Session ID",
|
||||
"name": "session_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Optional model UUID override for context window",
|
||||
"name": "model_id",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.SessionInfoResponse"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bots/{bot_id}/settings": {
|
||||
"get": {
|
||||
"description": "Get agent settings for current user",
|
||||
@@ -10875,6 +10932,23 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.CacheStats": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cache_hit_rate": {
|
||||
"type": "number"
|
||||
},
|
||||
"cache_read_tokens": {
|
||||
"type": "integer"
|
||||
},
|
||||
"cache_write_tokens": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total_input_tokens": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.ChannelMeta": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -10901,6 +10975,17 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.ContextUsage": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context_window": {
|
||||
"type": "integer"
|
||||
},
|
||||
"used_tokens": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.CreateContainerRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -11359,6 +11444,26 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.SessionInfoResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cache_stats": {
|
||||
"$ref": "#/definitions/handlers.CacheStats"
|
||||
},
|
||||
"context_usage": {
|
||||
"$ref": "#/definitions/handlers.ContextUsage"
|
||||
},
|
||||
"message_count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"skills": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.SkillItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -4386,6 +4386,63 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bots/{bot_id}/sessions/{session_id}/info": {
|
||||
"get": {
|
||||
"description": "Get aggregated info for a chat session including message count, context usage, cache stats, and used skills",
|
||||
"tags": [
|
||||
"sessions"
|
||||
],
|
||||
"summary": "Get session info",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Bot ID",
|
||||
"name": "bot_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Session ID",
|
||||
"name": "session_id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Optional model UUID override for context window",
|
||||
"name": "model_id",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.SessionInfoResponse"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bots/{bot_id}/settings": {
|
||||
"get": {
|
||||
"description": "Get agent settings for current user",
|
||||
@@ -10866,6 +10923,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.CacheStats": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cache_hit_rate": {
|
||||
"type": "number"
|
||||
},
|
||||
"cache_read_tokens": {
|
||||
"type": "integer"
|
||||
},
|
||||
"cache_write_tokens": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total_input_tokens": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.ChannelMeta": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -10892,6 +10966,17 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.ContextUsage": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context_window": {
|
||||
"type": "integer"
|
||||
},
|
||||
"used_tokens": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.CreateContainerRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -11350,6 +11435,26 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.SessionInfoResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cache_stats": {
|
||||
"$ref": "#/definitions/handlers.CacheStats"
|
||||
},
|
||||
"context_usage": {
|
||||
"$ref": "#/definitions/handlers.ContextUsage"
|
||||
},
|
||||
"message_count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"skills": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.SkillItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -1190,6 +1190,17 @@ definitions:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
handlers.CacheStats:
|
||||
properties:
|
||||
cache_hit_rate:
|
||||
type: number
|
||||
cache_read_tokens:
|
||||
type: integer
|
||||
cache_write_tokens:
|
||||
type: integer
|
||||
total_input_tokens:
|
||||
type: integer
|
||||
type: object
|
||||
handlers.ChannelMeta:
|
||||
properties:
|
||||
capabilities:
|
||||
@@ -1207,6 +1218,13 @@ definitions:
|
||||
user_config_schema:
|
||||
$ref: '#/definitions/channel.ConfigSchema'
|
||||
type: object
|
||||
handlers.ContextUsage:
|
||||
properties:
|
||||
context_window:
|
||||
type: integer
|
||||
used_tokens:
|
||||
type: integer
|
||||
type: object
|
||||
handlers.CreateContainerRequest:
|
||||
properties:
|
||||
image:
|
||||
@@ -1503,6 +1521,19 @@ definitions:
|
||||
version:
|
||||
type: integer
|
||||
type: object
|
||||
handlers.SessionInfoResponse:
|
||||
properties:
|
||||
cache_stats:
|
||||
$ref: '#/definitions/handlers.CacheStats'
|
||||
context_usage:
|
||||
$ref: '#/definitions/handlers.ContextUsage'
|
||||
message_count:
|
||||
type: integer
|
||||
skills:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
handlers.SkillItem:
|
||||
properties:
|
||||
content:
|
||||
@@ -5655,6 +5686,45 @@ paths:
|
||||
summary: Update a session
|
||||
tags:
|
||||
- sessions
|
||||
/bots/{bot_id}/sessions/{session_id}/info:
|
||||
get:
|
||||
description: Get aggregated info for a chat session including message count,
|
||||
context usage, cache stats, and used skills
|
||||
parameters:
|
||||
- description: Bot ID
|
||||
in: path
|
||||
name: bot_id
|
||||
required: true
|
||||
type: string
|
||||
- description: Session ID
|
||||
in: path
|
||||
name: session_id
|
||||
required: true
|
||||
type: string
|
||||
- description: Optional model UUID override for context window
|
||||
in: query
|
||||
name: model_id
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.SessionInfoResponse'
|
||||
"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: Get session info
|
||||
tags:
|
||||
- sessions
|
||||
/bots/{bot_id}/settings:
|
||||
delete:
|
||||
description: Remove agent settings for current user
|
||||
|
||||
Reference in New Issue
Block a user