feat: 后台一键刷新飞书缓存

- feishu_service.py: FeishuKnowledgeService 新增 clear_cache() 方法
- admin_settings.py: 新增 POST /admin/feishu/cache/clear API
- api.ts: 前端封装 clearFeishuCache API
- App.vue: Agent管理页面新增'刷新飞书缓存'按钮

管理员更新飞书文档后,点击按钮即可清空服务端内存缓存,
客户端下次提问时会重新读取最新内容。
This commit is contained in:
2026-07-08 17:57:26 +08:00
parent 61db0aa9b8
commit 5dfff52b04
4 changed files with 25 additions and 0 deletions

View File

@@ -302,6 +302,12 @@ def _build_agent_debug_prompt(prompt_content: str, question: str, chunks: list)
return f"{prompt_content.strip()}\n\n{context}\n\n用户问题:{question.strip()}"
@router.post("/feishu/cache/clear")
def clear_feishu_cache(current_admin: Admin = Depends(get_current_admin)) -> dict:
count = FeishuKnowledgeService.clear_cache()
return api_success({"cleared": count, "message": f"已清空 {count} 条飞书缓存"})
def _config_dict(config: SystemConfig) -> dict:
return {
"id": config.id,

View File

@@ -323,6 +323,13 @@ class FeishuKnowledgeService:
_content_cache: dict[str, tuple[str, float]] = {}
_CACHE_TTL = 300 # 缓存 5 分钟
@classmethod
def clear_cache(cls) -> int:
"""清空所有飞书内容缓存,返回被清除的条目数"""
count = len(cls._content_cache)
cls._content_cache.clear()
return count
@classmethod
def retrieve(
cls,