闲社服务运行正常AI智能体自动化平台
g

公式识别提取

技能标识:glmocr-formula

Official skill for recognizing and extracting mathematical formulas from images and PDFs into LaTeX format

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.3
检测标记
后台标记通过
免费
免费获取
1
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

公式识别提取

GLM-OCR Formula Recognition Skill / GLM-OCR 公式识别技能

Recognize mathematical formulas from images and PDFs and convert them to LaTeX format using the ZhiPu GLM-OCR layout parsing API.

When to Use / 使用场景

  • - Extract mathematical formulas from images or scanned documents / 从图片或扫描件中提取数学公式
  • Convert formula images to LaTeX / 将公式图片转为 LaTeX 格式
  • Recognize complex equations, integrals, matrices / 识别复杂方程、积分、矩阵
  • Parse scientific papers, textbooks, exam papers with formulas / 解析含公式的论文、教材、试卷
  • User mentions formula OCR, extract formula, 公式识别, 公式OCR, 提取公式, 图片转LaTeX

Key Features / 核心特性

  • - Complex formula support: Handles integrals, summations, matrices, fractions, radicals
  • LaTeX output: Formulas are output in LaTeX format, ready for use in documents
  • Inline & block formulas: Recognizes both inline and display-style formulas
  • Mixed content: Can handle documents with both text and formulas
  • Local file & URL: Supports both local files and remote URLs

Resource Links / 资源链接

ResourceLink
Get API Key智谱开放平台 API Keys
API Docs
Layout Parsing / 版面解析 |

Prerequisites / 前置条件

API Key Setup / API Key 配置(Required / 必需)

脚本通过 ZHIPUAPIKEY 环境变量获取密钥,可与其他智谱技能复用同一个 key。
This script reads the key from the ZHIPUAPIKEY environment variable. Reusing the same key across Zhipu skills is optional.

Get Key / 获取 Key: Visit 智谱开放平台 API Keys to create or copy your key.

Setup options / 配置方式(任选一种):

  1. 1. Global config (recommended) / 全局配置(推荐): Set once in openclaw.json under env.vars, all Zhipu skills will share it:

json
{
env: {
vars: {
ZHIPUAPIKEY: 你的密钥
}
}
}

  1. 2. Skill-level config / Skill 级别配置: Set for this skill only in openclaw.json:

json
{
skills: {
entries: {
glmocr-formula: {
env: {
ZHIPUAPIKEY: 你的密钥
}
}
}
}
}

  1. 3. Shell environment variable / Shell 环境变量: Add to ~/.zshrc:
bash export ZHIPUAPIKEY=你的密钥

💡 如果你已为其他智谱 skill(如 glmocr、glmv-caption、glm-image-generation)配置过 key,它们共享同一个 ZHIPUAPIKEY,无需重复配置。

Security & Transparency / 安全与透明度

  • - Environment variables used / 使用的环境变量:
- ZHIPUAPIKEY (required / 必需) - GLMOCRTIMEOUT (optional timeout seconds / 可选超时秒数)
  • - Fixed endpoint / 固定官方端点: https://open.bigmodel.cn/api/paas/v4/layout_parsing
  • No custom API URL override / 不支持自定义 API URL 覆盖: avoids accidental key exfiltration via redirected endpoints.
  • Raw upstream response is optional / 原始响应默认不返回: use --include-raw only when needed for debugging.

⛔ MANDATORY RESTRICTIONS / 强制限制 ⛔

  1. 1. ONLY use GLM-OCR API — Execute the script python scripts/glmocrcli.py
  2. NEVER parse formulas yourself — Do NOT try to extract formulas using built-in vision or any other method
  3. NEVER offer alternatives — Do NOT suggest I can try to read it or similar
  4. IF API fails — Display the error message and STOP immediately
  5. NO fallback methods — Do NOT attempt formula extraction any other way

📋 Output Display Rules / 输出展示规则

