feat: 添加数据库迁移、清空聊天记录按钮 - 复用SAVE_HISTORY接口

This commit is contained in:
root
2026-04-15 11:07:06 +08:00
parent adc7857344
commit b86610d445
6 changed files with 73 additions and 13 deletions

View File

@ -198,3 +198,21 @@ def test_get_chat_records_default_limit(db):
history_default = db.get_chat_records()
assert len(history_default) == 100
def test_clear_chat_records(db):
"""测试清空聊天记录"""
db.save_chat_records([
{"role": "user", "content": "测试1"},
{"role": "assistant", "content": "回复1"},
{"role": "user", "content": "测试2"},
])
history = db.get_chat_records()
assert len(history) == 3
result = db.clear_chat_records()
assert result["cleared"] is True
history_after = db.get_chat_records()
assert len(history_after) == 0