mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
feat: add immediate context compaction API, UI button, and /compact slash command
- Add POST /bots/:bot_id/sessions/:session_id/compact endpoint for synchronous context compaction with fallback to chat model when no dedicated compaction model is configured - Add "Compact Now" button to session info panel in the web UI - Add /compact slash command for triggering compaction from chat - Regenerate OpenAPI spec and TypeScript SDK
This commit is contained in:
+59
-6
@@ -4395,6 +4395,51 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bots/{bot_id}/sessions/{session_id}/compact": {
|
||||
"post": {
|
||||
"description": "Run context compaction synchronously for a session",
|
||||
"tags": [
|
||||
"compaction"
|
||||
],
|
||||
"summary": "Trigger immediate context compaction",
|
||||
"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
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.TriggerCompactResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bots/{bot_id}/sessions/{session_id}/status": {
|
||||
"get": {
|
||||
"description": "Get aggregated info for a chat session including message count, context usage, cache stats, and used skills",
|
||||
@@ -11357,6 +11402,20 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.TriggerCompactResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message_count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"summary": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.createSessionRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -12678,9 +12737,6 @@ const docTemplate = `{
|
||||
"compaction_threshold": {
|
||||
"type": "integer"
|
||||
},
|
||||
"context_token_budget": {
|
||||
"type": "integer"
|
||||
},
|
||||
"discuss_probe_model_id": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -12749,9 +12805,6 @@ const docTemplate = `{
|
||||
"compaction_threshold": {
|
||||
"type": "integer"
|
||||
},
|
||||
"context_token_budget": {
|
||||
"type": "integer"
|
||||
},
|
||||
"discuss_probe_model_id": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
+59
-6
@@ -4386,6 +4386,51 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bots/{bot_id}/sessions/{session_id}/compact": {
|
||||
"post": {
|
||||
"description": "Run context compaction synchronously for a session",
|
||||
"tags": [
|
||||
"compaction"
|
||||
],
|
||||
"summary": "Trigger immediate context compaction",
|
||||
"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
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.TriggerCompactResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.ErrorResponse"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/handlers.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/bots/{bot_id}/sessions/{session_id}/status": {
|
||||
"get": {
|
||||
"description": "Get aggregated info for a chat session including message count, context usage, cache stats, and used skills",
|
||||
@@ -11348,6 +11393,20 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.TriggerCompactResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"message_count": {
|
||||
"type": "integer"
|
||||
},
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"summary": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"handlers.createSessionRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -12669,9 +12728,6 @@
|
||||
"compaction_threshold": {
|
||||
"type": "integer"
|
||||
},
|
||||
"context_token_budget": {
|
||||
"type": "integer"
|
||||
},
|
||||
"discuss_probe_model_id": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -12740,9 +12796,6 @@
|
||||
"compaction_threshold": {
|
||||
"type": "integer"
|
||||
},
|
||||
"context_token_budget": {
|
||||
"type": "integer"
|
||||
},
|
||||
"discuss_probe_model_id": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
+39
-4
@@ -1780,6 +1780,15 @@ definitions:
|
||||
$ref: '#/definitions/handlers.DailyTokenUsage'
|
||||
type: array
|
||||
type: object
|
||||
handlers.TriggerCompactResponse:
|
||||
properties:
|
||||
message_count:
|
||||
type: integer
|
||||
status:
|
||||
type: string
|
||||
summary:
|
||||
type: string
|
||||
type: object
|
||||
handlers.createSessionRequest:
|
||||
properties:
|
||||
channel_type:
|
||||
@@ -2659,8 +2668,6 @@ definitions:
|
||||
type: integer
|
||||
compaction_threshold:
|
||||
type: integer
|
||||
context_token_budget:
|
||||
type: integer
|
||||
discuss_probe_model_id:
|
||||
type: string
|
||||
heartbeat_enabled:
|
||||
@@ -2706,8 +2713,6 @@ definitions:
|
||||
type: integer
|
||||
compaction_threshold:
|
||||
type: integer
|
||||
context_token_budget:
|
||||
type: integer
|
||||
discuss_probe_model_id:
|
||||
type: string
|
||||
heartbeat_enabled:
|
||||
@@ -5766,6 +5771,36 @@ paths:
|
||||
summary: Update a session
|
||||
tags:
|
||||
- sessions
|
||||
/bots/{bot_id}/sessions/{session_id}/compact:
|
||||
post:
|
||||
description: Run context compaction synchronously for a session
|
||||
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
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.TriggerCompactResponse'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ErrorResponse'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/handlers.ErrorResponse'
|
||||
summary: Trigger immediate context compaction
|
||||
tags:
|
||||
- compaction
|
||||
/bots/{bot_id}/sessions/{session_id}/status:
|
||||
get:
|
||||
description: Get aggregated info for a chat session including message count,
|
||||
|
||||
Reference in New Issue
Block a user