interfaces.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. from __future__ import annotations
  2. from dataclasses import dataclass
  3. from pathlib import Path
  4. from typing import Any, Protocol
  5. class RuntimeStore(Protocol):
  6. def prepare_run(self, run_id: str) -> Path: ...
  7. def run_dir(self, run_id: str) -> Path: ...
  8. def write_json(self, run_id: str, filename: str, data: dict[str, Any]) -> Path: ...
  9. def update_json(self, run_id: str, filename: str, data: dict[str, Any]) -> Path: ...
  10. def append_jsonl(self, run_id: str, filename: str, rows: list[dict[str, Any]]) -> Path: ...
  11. def read_json(self, run_id: str, filename: str) -> dict[str, Any]: ...
  12. def read_jsonl(self, run_id: str, filename: str) -> list[dict[str, Any]]: ...
  13. def file_status(self, run_id: str) -> dict[str, bool]: ...
  14. def create_run_record(self, record: dict[str, Any]) -> None: ...
  15. def update_run_record(self, run_id: str, updates: dict[str, Any]) -> None: ...
  16. def record_policy_run(self, record: dict[str, Any]) -> None: ...
  17. def append_run_event_records(
  18. self,
  19. run_id: str,
  20. policy_run_id: str,
  21. rows: list[dict[str, Any]],
  22. ) -> None: ...
  23. def write_publish_jobs(
  24. self,
  25. run_id: str,
  26. policy_run_id: str,
  27. rows: list[dict[str, Any]],
  28. ) -> None: ...
  29. def write_author_assets(self, rows: list[dict[str, Any]]) -> None: ...
  30. def write_author_asset_roles(self, rows: list[dict[str, Any]]) -> None: ...
  31. def write_search_clue_assets(self, rows: list[dict[str, Any]]) -> None: ...
  32. def write_search_clue_asset_evidence(self, rows: list[dict[str, Any]]) -> None: ...
  33. def read_performance_feedback(
  34. self,
  35. run_id: str,
  36. policy_run_id: str,
  37. ) -> list[dict[str, Any]]: ...
  38. def enqueue_media_pipeline_task(self, task: dict[str, Any]) -> dict[str, Any]: ...
  39. def update_media_pipeline_task(self, task_id: str, updates: dict[str, Any]) -> None: ...
  40. def read_media_pipeline_tasks(
  41. self,
  42. run_id: str,
  43. *,
  44. batch_id: str | None = None,
  45. ) -> list[dict[str, Any]]: ...
  46. RuntimeFileStore = RuntimeStore
  47. @dataclass(frozen=True)
  48. class QueryVariantResult:
  49. query: str
  50. model: str
  51. prompt_version: str
  52. input_evidence: dict[str, Any]
  53. class QueryVariantClient(Protocol):
  54. def generate_variant(
  55. self,
  56. *,
  57. seed_term: str,
  58. evidence_context: dict[str, Any],
  59. ) -> QueryVariantResult: ...
  60. class GeminiVideoClient(Protocol):
  61. def analyze(
  62. self,
  63. content: dict[str, Any],
  64. media: dict[str, Any],
  65. source_context: dict[str, Any],
  66. ) -> dict[str, Any]: ...
  67. class PlatformSearchClient(Protocol):
  68. def search(self, search_query: dict[str, Any]) -> list[dict[str, Any]]: ...
  69. class PolicyBundleStore(Protocol):
  70. def load_policy_bundle(self, strategy_version: str, platform: str = "douyin") -> dict[str, Any]: ...