refactor: 规则中性化——剥离 PPT 业务,统一为订单示范域
把规则从原 ppt-gen 项目泛化为通用脚手架,覆盖 19 个文件: - ddd/architecture/design-discipline/error-codes/communication-* 等: 领域术语、错误码、消息示例、扩展点、状态流统一为「订单」示范域 - agent-dag/agent.md/agent-concurrency/agent-llm-*:DAG 节点、配置、并发、 LLM 适配从「对话→预览→生成→截图→合成」改为「intake→process→validate→finalize」 - backend-db:Session 实体/状态机/ORM/仓储/checkpoint 对齐新流水线 - 移除幻灯片专属依赖与产物:agent 去 playwright/python-pptx, Dockerfile 去 Chromium 系统库,.gitignore 去 *.pptx - 保留合法通用项:ANSI(PTY 处理)、Playwright(E2E 测试工具)、Gemini CLI(真实 provider) 验证:gemini-cli/openai-api 两变体生成退出 0,生成项目零 PPT 残留, backend/agent 骨架均可 import 运行。
This commit is contained in:
@@ -75,33 +75,32 @@ Anthropic 适配器同理,将 `AsyncOpenAI` 换为 `AsyncAnthropic`,流式 A
|
||||
## DAG 节点中的调用模式
|
||||
|
||||
```python
|
||||
async def phase3_generate(state, send, recv_queue):
|
||||
async def process(state, send, recv_queue):
|
||||
try:
|
||||
async with asyncio.timeout(settings.generate_timeout_seconds):
|
||||
async with asyncio.timeout(settings.process_timeout_seconds):
|
||||
chunks: list[str] = []
|
||||
async for token in llm_session.generate(state.messages):
|
||||
chunks.append(token)
|
||||
await send({"type": "llm_token", "text": token})
|
||||
html = extract_html("".join(chunks))
|
||||
if not html:
|
||||
raise HtmlExtractionError()
|
||||
result = extract_result("".join(chunks))
|
||||
if not result:
|
||||
raise OutputValidationError()
|
||||
except TimeoutError:
|
||||
raise LLMTimeoutError(phase="generate")
|
||||
raise ExternalServiceTimeoutError(phase="process")
|
||||
```
|
||||
|
||||
不需要 ANSI 过滤——API 响应是纯文本,无终端转义码。
|
||||
|
||||
## 超时保护
|
||||
|
||||
每个 DAG 阶段用 `asyncio.timeout()` 包裹 LLM 调用:
|
||||
每个 DAG 阶段用 `asyncio.timeout()` 包裹 LLM 调用(示范):
|
||||
|
||||
| 阶段 | 配置项 |
|
||||
|------|--------|
|
||||
| phase1_dialog(单轮对话) | `dialog_timeout_seconds`(默认 60s) |
|
||||
| phase2_preview(3 张预览) | `preview_timeout_seconds`(默认 180s) |
|
||||
| phase3_generate(完整 HTML) | `generate_timeout_seconds`(默认 300s) |
|
||||
| intake(收集输入) | `intake_timeout_seconds`(默认 60s) |
|
||||
| process(LLM 处理) | `process_timeout_seconds`(默认 300s) |
|
||||
|
||||
超时后抛 `LLMTimeoutError`(`domain/exceptions.py`),不静默挂起。
|
||||
超时后抛 `ExternalServiceTimeoutError`(`domain/exceptions.py`),不静默挂起。
|
||||
|
||||
## 连接管理
|
||||
|
||||
|
||||
Reference in New Issue
Block a user