85 lines
3.4 KiB
Python
85 lines
3.4 KiB
Python
"""Microsoft Agent Framework 多智能体会商实验功能开关配置。
|
|
|
|
本段为**部署级**特性开关:默认关闭。关闭时:
|
|
|
|
- Gateway 启动**不**加载 MAF SDK(SDK 延迟导入,仅在实际启用并触发会商 run
|
|
时才在 ``app.maf_roundtable`` 内 import)。
|
|
- ``/api/maf-roundtable/*`` 路由仍注册,但所有写接口与健康检查返回 ``503
|
|
Service Disabled``;只读的会话列表/详情可继续工作以便管理员查看历史。
|
|
- 前端入口由 ``GET /api/maf-roundtable/health`` 的 ``enabled`` 字段决定是否
|
|
显示。
|
|
|
|
段内只有开关与运行参数,无密钥,可公开只读(仿 ``y_log_config`` 的写法)。
|
|
|
|
``MafMode`` / ``MafWritePolicy`` 是部署配置与 API schema 共用的单一来源枚举,
|
|
避免两处各自维护一套合法值。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Literal
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
# ── shared enums (config + API schemas) ───────────────────────────────────
|
|
|
|
MafMode = Literal["structured", "group_chat"]
|
|
MafWritePolicy = Literal["auto", "confirm_high_risk", "confirm_all_writes"]
|
|
MafParticipantRole = Literal["manager", "seat"]
|
|
|
|
|
|
class MafRoundtableConfig(BaseModel):
|
|
"""Microsoft Agent Framework 多智能体会商实验功能开关。
|
|
|
|
默认 ``enabled=False``:这是一个独立于现有 ``RoundtablePlanningPage`` 的
|
|
实验性功能,不替换旧会商;首期仅管理员/白名单可见,关闭时完全不影响
|
|
Gateway 启动与旧功能行为。
|
|
"""
|
|
|
|
enabled: bool = Field(
|
|
default=False,
|
|
description="是否启用 MAF 多智能体会商实验功能;关闭时 SDK 延迟不加载,写接口返回 503。",
|
|
)
|
|
# 默认编排模式(用户可在创建会商时覆盖)。
|
|
default_mode: MafMode = Field(
|
|
default="structured",
|
|
description="默认编排模式:structured(固定流程)| group_chat(动态群聊)",
|
|
)
|
|
# 默认写入策略(auto / confirm_high_risk / confirm_all_writes)。
|
|
default_write_policy: MafWritePolicy = Field(
|
|
default="confirm_high_risk",
|
|
description="默认外部写入策略:auto / confirm_high_risk / confirm_all_writes",
|
|
)
|
|
# 默认最大轮次(群聊硬上限)。
|
|
default_max_rounds: int = Field(
|
|
default=8,
|
|
ge=1,
|
|
le=64,
|
|
description="默认最大轮次上限(群聊模式硬上限,避免弱模型无限讨论)",
|
|
)
|
|
# 管理员诊断是否可见所有用户的会商(true=管理员跨用户读,false=管理员也只能看自己的)。
|
|
admin_diagnostic_access: bool = Field(
|
|
default=True,
|
|
description="管理员是否可跨用户读取所有 MAF 会商用于诊断(仅读,不含写)",
|
|
)
|
|
# Phase 3: per-seat wall-clock timeout (seconds) for structured expert turns.
|
|
seat_timeout_seconds: int = Field(
|
|
default=600,
|
|
ge=30,
|
|
le=7200,
|
|
description="结构化流程中单个专家席位的超时秒数;超时记为 partial_failure 并继续其余席位",
|
|
)
|
|
# Phase 3: allow one directed format-repair turn when seat JSON fails schema.
|
|
schema_repair_enabled: bool = Field(
|
|
default=True,
|
|
description="席位输出未通过 SeatTurnOutput 校验时是否允许一次定向格式修复",
|
|
)
|
|
|
|
|
|
__all__ = [
|
|
"MafMode",
|
|
"MafParticipantRole",
|
|
"MafRoundtableConfig",
|
|
"MafWritePolicy",
|
|
]
|