Files
group_xinghuo_jinrong/app/gateway/visitor_deps.py
T
zhanghongyu_0626 b841f68295 feat(visitor): Implement visitor chat functionality and enhance customer service interactions
- Added a new visitor chat API endpoint (`/api/chat/visitor`) to allow unauthenticated users to engage in conversations without requiring customer data.
- Introduced a visitor context dependency to manage visitor interactions seamlessly.
- Enhanced the chat API to support explicit session termination and improved response handling for customer service interactions.
- Updated the database configuration to include Redis client support for caching visitor data.
- Added a new customer note repository to persist user notes independently of the L1 profile slots.

This update significantly improves the customer service experience by enabling visitor interactions and ensuring efficient data handling for both registered and unregistered users.
2026-09-09 18:32:00 +08:00

26 lines
674 B
Python

"""游客免认证依赖:构造受限 AuthContext。"""
from __future__ import annotations
import uuid
from fastapi import Request
from app.model.schemas import AuthContext
def get_visitor_context(request: Request) -> AuthContext:
"""构造游客受限上下文,不走 JWT 鉴权,不调 assert_agent_access。"""
trace_id = getattr(request.state, "trace_id", None) or str(uuid.uuid4())
return AuthContext(
sub="visitor",
token_type="visitor",
roles=[],
permissions=[],
tenant_id="default",
trace_id=trace_id,
agent_type="visitor",
jti=str(uuid.uuid4()),
customer_id=None,
)