fix(search): 将搜索历史持久化到应用数据库

This commit is contained in:
2026-09-04 19:33:43 +08:00
parent a71cd1d0bf
commit 5234f20522
8 changed files with 117 additions and 41 deletions
+15
View File
@@ -303,9 +303,24 @@ async def rename_note(note_id: str, request: NoteRenameRequest) -> Note:
# Retrieval and chat
@router.post("/search", response_model=SearchResponse, tags=["Search"])
async def search_notes(request: SearchRequest) -> SearchResponse:
from app.services import search_history
search_history.record(request.query)
return await engine.search(request)
@router.get("/search/history", tags=["Search"])
async def get_search_history() -> dict[str, list[str]]:
from app.services import search_history
return {"queries": search_history.list_queries()}
@router.delete("/search/history", tags=["Search"])
async def clear_search_history() -> dict[str, list[str]]:
from app.services import search_history
search_history.clear()
return {"queries": []}
@router.post(
"/chat",
response_class=StreamingResponse,