yha9806

western-batch-generator

0
0
# Install this skill:
npx skills add yha9806/claude-skills-vulca --skill "western-batch-generator"

Install specific skill from multi-skill repository

# Description

批量生成Western艺术双语评论。当需要处理western批次、生成西方艺术评论、或继续western expansion任务时使用。自动读取候选图像、调用western-image-critique-agent、保存检查点。

# SKILL.md


name: western-batch-generator
description: 批量生成Western艺术双语评论。当需要处理western批次、生成西方艺术评论、或继续western expansion任务时使用。自动读取候选图像、调用western-image-critique-agent、保存检查点。


Western Art Critique Batch Generator

核心功能

  • 从candidates文件读取待处理图像
  • 按批次(25张/批)生成双语评论
  • 自动保存检查点,支持断点续传
  • 质量验证(中文≥200字,维度≥18)

快速启动

检查当前进度

import json

# 读取进度文件
with open('checkpoints/western_expansion_progress.json') as f:
    progress = json.load(f)
print(f"已完成: {progress['completed']}/{progress['total']}")
print(f"下一批次: {progress['next_batch']}")

生成下一批次

使用 scripts/generate_western_batch.py:

python scripts/generate_western_batch.py --batch-id 005 --size 25

批次处理流程

Step 1: 准备批次输入

def prepare_batch(batch_id: int, size: int = 25):
    """从候选中提取下一批次图像"""
    with open('checkpoints/western_expansion_candidates.json') as f:
        data = json.load(f)

    # 读取已完成路径
    completed = set()
    for i in range(1, batch_id):
        try:
            with open(f'checkpoints/western_batch_{i:03d}_output.json') as f:
                for item in json.load(f):
                    completed.add(item['filepath'])
        except FileNotFoundError:
            pass

    # 筛选未完成图像
    remaining = [img for img in data['images'] if img['filepath'] not in completed]
    batch = remaining[:size]

    # 保存批次输入
    with open(f'checkpoints/western_batch_{batch_id:03d}_input.json', 'w') as f:
        json.dump(batch, f, indent=2, ensure_ascii=False)

    return batch

Step 2: 调用Agent生成评论

使用Task工具调用western-image-critique-agent:

Task(
    subagent_type="western-image-critique-agent",
    prompt="处理checkpoints/western_batch_{batch_id}_input.json中的25张图像,生成双语评论,保存到western_batch_{batch_id}_output.json"
)

Step 3: 验证输出质量

def validate_batch(batch_id: int) -> dict:
    """验证批次输出质量"""
    with open(f'checkpoints/western_batch_{batch_id:03d}_output.json') as f:
        critiques = json.load(f)

    results = {'passed': 0, 'failed': [], 'total': len(critiques)}

    for c in critiques:
        issues = []
        if len(c.get('critique_zh', '')) < 200:
            issues.append('short_zh')
        if len(c.get('critique_en', '').split()) < 150:
            issues.append('short_en')
        if len(c.get('covered_dimensions', [])) < 18:
            issues.append('low_dims')

        if issues:
            results['failed'].append({'filepath': c['filepath'], 'issues': issues})
        else:
            results['passed'] += 1

    return results

艺术家优先策略

保持同一艺术家的作品连续处理:

def get_artist_priority_batch(size: int = 25):
    """按艺术家优先级获取批次"""
    with open('checkpoints/western_expansion_candidates.json') as f:
        data = json.load(f)

    # 按艺术家分组
    by_artist = {}
    for img in data['images']:
        artist = img.get('artist', 'Unknown')
        by_artist.setdefault(artist, []).append(img)

    # 找到未完成的艺术家
    # 优先完成当前进行中的艺术家
    ...

输出格式

每条评论必须包含:

{
  "critique_id": "CRIT_WE_NEW_{SEQ}",
  "culture": "western",
  "culture_id": "western",
  "filepath": "/mnt/i/VULCA 2.0/.../image.jpg",
  "artist": "Artist Name",
  "title": "Artwork Title",
  "critique_zh": "中文评论(≥200字)",
  "critique_en": "English critique (≥150 words)",
  "covered_dimensions": ["WE_L1_D1", "WE_L1_D2", ...],
  "quality_score": 85
}

检查点机制

进度自动保存到 checkpoints/western_expansion_progress.json:

{
  "total": 3704,
  "completed": 100,
  "next_batch": 5,
  "last_updated": "2025-12-18T10:30:00",
  "completed_artists": ["Maximilien Luce"],
  "in_progress_artist": null,
  "failed_batches": []
}

错误恢复

如果批次失败:
1. 检查 failed_batches 列表
2. 重新运行失败批次
3. 或手动修复后标记完成

def retry_failed_batch(batch_id: int):
    """重试失败的批次"""
    # 读取原始输入
    with open(f'checkpoints/western_batch_{batch_id:03d}_input.json') as f:
        batch = json.load(f)

    # 重新处理
    # ...

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.