fix(documentary): align batch result fields with prompt contract

This commit is contained in:
linyq 2026-04-03 01:23:05 +08:00
parent c83841a2e0
commit 40a48cc9ff
2 changed files with 18 additions and 2 deletions

View File

@ -27,7 +27,7 @@ class FrameBatchResult:
time_range: str
raw_response: str
frame_paths: list[str] = field(default_factory=list)
observations: list[dict] = field(default_factory=list)
summary: str = ""
frame_observations: list[dict] = field(default_factory=list)
overall_activity_summary: str = ""
fallback_summary: str = ""
error_message: str = ""

View File

@ -46,6 +46,22 @@ class DocumentaryFrameAnalysisServiceTests(unittest.TestCase):
self.assertEqual("", batch.raw_response)
self.assertTrue(batch.fallback_summary)
def test_failed_batch_result_uses_prompt_contract_field_names(self):
service = DocumentaryFrameAnalysisService()
batch = service._build_failed_batch_result(
batch_index=4,
raw_response="not-json",
error_message="JSON decode failed",
frame_paths=["/tmp/keyframe_000002_000002000.jpg"],
time_range="00:00:06,000-00:00:09,000",
)
self.assertEqual([], batch.frame_observations)
self.assertEqual("", batch.overall_activity_summary)
self.assertFalse(hasattr(batch, "observations"))
self.assertFalse(hasattr(batch, "summary"))
class DocumentaryAnalysisConfigTests(unittest.TestCase):
def test_config_rejects_non_positive_frame_interval(self):