kirara_ai/web/README.md
本系统提供了一套完整的RESTful API,用于管理和监控ChatGPT-Mirai机器人的各个组件。
framework/web/authframework/web/api/imframework/web/api/llmframework/web/api/dispatchframework/web/api/blockframework/web/api/workflowframework/web/api/pluginframework/web/api/systempip install -r requirements.txt
config.yaml.example 到 config.yamlpython main.py
首次启动时会自动创建管理员密码。
除了首次设置密码的接口外,所有API都需要在请求头中携带JWT令牌:
Authorization: Bearer <your-jwt-token>
获取令牌:
POST/backend-api/api/auth/login
Content-Type: application/json
{
"password": "your-password"
}
framework/web/app.py 中注册蓝图示例:
from quart import Blueprint, request
from pydantic import BaseModel
# 定义数据模型
class MyModel(BaseModel):
name: str
value: int
# 创建蓝图
my_bp = Blueprint('my_api', __name__)
# 实现API端点
@my_bp.route('/endpoint', methods=['POST'])
@require_auth
async def my_endpoint():
data = await request.get_json()
model = MyModel(**data)
# 处理逻辑
return model.model_dump()
使用HTTP状态码表示错误类型:
返回统一的错误格式:
{
"error": "错误描述信息"
}
主要依赖包:
完整依赖列表见 requirements.txt
运行单元测试:
pytest tests/web