v3.1 + 批次0: 智能回复重构基线 - ApprovalMatcher + 关键词降级 + 文档速修 + v4.0任务书面化

This commit is contained in:
Simon
2026-07-17 23:08:59 +08:00
parent 5a77a89ab1
commit 3ed86d5fb3
181 changed files with 19738 additions and 2655 deletions
+23 -4
View File
@@ -16,7 +16,7 @@ from functools import wraps
from typing import List, Optional, Union
import redis.asyncio as aioredis
from fastapi import Depends, HTTPException, status
from fastapi import Depends, HTTPException, Request, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from app.config import settings
@@ -145,13 +145,13 @@ def dep_ai_handler():
def dep_wingman_service():
"""WingmanService 依赖注入。
"""WingmanService 依赖注入(含 Redis 支持)
Returns:
WingmanService: AI Wingman 服务实例
WingmanService: AI Wingman 服务实例(含 Redis 缓存支持)
"""
from app.services.wingman_service import WingmanService
return WingmanService()
return WingmanService(redis_client=settings.create_redis_client())
def dep_neo4j_client():
@@ -203,6 +203,7 @@ TOKEN_BLACKLIST_PREFIX = "token:blacklist:"
async def get_current_user(
credentials: HTTPAuthorizationCredentials = Depends(security),
request: Request = None,
) -> UserInfo:
"""统一认证依赖:从 Token 获取用户信息。
@@ -210,6 +211,7 @@ async def get_current_user(
Args:
credentials: HTTP Bearer Token
request: 请求对象(可选,用于获取客户端IP记录)
Returns:
UserInfo: 用户信息
@@ -245,6 +247,23 @@ async def get_current_user(
headers={"WWW-Authenticate": "Bearer"},
)
# 记录Token使用的IP(用于异常检测)
# 只有在能获取到IP时才记录
if request:
try:
# 优先从 X-Forwarded-For 获取真实IP
client_ip = request.headers.get("X-Forwarded-For", "")
if client_ip:
client_ip = client_ip.split(",")[0].strip()
else:
client_ip = request.client.host if request.client else None
if client_ip:
await token_service.record_token_ip(token, client_ip)
except Exception as e:
# IP记录失败不影响主流程
logger.debug(f"记录Token IP失败(不影响认证): {e}")
return UserInfo(
employee_id=user_info["employee_id"],
name=user_info.get("name", ""),