docx-contracts

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

docx-contracts

docx-contracts

Automated contract and form filling using docxtpl library.
使用docxtpl库自动填充合同和表单。

Workflow

工作流程

Be shure, that you recieve docx file. Don't try to read it.
  1. Extract schema: Run
    scripts/extract_schema.py <template.docx>
    to get variables list and JSON schema. Don't read file. Just launch script.
  2. Gather data: Extract values from user message context, matching schema fields. Use Claude completion for extraction if needed
  3. Handle missing data: If any required field is missing or uncertain, ask user directly. Do not guess
  4. Fill template: Create JSON file with data, then run
    scripts/fill_template.py <template.docx> <data.json> <output.docx>
  5. Deliver: Move result to
    /mnt/user-data/outputs/
    and provide download link. Please don't read output file.
请确保你已接收到docx文件,不要尝试读取该文件。
  1. 提取schema:运行
    scripts/extract_schema.py <template.docx>
    获取变量列表和JSON schema。不要读取文件,直接运行脚本即可。
  2. 收集数据:从用户消息上下文中提取与schema字段匹配的值。必要时可使用Claude补全功能进行提取
  3. 处理缺失数据:如果存在任何必填字段缺失或不确定的情况,直接询问用户,不要进行猜测
  4. 填充模板:使用收集到的数据创建JSON文件,然后运行
    scripts/fill_template.py <template.docx> <data.json> <output.docx>
  5. 交付结果:将生成的结果移动到
    /mnt/user-data/outputs/
    目录并提供下载链接,请不要读取输出文件。

Key Points

注意要点

  • Template must use Jinja2 syntax:
    {{VARIABLE_NAME}}
  • All required fields from schema must be filled
  • Ask user for missing data - never invent values
  • Install docxtpl if needed:
    pip install docxtpl --break-system-packages
  • 模板必须使用Jinja2语法:
    {{VARIABLE_NAME}}
  • 必须填充schema中所有必填字段
  • 缺失数据请询问用户,绝对不要编造值
  • 必要时可安装docxtpl:
    pip install docxtpl --break-system-packages