mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-10-14 05:00:08 +00:00
Redact AI Buddy request parameters in operation logs (#1269)
This commit is contained in:
@@ -244,6 +244,7 @@ class Settings(BaseSettings):
|
||||
'old_password',
|
||||
'new_password',
|
||||
'confirm_password',
|
||||
'secret',
|
||||
]
|
||||
OPERA_LOG_QUEUE_MAXSIZE: int = 100000
|
||||
OPERA_LOG_QUEUE_BATCH_CONSUME_SIZE: int = 100
|
||||
|
||||
@@ -133,6 +133,12 @@ class OperaLogMiddleware(BaseHTTPMiddleware):
|
||||
:return:
|
||||
"""
|
||||
args = {}
|
||||
# 用于 ai-buddy 插件,避免交互输入、聊天和图像生成请求中的敏感内容写入操作日志
|
||||
if '/input-requests/' in request.url.path or request.url.path.endswith((
|
||||
'/chat/completions',
|
||||
'/images/generations',
|
||||
)):
|
||||
return {'body': '[REDACTED]'}
|
||||
|
||||
# 查询参数
|
||||
query_params = dict(request.query_params)
|
||||
|
||||
Reference in New Issue
Block a user