Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3522962
Built-in director: what it says about a shot is in English, as the re…
KBRASK Nov 29, 2026
72d24f5
Batch, one prompt per line: a line that names media with @ takes only…
KBRASK Nov 29, 2026
4dbc432
Media tray: when the line of keys is still too wide with the AI and a…
KBRASK Nov 29, 2026
5fbf422
Character dialog: a Voice section gives the character its own voice, …
KBRASK Nov 29, 2026
73301b0
A media card turned off keeps its place in the prompt by name
KBRASK Nov 29, 2026
7d08a6f
Character dialog on a narrow window: tabs, view names and clothes cho…
KBRASK Nov 29, 2026
100be95
What the page keeps only in its browser can also be kept in the engin…
KBRASK Nov 29, 2026
b79296b
Cast shelf: a card read again after a save keeps its picture until th…
KBRASK Nov 29, 2026
24d46dd
Reuse settings fills back the media an earlier video was made from, c…
KBRASK Nov 29, 2026
f4cc235
Page check tests follow the page as it is: the card names the step th…
KBRASK Nov 29, 2026
29017a6
Old workflows and a video's tags read back as generate requests (spec…
KBRASK Nov 29, 2026
4c4df5a
Restore: a work's file read back as a generate request, read only (PO…
KBRASK Nov 29, 2026
d520c1f
What the page keeps only in this browser is also kept in the engine's…
KBRASK Nov 29, 2026
d544df2
Agent: planning and generating a project's parts works again over HTT…
KBRASK Nov 29, 2026
8f66603
Agent: reading a waiting job no longer waits while another job's star…
KBRASK Nov 29, 2026
c83cb38
Sign-in proxy: a browser leaving mid-stream is not an error, and an a…
KBRASK Nov 29, 2026
03ea172
Long videos: the finished-job record is written to the output folder …
KBRASK Nov 29, 2026
2b4910a
One prompt per line: a character named with @ brings its pictures and…
KBRASK Nov 29, 2026
a9b0a7d
A backup of ComfyUI's unsaved workflow tabs that holds the prompt of …
KBRASK Nov 29, 2026
4cc4bb6
Launcher: an NVIDIA driver too old for setup names the check's own bu…
KBRASK Nov 29, 2026
5fbcae1
Agent plan: the first and second pass it reports are the ones the job…
KBRASK Nov 29, 2026
00ebf69
Failed download copies: the Fast level's files follow the same rule, …
KBRASK Nov 29, 2026
786fb53
ComfyUI is no longer started on a computer whose CUDA driver shows no…
KBRASK Nov 29, 2026
494e511
The CUDA no-device card says that a Remote Desktop connection is the …
KBRASK Nov 29, 2026
803f9c3
Opening screen: the line counts in the page language, read from its l…
KBRASK Nov 29, 2026
9ffa80b
Offline packages: a package folder spelled differently from its files…
KBRASK Nov 29, 2026
f122bda
Model downloads: the size check of a transfer leaves out every kind o…
KBRASK Nov 29, 2026
10b17d1
LoRA check: an adapter for LTX's audio branch (audio attention, audio…
KBRASK Nov 29, 2026
35e6efd
Extending a video: the second pass of its preview runs instead of sto…
KBRASK Nov 29, 2026
9fb0993
Editor: closing an empty edit words a held-back delete as the delete …
KBRASK Nov 29, 2026
80ff22d
Upscale times: a request it cannot read says which value is missing o…
KBRASK Nov 29, 2026
b276c18
Reverse and rewrite say a busy prompt model as a note that clears itself
KBRASK Nov 29, 2026
b3fa8bb
Release 0.6.18: update notes
KBRASK Nov 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ async def comfy_entrypoint():
logging.warning('[FreeVideo] Chain routes not registered: %s', error)
from .freevideo_engine.comfy_upload import register
register()
# A work read back as a generate request (read only; the page does not ask for it yet).
from .freevideo_engine.restore import register as restore_routes
restore_routes()
from .freevideo_engine.comfy_setup import register as setup_routes
setup_routes()
from .freevideo_engine.prompt_vlm.service import register as prompt_routes
Expand Down Expand Up @@ -66,6 +69,8 @@ async def comfy_entrypoint():
update_routes()
from .freevideo_engine.reload_keep import register as reload_keep_routes
reload_keep_routes()
from .freevideo_engine.user_store import register as user_store_routes
user_store_routes()
from .freevideo_engine.comfy_library import register as library_routes
library_routes()
from .freevideo_engine.comfy_editor import register as editor_routes
Expand Down
17 changes: 14 additions & 3 deletions freevideo_engine/access_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import math
import time
import ipaddress
import logging
import os
import re
from pathlib import Path
Expand Down Expand Up @@ -275,9 +276,19 @@ async def forward(request):
response.content_length = reply.content_length
browser_headers(response, request)
await response.prepare(request)
async for chunk in reply.content.iter_chunked(1 << 16):
await response.write(chunk)
await response.write_eof()
try:
async for chunk in reply.content.iter_chunked(1 << 16):
await response.write(chunk)
await response.write_eof()
except ConnectionResetError:
# The browser went away mid-way (a closed tab, a video seeking elsewhere): nothing went wrong.
pass
except (client_exceptions.ClientPayloadError, client_exceptions.ServerDisconnectedError) as error:
# ComfyUI stopped in the middle of its answer. The status has been sent, so dropping the connection is
# how the browser learns the answer is incomplete, rather than taking a cut-off file as whole.
logging.getLogger(__name__).warning('[FreeVideo] An answer from ComfyUI ended early (%s).', type(error).__name__)
if request.transport is not None:
request.transport.abort()
return response
except client_exceptions.ClientConnectorError:
return web.json_response(dict(error='ComfyUI is not answering yet.'), status=502)
Expand Down
37 changes: 21 additions & 16 deletions freevideo_engine/agent/builtin_director.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ def _take_count(shot):
return max(1, min(8, sum(t['generation'] == first for t in shot['takes'])))


