feat(eval): memoir A/B chapter judging and eval-web parity with dialogue
- Judge baseline excerpt and library chapter separately; build_memoir_compare_summary for gate, nine-dim and leaf deltas. - Memoir SSE chapter payload: baseline_judge, compare_summary, baseline_judge_error. - MemoirJudgeOutput: loose score coercion and post-validate clamp; memoir judge prompt caps from settings. - app-eval-web: two-column MemoirScoreCard layout, MemoirCompareSummary, chapter blocks and CSS. - Add memoir_compare_summary, log_events, celery_log_context, memoir_pipeline_progress; tests and migration 0014. - Misc: memory/evidence and enrichment paths, task/orchestrator updates, internal-eval docs, env examples.
This commit is contained in:
@@ -15,6 +15,7 @@ import redis
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.logging import get_logger
|
||||
from app.core.memoir_pipeline_progress import merge_pipeline_run
|
||||
from app.core.memory_compaction_schedule import schedule_memory_compaction_run
|
||||
|
||||
logger = get_logger(__name__)
|
||||
@@ -92,8 +93,26 @@ def enqueue_story_post_commit_effects(
|
||||
exc,
|
||||
)
|
||||
try:
|
||||
cast(Any, gen_story_image_task).delay(sid)
|
||||
img_ar = cast(Any, gen_story_image_task).delay(
|
||||
sid, memoir_correlation_id=memoir_correlation_id
|
||||
)
|
||||
result.enqueued_story_image_count += 1
|
||||
tid_img = getattr(img_ar, "id", None)
|
||||
if memoir_correlation_id and tid_img:
|
||||
merge_pipeline_run(
|
||||
memoir_correlation_id,
|
||||
{
|
||||
"fanout": {
|
||||
"story_images": [
|
||||
{
|
||||
"story_id": sid,
|
||||
"task_id": str(tid_img),
|
||||
"status": "enqueued",
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"generate_story_image.delay failed story={} trigger={}: {}",
|
||||
@@ -115,10 +134,31 @@ def enqueue_story_post_commit_effects(
|
||||
cd = int(settings.recompose_chapter_delay_seconds)
|
||||
for cid in sorted(chapter_ids):
|
||||
try:
|
||||
cast(Any, recompose_chapter_task).apply_async(
|
||||
args=[cid], countdown=max(0, cd)
|
||||
rkwargs: dict[str, Any] = {}
|
||||
if memoir_correlation_id:
|
||||
rkwargs["memoir_correlation_id"] = memoir_correlation_id
|
||||
rec_ar = cast(Any, recompose_chapter_task).apply_async(
|
||||
args=[cid],
|
||||
kwargs=rkwargs,
|
||||
countdown=max(0, cd),
|
||||
)
|
||||
result.enqueued_chapter_recompose_count += 1
|
||||
tid_rec = getattr(rec_ar, "id", None)
|
||||
if memoir_correlation_id and tid_rec:
|
||||
merge_pipeline_run(
|
||||
memoir_correlation_id,
|
||||
{
|
||||
"fanout": {
|
||||
"recompose_chapters": [
|
||||
{
|
||||
"chapter_id": cid,
|
||||
"task_id": str(tid_rec),
|
||||
"status": "enqueued",
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"recompose_chapter.apply_async failed chapter={} trigger={}: {}",
|
||||
@@ -140,6 +180,18 @@ def enqueue_story_post_commit_effects(
|
||||
ctx.update(compaction_extra)
|
||||
schedule_memory_compaction_run(user_id, ctx)
|
||||
result.compaction_scheduled = True
|
||||
if memoir_correlation_id:
|
||||
merge_pipeline_run(
|
||||
memoir_correlation_id,
|
||||
{
|
||||
"fanout": {
|
||||
"compaction": {
|
||||
"status": "scheduled",
|
||||
"note": "debounce",
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"schedule_memory_compaction_run failed user_id={} trigger={}: {}",
|
||||
@@ -156,12 +208,25 @@ def enqueue_story_post_commit_effects(
|
||||
)
|
||||
|
||||
cd = int(settings.memoir_quality_pass_delay_seconds)
|
||||
cast(Any, quality_pass_task).apply_async(
|
||||
qp_ar = cast(Any, quality_pass_task).apply_async(
|
||||
args=[user_id, sorted(story_ids), sorted(chapter_ids)],
|
||||
kwargs={"memoir_correlation_id": memoir_correlation_id},
|
||||
countdown=max(0, cd),
|
||||
)
|
||||
result.quality_pass_scheduled = True
|
||||
tid_qp = getattr(qp_ar, "id", None)
|
||||
if memoir_correlation_id and tid_qp:
|
||||
merge_pipeline_run(
|
||||
memoir_correlation_id,
|
||||
{
|
||||
"fanout": {
|
||||
"quality_pass": {
|
||||
"task_id": str(tid_qp),
|
||||
"status": "enqueued",
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"memoir_quality_pass enqueue failed user_id={} trigger={}: {}",
|
||||
|
||||
Reference in New Issue
Block a user