feat(api): 回忆录管线简化、路由延迟池与相关加固
- Phase1/2:移除 MemoirOrchestrator.run 与 process_memoir_segments 别名;文档改为 process_memoir_phase1。 - 槽位校验集中到 stage_constants(filter_stage_slots),批处理与顺序路径及 state_service 写库一致。 - StoryRoute:no_llm/parse_error/invalid_target 保守 new_story;短篇护栏不覆盖这些 fallback。 - Phase2 低置信单路径可选延迟(StoryPipelineResult.deferred):不写 Chapter/Story,Segment 记录 defer 元数据,冷却内不重复消费;上限后停自动重试,Phase1 同类目新段唤醒池内段。 - Alembic 0017:segments 表 narrative_defer_* 列。 - ProfileAgent:经 LlmGateway/注入 Provider 统一聊天与 JSON,新增测试。 - ImagePromptOrchestrator:LLM 初始化失败可依配置降级或硬失败;补充策略测试。 - 配套单测与 README/本地开发文档表述更新。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -121,3 +121,44 @@ def test_cover_fallback_disabled_requires_excerpt(monkeypatch):
|
||||
chapter_category="family",
|
||||
context_excerpt="",
|
||||
)
|
||||
|
||||
|
||||
def test_image_prompt_orchestrator_provider_failure_uses_fallback(monkeypatch):
|
||||
from app.agents.image_prompt.orchestrator import get_image_prompt_orchestrator
|
||||
|
||||
class BoomGateway:
|
||||
def langchain_llm_for(self, *_a, **_kw): # noqa: ANN001
|
||||
raise RuntimeError("provider missing")
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.agents.image_prompt.orchestrator.settings.image_prompt_fallback_disabled",
|
||||
False,
|
||||
)
|
||||
monkeypatch.setattr("app.core.llm_gateway.LlmGateway", lambda: BoomGateway())
|
||||
|
||||
orch = get_image_prompt_orchestrator()
|
||||
out = orch.build_cover_prompt(
|
||||
chapter_title="T",
|
||||
chapter_category="family",
|
||||
context_excerpt="mountain lake",
|
||||
)
|
||||
assert "mountain lake" in out["prompt"].lower()
|
||||
|
||||
|
||||
def test_image_prompt_orchestrator_provider_failure_raises_when_disabled(
|
||||
monkeypatch,
|
||||
):
|
||||
from app.agents.image_prompt.orchestrator import get_image_prompt_orchestrator
|
||||
|
||||
class BoomGateway:
|
||||
def langchain_llm_for(self, *_a, **_kw): # noqa: ANN001
|
||||
raise RuntimeError("provider missing")
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.agents.image_prompt.orchestrator.settings.image_prompt_fallback_disabled",
|
||||
True,
|
||||
)
|
||||
monkeypatch.setattr("app.core.llm_gateway.LlmGateway", lambda: BoomGateway())
|
||||
|
||||
with pytest.raises(RuntimeError, match="provider missing"):
|
||||
get_image_prompt_orchestrator()
|
||||
|
||||
Reference in New Issue
Block a user