# What the director says about a choice is read by the connected agent and the log, as the rest of the agent's
# interface is: in English. The model writes its reason for a take in English, in one sentence of this length.
REASON_LIMIT = 120


def judge(shot_view, sheets, *, ask):
"""Score all selectable takes; invalid/missing evidence leaves a human choice.
Expand All @@ -366,22 +371,22 @@ def judge(shot_view, sheets, *, ask):
"""
shot = shot_view
if shot.get('chosen_by') == 'user' or shot.get('chosen') is not None:
return Decision('keep', shot['id'], '保留已选定的版本。')
return Decision('keep', shot['id'], 'The chosen take stays.')
shooting = shot.get('state') in ('waiting', 'shooting')
uncertain = Decision('ask_user', shot['id'], '拿不准,请挑一版。')
uncertain = Decision('ask_user', shot['id'], 'No take is clearly best; the user picks one.')
finished = _selectable(shot)
unchecked = any('qa' in t and t['qa'] is None for t in finished)
if shooting and (not finished or any(t.get('qa') is None for t in finished)) or unchecked:
return Decision('wait', shot['id'], '等待这一镜的各版完成并质检。')
return Decision('wait', shot['id'], 'Waiting for every take of this shot to finish and be checked.')
# A take that failed the picture or sound check is never chosen; a shot still shooting is judged as takes arrive.
takes = [t for t in finished if (t.get('qa') or {}).get('ok', True)]
if not takes:
if shooting:
return Decision('wait', shot['id'], '已完成的版本没有通过质检,等待其余版本。')
return Decision('wait', shot['id'], 'The finished takes failed the check; waiting for the others.')
if not finished or _retaken(shot):
return uncertain
faults = ';'.join(sorted({p for t in finished for p in t['qa']['problems']}))
return Decision('reshoot', shot['id'], '各版都没有通过质检。',
return Decision('reshoot', shot['id'], 'No take passed the check.',
note=('上一次的问题:' + faults)[:300], takes=_take_count(shot))
try:
rows = sheets['takes']
Expand All @@ -395,14 +400,14 @@ def judge(shot_view, sheets, *, ask):
for start in range(0, len(numbers), batch_size):
batch = numbers[start:start + batch_size]
rating = _object(dict(take=dict(type='integer', enum=batch), score=dict(type='number', minimum=0, maximum=10),
reason=_string(30), note=_string(300), captions=dict(type='boolean')),
reason=_string(REASON_LIMIT), note=_string(300), captions=dict(type='boolean')),
('take', 'score', 'reason', 'note', 'captions'))
schema = _object(dict(ratings=dict(type='array', minItems=len(batch), maxItems=len(batch), items=rating)),
('ratings',))
prompt = ('评价这一镜的每个版本:0–10 分,reason 用不超过30字的中文指出具体优点或问题'
'(多余的字、人物变形、和描述不符等);note 给下一次生成能用的具体修正。'
prompt = ('评价这一镜的每个版本:0–10 分;reason 用一句英文写出具体的优点或问题'
'(多余的字、人物变形、和描述不符等),%d 个字符以内;note 给下一次生成能用的具体修正。'
'captions 表示有叠加字幕/文字,场景内真实招牌不算。声音由自动质检评价,这里不评价。'
'\n镜头描述:' + _dump({k: shot[k] for k in ('screenplay', 'characters', 'style', 'captions') if k in shot})
'\n镜头描述:' % REASON_LIMIT + _dump({k: shot[k] for k in ('screenplay', 'characters', 'style', 'captions') if k in shot})
+ '\n图片顺序对应版号:' + _dump(batch)
+ ''.join('\n版%d的%s' % (t['take'], take_qa.summary(t.get('qa'))) for t in takes
if t['take'] in batch and t.get('qa'))
Expand All @@ -412,17 +417,17 @@ def judge(shot_view, sheets, *, ask):
return uncertain
ratings.extend(reply['ratings'])
for row in ratings:
spec._text(row['reason'], '/reason', 30)
spec._text(row['reason'], '/reason', REASON_LIMIT)
spec._text(row['note'], '/note', 300)
if row['captions'] and not shot.get('captions', False):
row['score'] = min(row['score'], 3)
best = max(ratings, key=lambda r: (r['score'], -r['take']))
if best['score'] < 7 and shooting:
return Decision('wait', shot['id'], '已完成的版本不够好,等待其余版本。')
return Decision('wait', shot['id'], 'The finished takes are not good enough; waiting for the others.')
if best['score'] >= 7:
return Decision('choose', shot['id'], best['reason'], take=best['take'])
if _retaken(shot):
return Decision('choose', shot['id'], '重拍后仍不理想:' + best['reason'], take=best['take'])
return Decision('choose', shot['id'], 'Still not good after a reshoot: ' + best['reason'], take=best['take'])
return Decision('reshoot', shot['id'], best['reason'], note=best['note'], takes=_take_count(shot))
except (KeyError, TypeError, ValueError):
return uncertain
Expand Down Expand Up @@ -559,7 +564,7 @@ def _with_stitch(tools, production_id, shot, sheets, decision, ask):
if pieces is None:
return decision, None
parts = [dict(take=p['take'], start=p['start'], end=p['end']) for p in pieces['pieces']]
return replace(decision, take=parts[-1]['take'], reason=(decision.reason + ';各切镜取最好的一版拼接')[:300]), parts
return replace(decision, take=parts[-1]['take'], reason=(decision.reason + '; joined from the best take of each cut')[:300]), parts


def run(tools, production_id, *, ask, stop, wait=25):
Expand Down Expand Up @@ -591,7 +596,7 @@ def run(tools, production_id, *, ask, stop, wait=25):
chosen = dict(snapshot)
# The parts of a shot are kept with its chosen take in the production.
tools.finish(production_id, by='builtin', ref=_ref(production_id, 'finish', snapshot))
yield dict(shot=None, action='finish', reason='每镜已选定,开始接成影片。')
yield dict(shot=None, action='finish', reason='Every shot has its take; joining the film.')
return
if action not in ('choose', 'reshoot'):
continue
Expand Down Expand Up @@ -654,12 +659,12 @@ def run(tools, production_id, *, ask, stop, wait=25):
conflicts += 1
errors, since = 0, None
if conflicts >= 5:
yield dict(shot=None, action='error', reason='多次和已有的选择冲突,已停止:' + code)
yield dict(shot=None, action='error', reason='Stopped after repeated conflicts with choices already made: ' + code)
return
continue
errors += 1
since = None
if errors >= 3:
label = code if isinstance(code, str) and re.fullmatch(r'[a-z_]{1,80}', code) else type(error).__name__
yield dict(shot=None, action='error', reason='连续三次操作失败,已停止:' + label)
yield dict(shot=None, action='error', reason='Stopped after three failed operations in a row: ' + label)
return
2 changes: 1 addition & 1 deletion freevideo_engine/agent/editor_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# module still loading is reached only through a namespace import.
MODULES = ('chain_rules', 'editor_picture_fields', 'editor_transport_model', 'editor_audio_model', 'editor_speed_model',
'editor_text_model', 'editor_model', 'editor_room', 'editor_actions', 'editor_generation', 'sampling_effort',
'chain_support', 'editor_store')
'chain_support', 'random_id', 'editor_store')
TIME_LIMIT = 5.0
MEMORY_LIMIT = 256 * 2**20
STACK_LIMIT = 4 * 2**20
Expand Down
20 changes: 16 additions & 4 deletions freevideo_engine/agent/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,12 +1411,18 @@ def run_again(self, identity):
replace(row, candidate)
return row

def queue_view(self):
"""Describe ownership/order without exposing studio workflows or prompts."""
def queue_view(self, *, wait=True):
"""Describe ownership/order without exposing studio workflows or prompts.
With wait=False the answer is None at once while another thread holds the chain runner (starting a chain
writes its receipts to disk under that lock), instead of waiting for it.
"""
runner = self.port.chain_runner()
entries, chains, prompts = [], [], {}
if runner is not None:
with runner.lock:
if not runner.lock.acquire(blocking=wait):
return None
try:
order = runner.active_ids() + runner.queue
order += [r['id'] for r in runner.records.values() if r['id'] not in order]
records = [runner.records[identity] for identity in dict.fromkeys(order)]
Expand All @@ -1430,6 +1436,8 @@ def queue_view(self):
for block in record['blocks']:
if block['prompt_id'] and block['state'] in ('queued', 'running'):
prompts[block['prompt_id']] = (record['id'], entry)
finally:
runner.lock.release()
for row in self.active():
if row.get('comfy'):
prompts[row['comfy']['prompt_id']] = (row['id'], dict(owner='agent', job_id=row['id'], state=row['status']))
Expand Down Expand Up @@ -1457,8 +1465,12 @@ def queue_view(self):

def queue_note(self, row):
"""Where a waiting generation stands behind the work holding the GPU, and what a client does meanwhile."""
# The note only tells a client where it stands, so a status read never waits for it: while another job holds the
# chain runner to write its receipts, this read goes without the note and the next read carries it.
try:
queue = self.queue_view()
queue = self.queue_view(wait=False)
if queue is None:
return {}
ahead = queue['ahead'].get(row['id'])
if not ahead or not ahead['count']:
return {}
Expand Down
19 changes: 13 additions & 6 deletions freevideo_engine/agent/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,30 +312,37 @@ def capabilities(port, jobs):


def plan(port, value, jobs=None):
from ..two_pass import plan as sampling_plan
from ..two_pass import plan as sampling_plan, sampling_canvas
from ..geometry import geometry
spec = specs.normalize(value, port=port)
result = dict(spec={k: v for k, v in spec.items() if k != 'depends_on'}, warnings=[])
if spec['kind'] != 'generate' or spec.get('refine_from'):
return result
from .jobs import continuation_problems, cut_problems, middle_problems, part_prompt_problems, parts_problems
problems = (continuation_problems(spec) + cut_problems(spec, spec['seconds']) + middle_problems(spec)
+ part_prompt_problems(spec))
from .jobs import (continuation_problems, cut_problems, middle_problems, original_audio_problems, part_prompt_problems,
parts_problems)
# First, as on submit: an audio file used as it is replaces the seconds with its own length for every later check.
problems = original_audio_problems(spec, port.input_root)
problems += (continuation_problems(spec) + cut_problems(spec, spec['seconds']) + middle_problems(spec)
+ part_prompt_problems(spec))
if jobs is not None:
problems += parts_problems(spec, jobs.port.chain_runner(), work=jobs.continued_work(spec),
planned=jobs.planned_parts(spec))
else:
problems += parts_problems(spec, None)
if problems:
raise specs.SpecError(problems)
result['spec'] = {k: v for k, v in spec.items() if k != 'depends_on'}
if jobs is not None:
jobs.require_continuation(spec)
if spec.get('continue_from') and not jobs.continuation_ready():
from .jobs import continuation_unavailable
raise continuation_unavailable()
canvas = geometry(spec['width'], spec['height'], seconds=spec['seconds'])
passes = sampling_plan(canvas, spec['two_pass'], spec['task'], base_steps=spec['base_steps'],
refine_steps=spec['refine_steps'])
# What the job will sample, decided as the generation decides it: a preview keeps the requested canvas and its
# half-size first pass; a small size is rendered larger; the factor is the one the job's graph carries.
sampled, _ = sampling_canvas(canvas, staged=spec['preview'])
passes = sampling_plan(sampled, spec['two_pass'], spec['task'], base_steps=spec['base_steps'],
refine_steps=spec['refine_steps'], staged=spec['preview'], scale=specs.upscale_factor(spec))
result['geometry'] = {k: canvas[k] for k in ('width', 'height', 'frames', 'seconds', 'fps', 'latent_frames')}
result['sampling'] = dict(two_pass=passes['enabled'], total_steps=passes['total_steps'],
first_pass=passes.get('first'), second_pass=passes.get('second') if passes['enabled'] else None)
Expand Down
16 changes: 14 additions & 2 deletions freevideo_engine/agent/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ def normalize(value, *, port=None):
return result


def upscale_factor(spec):
"""The learned upscale factor a generate spec is sampled with: its level's factor for two passes; 2 for one pass
and for a preview, which stays the quick half-size first pass. The job's graph and its plan both read it here."""
return spec.get('upscale_factor', 2) if spec['two_pass'] and not spec['preview'] else 2


def comfy_prompt(spec, node, *, prompt, assets, refine_from=''):
"""The ComfyUI API-format graph for one generate job; media are files in ComfyUI input."""
from ..lora_triggers import apply_triggers
Expand All @@ -377,8 +383,8 @@ def comfy_prompt(spec, node, *, prompt, assets, refine_from=''):
inputs['first_frame_reference'] = True
if spec.get('step_cache'):
inputs['step_cache'] = spec['step_cache']
if spec.get('upscale_factor', 2) != 2 and spec['two_pass'] and not spec['preview']:
inputs['upscale_factor'] = '%g' % spec['upscale_factor']
if upscale_factor(spec) != 2:
inputs['upscale_factor'] = '%g' % upscale_factor(spec)
graph = {node: {'class_type': 'FreeVideoGenerate', 'inputs': inputs,
'_meta': {'title': 'FreeVideo · ' + (spec.get('label') or 'Agent job')}}}
if assets:
Expand All @@ -400,3 +406,9 @@ def upscale_prompt(node, preview_video):
two_pass=True, base_steps=8, refine_steps=3, force_regenerate=False, preview=False,
refine_from=preview_video)
return {node: {'class_type': 'FreeVideoGenerate', 'inputs': inputs, '_meta': {'title': 'FreeVideo · Second pass'}}}


def from_comfy(source, *, resolve=None):
"""The reverse of comfy_prompt: a generate request from an old workflow or a video's tags (agent/spec_comfy.py)."""
from .spec_comfy import from_comfy as read
return read(source, resolve=resolve)
Loading