| from __future__ import annotations |
|
|
| from app.schemas.plans import VisualOperation, VisualPlan, VisualReference |
| from app.storage.models import VisualAssetRecord |
|
|
|
|
| def compile_visual_plan(intent: str, text: str, asset: VisualAssetRecord | None, views: list[str]) -> VisualPlan: |
| references = [] |
| operations = [] |
| if asset: |
| for idx, view in enumerate(views, start=1): |
| references.append(VisualReference(phrase=text[:80], asset_id=asset.id, view=view, confidence=0.86)) |
| operations.append(VisualOperation(id=f"op_{idx}", op="get_view", asset_id=asset.id, view=view)) |
| if intent == "create_presentation": |
| operations.append(VisualOperation(id=f"op_{len(operations)+1}", op="create_presentation", asset_id=asset.id if asset else None, parameters={"content_request": text})) |
| if not operations: |
| operations.append(VisualOperation(id="op_1", op="answer_from_evidence", parameters={"content_request": text})) |
| return VisualPlan(intent=intent, references=references, operations=operations) |
|
|