YAMLResume

导入

`yamlresume ai import` 命令借助具备视觉能力的模型,将一张或多张简历图片转换为 YAMLResume 文件。

yamlresume ai import 命令可将一张或多张图片中的简历导入为 YAMLResume 文件。当你手头只有一张截图、一份扫描件或现有简历的导出页面时,它会非常有用。

$ yamlresume ai import --help
Usage: yamlresume ai import [options] <image-1.png> [image-2.png ...] <output>

import a resume from one or more images with AI

Arguments:
  paths                      ordered image paths followed by the output resume
                             filename

Options:
  -m, --model <model>        AI provider model to use
  -b, --base-url <url>       AI provider base URL
  -r, --retry <count>        maximum retries when validation fails (default: 2)
  -l, --language <language>  locale language override
  --no-layouts               do not append the default layouts block
  --no-comments              do not inject YAML comments
  -h, --help                 display help for command

Environment variables:

  Required (one API key for the selected cloud provider):
    DEEPSEEK_API_KEY          DeepSeek API key
    OPENAI_API_KEY            OpenAI API key
    MOONSHOT_API_KEY          Kimi (Moonshot AI) API key

  Optional:
    OLLAMA_HOST               Ollama host for local models
    YAMLRESUME_AI_MODEL       model override (overridden by --model)
    YAMLRESUME_AI_BASE_URL    API base URL override (overridden by --base-url)

Import notes:

  Only image files are supported: .png, .jpg, .jpeg, .webp, .gif.
  Pass image paths in page order, followed by the output resume filename:
    yamlresume ai import page-01.png page-02.png resume.yml
  A vision-capable model is required. Use --model to select one when the
  provider default does not accept image input.

示例

设置服务提供商的 API 密钥并导入单张图片。最后一个路径始终是输出简历的文件名:

$ export OPENAI_API_KEY=sk-...
$ yamlresume ai import screenshot.png resume.yml

对于多页简历,请在输出路径之前按页面顺序传入图片:

$ yamlresume ai import page-01.png page-02.png page-03.png resume.yml

一次真实的导入:输入图像,以及用 yamlresume build 从导入的 YAML 重新构建的同一份简历。

原始简历图像输入图像
用作 AI 导入输入的简历图像截图
导入后的简历由导入的 YAML 构建
同一份简历经导入并用 YAMLResume 重新构建

仅支持图片文件:.png、.jpg、.jpeg、.webp 和 .gif。每张图片以及合并后的输入都限制在 20 MiB 以内。PDF 和 DOCX 导入计划在后续阶段支持。

该命令不会覆盖已存在的输出文件;请选择一个新输出路径,或先删除旧文件。

需要使用具备视觉能力的模型。当提供商的默认模型不接受图片输入时,可用 -m, --model 选择模型。可用的服务提供商及其默认模型请参阅生成:支持的提供商;你也可以通过 YAMLRESUME_AI_MODEL 和 YAMLRESUME_AI_BASE_URL 环境变量覆盖模型和基础 URL。

-l, --language

默认情况下,模型会从图片中识别简历的区域语言。使用 -l, --language 可以覆盖识别结果,显式设置 locale.language:

$ yamlresume ai import --language zh-hans page-01.png resume.yml

--no-layouts 和 --no-comments

默认情况下,导入的简历会包含默认的 layouts 块和便于编辑器/IDE 进行 schema 验证的有用 YAML 注释,因此你可以立即构建它。可以用以下方式禁用其中任意一项:

$ yamlresume ai import --no-layouts --no-comments screenshot.png resume.yml

--retry

导入会在每次尝试后验证生成的 YAML。结构性失败——输出不是有效的 YAML 或不具备 YAMLResume 文档结构——会被反馈给模型并重试,默认最多重试 2 次。

使用 -r, --retry 并传入一个非负整数即可修改重试上限:

$ yamlresume ai import --retry 5 screenshot.png resume.yml

重试次数必须是一个非负的安全整数。负数、小数、2x 这类部分数字字符串以及不安全的整数都会被拒绝。使用 --retry 0 可在出现首个结构性错误时直接失败,不再重试。

验证与检查

导入采用尽力而为(best-effort)的验证方式。它要求 YAML 有效并具备 YAMLResume 文档结构,但会保留缺失的字段和值级别的 schema 问题,以免丢弃任何源信息。当生成的 YAML 仍存在 schema 问题时,命令会记录警告而不是直接失败。

之后可以运行 yamlresume validate,在构建前找出并修正遗留问题:

$ yamlresume validate resume.yml

程序化 API

@yamlresume/ai 包提供底层的导入 API。传入多个附件即可将它们视为同一份简历的多页:

import { importResume } from "@yamlresume/ai";
import { openai } from "@ai-sdk/openai";
import { readFileSync } from "node:fs";

const model = openai("gpt-5");
const data = readFileSync("resume.png");

const yaml = await importResume(
  { attachments: [{ data, mediaType: "image/png" }] },
  {
    model,
    // Optional: override locale detection
    language: "en",
  }
);

在 Node.js 中处理文件时,@yamlresume/node 提供 importResumeFile,它接受单个路径或有序的路径数组,并将导入的简历写入新文件。

Edit on GitHub

Last updated on

On this page