423baff73b
- Docker bridge 网络隔离(8000 端口封死) - Gunicorn 4 Worker 多进程 - Alembic 数据库迁移基线 - 日志轮转 20m×3 - JWT 密钥 + DB 密码 + CORS 收紧 - 3-2-1 备份链路(NAS + R740-B 冷备) - 连接池 pool_pre_ping + pool_recycle=3600
82 lines
3.1 KiB
Python
82 lines
3.1 KiB
Python
"""
|
||
V5.0 AI 画像强约束 Pydantic Schema
|
||
- CompanyPersona: 企业级画像 (crm_customers.ai_persona)
|
||
- BuyerPersona: 联系人级画像 (crm_contacts.ai_buyer_persona)
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
from pydantic import BaseModel, Field
|
||
|
||
|
||
# ═══════════════════════════════════════════════════════
|
||
# 企业画像 (crm_customers.ai_persona)
|
||
# ═══════════════════════════════════════════════════════
|
||
|
||
class Firmographics(BaseModel):
|
||
"""企业属性"""
|
||
industry: str | None = None
|
||
scale: str | None = None
|
||
business_model: str | None = None
|
||
|
||
|
||
class DynamicStatus(BaseModel):
|
||
"""时序动态"""
|
||
pain_points: list[str] = Field(default_factory=list)
|
||
purchase_intent: str | None = None
|
||
recent_events: list[str] = Field(default_factory=list)
|
||
|
||
|
||
class CompanyPersona(BaseModel):
|
||
"""企业级 AI 画像 Schema"""
|
||
firmographics: Firmographics = Field(default_factory=Firmographics)
|
||
dynamic_status: DynamicStatus = Field(default_factory=DynamicStatus)
|
||
summary: str | None = None
|
||
|
||
|
||
# ═══════════════════════════════════════════════════════
|
||
# 联系人画像 (crm_contacts.ai_buyer_persona)
|
||
# ═══════════════════════════════════════════════════════
|
||
|
||
class BuyerRole(BaseModel):
|
||
"""决策角色"""
|
||
decision_role: str | None = None # 决策者 / 影响者 / 执行者
|
||
authority_level: str | None = None # 高 / 中 / 低
|
||
|
||
|
||
class BuyerKPI(BaseModel):
|
||
"""核心痛点与目标"""
|
||
core_goals: list[str] = Field(default_factory=list)
|
||
pain_points: list[str] = Field(default_factory=list)
|
||
|
||
|
||
class BuyerPreference(BaseModel):
|
||
"""交互偏好"""
|
||
comm_style: str | None = None
|
||
meeting_preference: str | None = None
|
||
topics_of_interest: list[str] = Field(default_factory=list)
|
||
|
||
|
||
class BuyerPersona(BaseModel):
|
||
"""联系人级 AI 画像 Schema"""
|
||
role: BuyerRole = Field(default_factory=BuyerRole)
|
||
kpi: BuyerKPI = Field(default_factory=BuyerKPI)
|
||
preference: BuyerPreference = Field(default_factory=BuyerPreference)
|
||
|
||
|
||
# ═══════════════════════════════════════════════════════
|
||
# 双轨画像回写 Payload(Dify Workflow 回调用)
|
||
# ═══════════════════════════════════════════════════════
|
||
|
||
class ContactPersonaUpdate(BaseModel):
|
||
"""单个联系人画像增量"""
|
||
contact_id: str
|
||
role: dict | None = None
|
||
kpi: dict | None = None
|
||
preference: dict | None = None
|
||
|
||
|
||
class PersonaUpdatePayload(BaseModel):
|
||
"""双轨画像回写请求体"""
|
||
company_updates: dict | None = None
|
||
contact_updates: list[ContactPersonaUpdate] | None = None
|