Skip to content
LlamaParse 文档版本 跟随上游 源快照 31df54ed 更新于 2026-10-16

agentic_options.custom_prompt 让你像给 LLM 下指令一样给 Parse 的智能体模型下指令:说明文档类型、要关注或跳过什么、要求保留某种格式。这个提示词会塑造 Parse 为该任务产出的 markdown 与 items。它在 cost_effective、agentic 与 agentic_plus 上可用;fast 档不运行任何智能体模型,会拒绝 agentic_options。

什么时候用它

  • 补上解析器无从推断的文档背景:“这是一份财务 10-K”、“提供的文档是一张餐厅小票”。
  • 保留某种格式:每个数字都带货币符号、日期写成 YYYY-MM-DD、保留原有章节层级。
  • 把输出收窄到你关心的部分,例如小票上的逐项明细与总额。
  • 遇到不寻常的版式时,用描述来改善结果。

提示词起的是引导作用,并不保证输出形态。当你需要一定符合 schema 的 JSON 时,请对同一文档改用 Extract。

选项

选项类型默认值作用
agentic_options.custom_promptstring未设给智能体解析器的自然语言指令,作用于整个任务。fast 档不可用。

agentic_options 是顶层请求字段,不属于 processing_options。改动提示词就等于改动解析参数,因此用新提示词重跑会自动绕过结果缓存。

怎么写一个管用的提示词

  • 写得具体,并点明文档类型。
  • 除了要说保留什么,也要说跳过什么。
  • 在关键处指明你想要的输出格式。
  • 保持简短:两三句最合适。

示例

从小票示例 下载那张小票图片:

终端窗口

curl -fL -o mcdonalds_receipt.png https://raw.githubusercontent.com/run-llama/llama_cloud_services/main/examples/parse/parsing_instructions/mcdonalds_receipt.png

上传它并在其上跑两个 Parse 任务:一个不加任何指令,另一个加一个只保留逐项明细与应付金额的提示词:

from llama_cloud import LlamaCloud

client = LlamaCloud()  # reads LLAMA_CLOUD_API_KEY from the environment

file = client.files.create(file="./mcdonalds_receipt.png", purpose="parse")

vanilla = client.parsing.parse(
    file_id=file.id,
    tier="agentic",
    version="latest",
    expand=["markdown"],
)
print(vanilla.markdown.pages[0].markdown)

with_prompt = client.parsing.parse(
    file_id=file.id,
    tier="agentic",
    version="latest",
    agentic_options={
        "custom_prompt": (
            "The provided document is a restaurant receipt. "
            "Provide ONLY each line item (item name and price) and the final amount to be paid."
        )
    },
    expand=["markdown"],
)
print(with_prompt.markdown.pages[0].markdown)

你会拿到什么

不加指令时,小票示例 会把整张小票作为 markdown 返回:调研横幅、门店地址、一张订单表、合计,以及底部的招聘告示:

## McDonald's Restaurant #31278
2378 PINE RD NW
RICE, MN 56367-9740

| Item                     | Price |
|--------------------------|-------|
| 1 Happy Meal 6 Pc        | 4.89  |
| 1 Snack Oreo McFlurry    | 2.69  |

| Subtotal                 | 7.58  |
| Tax                      | 0.52  |
| Take-Out Total           | 8.10  |

加上提示词后,同一页会被收窄到只剩逐项明细与总额:

* Happy Meal 6 Pc 4.89
* Snack Oreo McFlurry 2.69

Take-Out Total 8.10

配方 页里的提示词展示了另一种常见写法:保留全部内容但强制约定 —— “This is a financial 10-K. Preserve currency symbols on every number and keep the original section hierarchy.”

另请参阅

BytesRouter 是社区翻译站点,所有译文仅供参考,一切以官方英文原文为准。