kirara_ai/web/api/system/README.md
系统管理 API 提供了监控和管理系统状态的功能。
GET/backend-api/api/system/status
获取系统的当前运行状态,包括版本信息、运行时间、资源使用情况等。
响应示例:
{
"status": {
"version": "1.0.0",
"uptime": 3600, // 运行时间(秒)
"active_adapters": 2, // 活跃的 IM 适配器数量
"active_backends": 3, // 活跃的 LLM 后端数量
"loaded_plugins": 5, // 已加载的插件数量
"workflow_count": 10, // 工作流数量
"memory_usage": {
"rss": 256.5, // 物理内存使用(MB)
"vms": 512.8, // 虚拟内存使用(MB)
"percent": 2.5 // 内存使用百分比
},
"cpu_usage": 1.2 // CPU 使用百分比
}
}
GET/backend-api/api/system/config
获取系统当前配置。
PUT/backend-api/api/system/config
更新系统配置。
请求体:
{
"log_level": "INFO",
"max_connections": 100,
"timeout": 30,
"storage": {
"type": "local",
"path": "/data"
}
}
GET/backend-api/api/system/logs
获取系统日志。支持分页和过滤。
查询参数:
level: 日志级别 (DEBUG/INFO/WARNING/ERROR)start_time: 开始时间end_time: 结束时间limit: 每页条数offset: 偏移量GET/backend-api/api/system/users
获取系统用户列表。
POST/backend-api/api/system/users
创建新用户。
请求体:
{
"username": "admin",
"password": "password123",
"role": "admin",
"permissions": ["read", "write", "admin"]
}
PUT/backend-api/api/system/users/{username}
更新用户信息。
DELETE/backend-api/api/system/users/{username}
删除指定用户。
version: 系统版本uptime: 运行时间(秒)active_adapters: 活跃的 IM 适配器数量active_backends: 活跃的 LLM 后端数量loaded_plugins: 已加载的插件数量workflow_count: 工作流数量memory_usage: 内存使用情况
rss: 物理内存使用(MB)vms: 虚拟内存使用(MB)percent: 内存使用百分比cpu_usage: CPU 使用百分比log_level: 日志级别max_connections: 最大连接数timeout: 超时时间(秒)storage: 存储配置username: 用户名role: 角色permissions: 权限列表created_at: 创建时间last_login: 最后登录时间所有 API 端点在发生错误时都会返回适当的 HTTP 状态码和错误信息:
{
"error": "错误描述信息"
}
常见状态码:
import requests
response = requests.get(
'http://localhost:8080/api/system/status',
headers={'Authorization': f'Bearer {token}'}
)
status = response.json()['status']
print(f"系统已运行: {status['uptime']} 秒")
print(f"内存使用: {status['memory_usage']['percent']}%")
print(f"CPU 使用: {status['cpu_usage']}%")
import requests
config_data = {
"log_level": "DEBUG",
"max_connections": 200,
"timeout": 60
}
response = requests.put(
'http://localhost:8080/api/system/config',
headers={'Authorization': f'Bearer {token}'},
json=config_data
)
import requests
user_data = {
"username": "admin",
"password": "password123",
"role": "admin",
"permissions": ["read", "write", "admin"]
}
response = requests.post(
'http://localhost:8080/api/system/users',
headers={'Authorization': f'Bearer {token}'},
json=user_data
)