After running the script, present the OCR result clearly and safely.

  • - Show extracted text/formulas (text) in full
  • Summarization is allowed, but do not hide important extraction failures
  • If layout_details contains formula-related entries, you may highlight them
  • If the result file is saved, tell the user the file path
  • Show raw upstream response only when explicitly requested or debugging (--include-raw)

⚠️ LaTeX Rendering / LaTeX 渲染注意:

OCR API returns formulas in LaTeX format (e.g., $\frac{1}{2}$, $\theta^{x+1}$). Since most chat platforms do not render LaTeX, you should ask the user once (on first use):

OCR 结果包含 LaTeX 公式,需要我将公式转为 Unicode 可读格式展示,还是保留原始 LaTeX?

Remember the users choice for the rest of the session. Do NOT ask again on subsequent calls unless the user explicitly changes their preference.

  • - User chooses readable format → convert LaTeX to Unicode/plain-text:
LaTeXUnicode / 纯文本
$\frac{a}{b}$a/b
$x^{n}$
x^n | | $x_{i}$ | xᵢ | | $\sqrt{x}$ | √x | | $\theta$ | θ | | $\phi$ | φ | | $\therefore$ | ∴ | | $\Rightarrow$ | ⇒ | | $\left\{ \begin{array}{l} ... \end{array} \right.$ | ⎧ line1 ⎨ line2 ⎩ | | $\textcircled{1}$ | ① | | $\in$ | ∈ | | $\infty$ | ∞ | | $\ln$ | ln | | $\leq$ / $\geq$ | ≤ / ≥ |
  • - User chooses raw LaTeX → display the original LaTeX output directly, and remind them the raw data is also saved in the output file if --output was used.

How to Use / 使用方法

Extract from URL / 从 URL 提取

bash
python scripts/glmocrcli.py --file-url https://example.com/formula.png

Extract from Local File / 从本地文件提取

bash
python scripts/glmocrcli.py --file /path/to/equation.png

Save Result to File / 保存结果到文件

bash
python scripts/glmocrcli.py --file formula.png --output result.json --pretty

Include Raw Upstream Response (Debug Only) / 包含原始上游响应(仅调试)

bash
python scripts/glmocrcli.py --file formula.png --output result.json --include-raw

CLI Reference / CLI 参数

python {baseDir}/scripts/glmocrcli.py (--file-url URL | --file PATH) [--output FILE] [--pretty] [--include-raw]

ParameterRequiredDescription
--file-urlOne ofURL to image/PDF
--file
One of | Local file path to image/PDF | | --output, -o | No | Save result JSON to file | | --pretty | No | Pretty-print JSON output | | --include-raw | No | Include raw upstream API response in result field (debug only) |

Response Format / 响应格式

json
{
ok: true,
text: Extracted formulas and text in Markdown/LaTeX...,
layout_details: [...],
result: null,
error: null,
source: /path/to/file,
source_type: file,
rawresultincluded: false
}

Key fields:

  • - ok — whether extraction succeeded
  • text — extracted text in Markdown with LaTeX formulas
  • layout_details — layout analysis details
  • error

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 glmocr-formula-1776193393 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 glmocr-formula-1776193393 技能

通过命令行安装

skillhub install glmocr-formula-1776193393

下载

⬇ 下载 glmocr-formula v1.0.3(免费)

文件大小: 8.41 KB | 发布时间: 2026-4-17 14:57

v1.0.3 最新 2026-4-17 14:57
glm-ocr-formula v1.0.3 changelog

- Clarified this is the "official" formula extraction skill in the description.
- Updated supported emoji from "📄" to "📐" for better formula context.
- Improved and reorganized API key setup instructions, emphasizing global and skill-level config options.
- Added a dedicated "Security & Transparency" section—documenting use of fixed official API endpoints and preventing custom override for safety.
- Added optional CLI flag `--include-raw` to include raw upstream API responses for debugging.
- Restated output display rules and LaTeX rendering prompt for clarity and safer downstream usage.
- Updated API docs/resource URLs for improved accuracy and access.
返回顶部