perf: Assistant api

This commit is contained in:
fit2cloud-chenyw
2025-07-22 16:35:13 +08:00
parent 7bf541864e
commit 7835678967
2 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ async def info(session: SessionDep, id: str, virtual: Optional[int] = Query(None
@router.get("", response_model=list[AssistantModel])
async def query(session: SessionDep):
list_result = session.exec(select(AssistantModel).order_by(AssistantModel.create_time)).all()
list_result = session.exec(select(AssistantModel).order_by(AssistantModel.create_time.asc())).all()
return list_result
@router.post("")
+7 -5
View File
@@ -164,11 +164,13 @@ def clear_cache(
)
async with _get_cache_lock(cache_key):
await FastAPICache.clear(key=cache_key)
result = await func(*args, **kwargs)
logging.info(f"Clearing cache for key: {cache_key}")
print(f"Clearing cache for key: {cache_key}")
return result
if await FastAPICache.get_backend().get(cache_key):
await FastAPICache.clear(key=cache_key)
result = await func(*args, **kwargs)
logging.info(f"Clearing cache for key: {cache_key}")
print(f"Clearing cache for key: {cache_key}")
return result
return await func(*args, **kwargs)
return wrapper
return decorator