mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(blocks): use store_media_file for_block_output on edit video output
The edit block was returning a raw Replicate URL instead of piping the output through store_media_file with for_block_output. This broke workspace:// URI generation in CoPilot. Matches the pattern used by all sibling video blocks (clip, narration, concat, etc). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -48,8 +48,8 @@ class EditVideoByTextBlock(Block):
|
||||
)
|
||||
|
||||
class Output(BlockSchemaOutput):
|
||||
video_url: str = SchemaField(
|
||||
description="URL of the edited video",
|
||||
video_out: MediaFileType = SchemaField(
|
||||
description="Edited video file (path or data URI)",
|
||||
)
|
||||
transcription: str = SchemaField(
|
||||
description="Transcription used for editing",
|
||||
@@ -68,12 +68,13 @@ class EditVideoByTextBlock(Block):
|
||||
"transcription": "edited transcript",
|
||||
},
|
||||
test_output=[
|
||||
("video_url", "https://replicate.com/output/video.mp4"),
|
||||
("video_out", str),
|
||||
("transcription", "edited transcript"),
|
||||
],
|
||||
test_mock={
|
||||
"_edit_video": lambda *args: "https://replicate.com/output/video.mp4",
|
||||
"_store_input_video": lambda *args, **kwargs: "data:video/mp4;base64,AAAA",
|
||||
"_store_output_video": lambda *args, **kwargs: "edited_video.mp4",
|
||||
},
|
||||
test_credentials=TEST_CREDENTIALS,
|
||||
)
|
||||
@@ -88,6 +89,16 @@ class EditVideoByTextBlock(Block):
|
||||
return_format="for_external_api",
|
||||
)
|
||||
|
||||
async def _store_output_video(
|
||||
self, execution_context: ExecutionContext, file: MediaFileType
|
||||
) -> MediaFileType:
|
||||
"""Store output video. Extracted for testability."""
|
||||
return await store_media_file(
|
||||
file=file,
|
||||
execution_context=execution_context,
|
||||
return_format="for_block_output",
|
||||
)
|
||||
|
||||
async def _edit_video(
|
||||
self, data_uri: str, transcription: str, split_at: str, api_key: str
|
||||
) -> str:
|
||||
@@ -146,7 +157,12 @@ class EditVideoByTextBlock(Block):
|
||||
credentials.api_key.get_secret_value(),
|
||||
)
|
||||
|
||||
yield "video_url", video_url
|
||||
# Store output through workspace so CoPilot gets workspace:// URIs
|
||||
video_out = await self._store_output_video(
|
||||
execution_context, MediaFileType(video_url)
|
||||
)
|
||||
|
||||
yield "video_out", video_out
|
||||
yield "transcription", input_data.transcription
|
||||
|
||||
except BlockExecutionError:
|
||||
|
||||
@@ -13,7 +13,7 @@ Takes a video and a modified version of its transcript, then produces a new vide
|
||||
|
||||
### How it works
|
||||
<!-- MANUAL: how_it_works -->
|
||||
The block sends the input video and the desired transcript to the Replicate API using the `jd7h/edit-video-by-editing-text` model in "edit" mode. The model aligns the provided transcript against the original speech in the video and removes any video segments whose speech is not present in the supplied transcript. The `split_at` parameter controls alignment granularity: `word` (default) aligns cuts at word boundaries for natural-sounding edits, while `character` allows finer sub-word alignment for more precise control. The block returns the URL of the edited video along with the transcript that was used.
|
||||
The block sends the input video and the desired transcript to the Replicate API using the `jd7h/edit-video-by-editing-text` model in "edit" mode. The model aligns the provided transcript against the original speech in the video and removes any video segments whose speech is not present in the supplied transcript. The `split_at` parameter controls alignment granularity: `word` (default) aligns cuts at word boundaries for natural-sounding edits, while `character` allows finer sub-word alignment for more precise control. The block returns the edited video (stored via the workspace file system) along with the transcript that was used.
|
||||
<!-- END MANUAL -->
|
||||
|
||||
### Inputs
|
||||
@@ -29,7 +29,7 @@ The block sends the input video and the desired transcript to the Replicate API
|
||||
| Output | Description | Type |
|
||||
|--------|-------------|------|
|
||||
| error | Error message if the operation failed | str |
|
||||
| video_url | URL of the edited video | str |
|
||||
| video_out | Edited video file (path or data URI) | str (file) |
|
||||
| transcription | Transcription used for editing | str |
|
||||
|
||||
### Possible use case
|
||||
|
||||
Reference in New Issue
Block a user