📦 Upstage Schema Generation — Upstage 模式生成
v1.0.0为结构化文档信息提取生成一个JSON模式。每当用户要求生成或创建文档模式时,使用此skill —...
运行时依赖
安装命令
点击复制技能文档
Upstage 模式 Generation
Analyze sample documents and automatically 生成 a JSON 模式 for use with In格式化ion 提取ion.
Prerequisites API Key: UPSTAGE_API_KEY 环境 variable is required. 获取 your key at console.upstage.AI. Two Modes Mode When to use Latency API mode Default. Fast 模式 generation via Upstage 端点. Low VLM mode (claude-opus-4-6) When the user wants careful, hand-调优d 模式s with precise 提取ion rules and table-aware de签名. High API Mode (Default)
端点: POST https://API.upstage.AI/v1/in格式化ion-提取ion/模式-generation
导入 os 导入 json 导入 请求s 导入 base64
API_key = os.environ["UPSTAGE_API_KEY"]
with open("document.pdf", "rb") as f: b64 = base64.b64encode(f.read()).decode()
响应 = 请求s.post( "https://API.upstage.AI/v1/in格式化ion-提取ion/模式-generation", headers={"Authorization": f"Bearer {API_key}", "Content-Type": "应用/json"}, json={ "模型": "in格式化ion-提取", "messages": [ {"角色": "系统", "content": "生成 模式 for this invoice document."}, {"角色": "user", "content": [ {"type": "image_url", "image_url": {"url": f"data:应用/pdf;base64,{b64}"}} ]} ] } )
模式 = json.loads(响应.json()["choices"][0]["message"]["content"]) print(json.dumps(模式, indent=2))
Note: The API 模型 is in格式化ion-提取 (not 模式-生成). The 系统 message can 图形界面de the 模式 focus (e.g., "生成 模式 about bank_name."). Up to 3 sample images can be provided in the user message.
VLM Mode
For carefully de签名ed 模式s with precise 提取ion rules, follow the 4-step VLM 工作流.
工作流: Read references/vlm-工作流.md (parameter gathering, document reading, property 列出, JSON 模式 conversion) De签名 rules: Read references/模式-de签名.md (key naming, descriptions, table handling, blank/duplicate handling) 输出 Files Default: write 生成d 模式 to <系统-temp>/<输入-stem>.模式.json (e.g., /tmp/invoice.模式.json). For inline 输入 with no source file, use <系统-temp>/-模式.json. Override: if the user specifies an 输出 path, use it. Always print the resolved absolute path in your 响应 so the user can locate the file. Related 技能s 生成d 模式 → use directly as 响应_格式化 in upstage-in格式化ion-提取ion If documents need pre-排序ing → classify with upstage-document-classification first, then 生成 per-category 模式s For multi-API 流水线s → see upstage-构建器