结构化输出(测试版)
结构化输出在 llamaParse API 中已被弃用,请改用 LlamaExtract API。
结构化输出允许您在解析阶段直接从文档中提取结构化数据(如JSON),从而降低所需成本和时间。
结构化输出目前仅与我们默认的解析模式兼容,可通过在API中设置structured_output=True来激活。
parser = LlamaParse( structured_output=True)curl -X 'POST' \ 'https://api.cloud.llamaindex.ai/api/v1/parsing/upload' \ -H 'accept: application/json' \ -H 'Content-Type: multipart/form-data' \ -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \ --form 'structured_output="true"' \ -F 'file=@/path/to/your/file.pdf;type=application/pdf'然后您需要提供以下任一选项:
- 一个 JSON 模式在
structured_output_json_schemaAPI 变量中,将用于以所需格式提取数据 - 或者变量
structured_output_json_schema_name中我们预定义模式之一的名称
parser = LlamaParse( structured_output_json_schema='A JSON SCHEMA')curl -X 'POST' \ 'https://api.cloud.llamaindex.ai/api/v1/parsing/upload' \ -H 'accept: application/json' \ -H 'Content-Type: multipart/form-data' \ -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \ --form 'structured_output_json_schema="A JSON SCHEMA"' \ -F 'file=@/path/to/your/file.pdf;type=application/pdf'parser = LlamaParse( structured_output_json_schema_name="invoice")curl -X 'POST' \ 'https://api.cloud.llamaindex.ai/api/v1/parsing/upload' \ -H 'accept: application/json' \ -H 'Content-Type: multipart/form-data' \ -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \ --form 'structured_output_json_schema_name="invoice"' \ -F 'file=@/path/to/your/file.pdf;type=application/pdf'imFeelingLucky
Section titled “imFeelingLucky”允许LlamaParse推断输出格式的通配符模式
curl -X 'POST' \ 'https://api.cloud.llamaindex.ai/api/v1/parsing/upload' \ -H 'accept: application/json' \ -H 'Content-Type: multipart/form-data' \ -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \ --form 'structured_output_json_schema_name="imFeelingLucky"' \ -F 'file=@/path/to/your/file.pdf;type=application/pdf'标准发票模式,适用于明细项目、税费和总计
curl -X 'POST' \ 'https://api.cloud.llamaindex.ai/api/v1/parsing/upload' \ -H 'accept: application/json' \ -H 'Content-Type: multipart/form-data' \ -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \ --form 'structured_output_json_schema_name="invoice"' \ -F 'file=@/path/to/your/file.pdf;type=application/pdf'类型:stringobject
属性
- invoiceNumber
required- 发票的唯一标识符
- 类型:
string
- invoiceDate
required- 发票开具日期(ISO格式)
- 类型:
string - 字符串格式必须为“日期”
-
dueDate
- 付款截止日期(ISO格式)
- 类型:
string - 字符串格式必须为“日期”
- billingAddress
required- 账单地址详情
- 类型:
object - Properties
- name
required- 类型:
string
- 类型:
- street
required- 类型:
string
- 类型:
- city
required- 类型:string
string
- 类型:string
-
state
- 类型:string
string
- 类型:string
- postalCode
required- 类型:string
string
- 类型:string
- country
required- 类型:string
string
- 类型:string
- name
-
shippingAddress
- 收货地址详情
- 类型:string
object - Properties
- name
required- 类型:string
string
- 类型:string
- street
required- 类型:string
string
- 类型:string
- city
required- 类型:string
string
- 类型:string
-
state
- 类型:string
string
- 类型:string
- postalCode
required- 类型:string
string
- 类型:string
- country
required- 类型:string
string
- 类型:string
- name
- items
required- 发票中包含的项目列表
- Type:
array- 项目
- 类型:string
object - Properties
- description
required- 项目描述
- 类型:string
string
- quantity
required- 商品数量
- 类型:string
number - 范围:≥ 1
- unitPrice
required- 商品单价
- 类型:object
number - 范围:≥ 0
- totalPrice
required- 此商品总价
- 类型:object
number - 范围:≥ 0
- description
- subTotal
required- 所有项目小计
- 类型:string
number - 范围:≥ 0
- tax
required- 税务详情
- 类型:string
object - Properties
- rate
required- 税率百分比
- 类型:string
number - 范围:≥ 0
- amount
required- 税费总额
- 类型:string
number - 范围:≥ 0
- rate
- total
required- 应付总额(小计 + 税费)
- 类型:string
number - 范围:≥ 0
-
notes
- 发票的附加说明或指示
- 类型:string
string
- status
required- 发票的当前付款状态
- 类型:string
string - 该值仅限于以下选项:
- “已支付”
- “未支付”
- “逾期”
遵循 JSON 简历标准
curl -X 'POST' \ 'https://api.cloud.llamaindex.ai/api/v1/parsing/upload' \ -H 'accept: application/json' \ -H 'Content-Type: multipart/form-data' \ -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \ --form 'structured_output_json_schema_name="resume"' \ -F 'file=@/path/to/your/file.pdf;type=application/pdf'基于 https://github.com/jsonresume/resume-schema
类型:stringobject
属性
-
basics
- 类型:string
object - Properties
-
name
- 类型:string
string
- 类型:string
-
label
- 例如:网页开发者
- 类型:string
string
-
image
- 符合 RFC 3986 标准的 JPEG 或 PNG 格式图像 URL
- 类型:string
string
-
email
- e.g. thomas@gmail.com
- 类型:string
string - 字符串格式必须为“邮箱”
-
phone
- 电话号码以字符串形式存储,因此您可以使用任意格式,例如 712-117-2923
- 类型:string
string
-
url
- 指向您网站的URL(遵循RFC 3986标准),例如个人主页
- 类型:string
string - 字符串格式必须为“uri”
-
summary
- 写一段2-3句的简短自我介绍
- 类型:string
string
-
location
- 类型:string
object - Properties
-
address
- 类型:string
string
- 类型:string
-
postalCode
- 类型:string
string
- 类型:string
-
city
- 类型:string
string
- 类型:string
-
countryCode
- 代码遵循 ISO-3166-1 ALPHA-2 标准,例如 US(美国)、AU(澳大利亚)、IN(印度)
- 类型:string
string
-
region
- 您居住的大致区域。例如,可以是美国的一个州或一个省份。
- 类型:string
string
-
address
- 类型:string
-
profiles
- 指定您参与的任何数量的社交网络
- Type:
array- 项目
- 类型:string
object - 此模式接受额外的属性。
- Properties
-
network
- 例如 Facebook 或 Twitter
- 类型:string
string
-
username
- e.g. neutralthoughts
- 类型:string
string
-
url
- e.g. http://twitter.example.com/neutralthoughts
- 类型:string
string - 字符串格式必须为“uri”
-
network
-
name
- 类型:string
-
work
- Type:
array- 项目
- 类型:string
object - Properties
-
name
- e.g. Facebook
- 类型:string
string
-
location
- 例如:加州门洛帕克
- 类型:string
string
-
description
- 例如:社交媒体公司
- 类型:string
string
-
position
- 例如:软件工程师
- 类型:string
string
-
url
- e.g. http://facebook.example.com
- 类型:string
string - 字符串格式必须为“uri”
-
startDate
- $ref: #/definitions/iso8601
-
endDate
- $ref: #/definitions/iso8601
-
summary
- 概述你在公司的职责
- 类型:string
string
-
highlights
- 指定多项成就
- Type:
array- 项目
- 例如:通过病毒式广告在2011年至2012年间将利润提升了20%
- 类型:string
string
-
name
- Type:
-
volunteer
- Type:
array- 项目
- 类型:string
object - Properties
-
organization
- e.g. Facebook
- 类型:string
string
-
position
- 例如:软件工程师
- 类型:string
string
-
url
- e.g. http://facebook.example.com
- 类型:string
string - 字符串格式必须为“uri”
-
startDate
- $ref: #/definitions/iso8601
-
endDate
- $ref: #/definitions/iso8601
-
summary
- 概述你在公司的职责
- 类型:string
string
-
highlights
- 指定成就和成果
- Type:
array- 项目
- 例如:通过病毒式广告在2011年至2012年间将利润提升了20%
- 类型:string
string
-
organization
- Type:
-
education
- Type:
array- 项目
- 类型:string
object - Properties
-
institution
- 例如:麻省理工学院
- 类型:string
string
-
url
- e.g. http://facebook.example.com
- 类型:string
string - 字符串格式必须为“uri”
-
area
- e.g. Arts
- 类型:string
string
-
studyType
- e.g. Bachelor
- 类型:string
string
-
startDate
- $ref: #/definitions/iso8601
-
endDate
- $ref: #/definitions/iso8601
-
score
- 平均绩点,例如 3.67/4.0
- 类型:string
string
-
courses
- 列出值得关注的课程/科目
- Type:
array- 项目
- 例如:H1302 - 美国历史导论
- 类型:string
string
-
institution
- Type:
-
awards
- 请注明您在整个职业生涯中获得的任何奖项
- Type:
array- 项目
- 类型:string
object - Properties
-
title
- 例如:本世纪最伟大的百位智者之一
- 类型:string
string
-
date
- $ref: #/definitions/iso8601
-
awarder
- 例如:《时代》杂志
- 类型:string
string
-
summary
- 例如:因我在量子物理学领域的工作而获得
- 类型:string
string
-
title
-
certificates
- 请注明您在职业生涯中获得的任何证书
- Type:
array- 项目
- 类型:string
object - 此模式接受额外的属性。
- Properties
-
name
- 例如:认证 Kubernetes 管理员
- 类型:string
string
-
date
- $ref: #/definitions/iso8601
-
url
- e.g. http://example.com
- 类型:string
string - 字符串格式必须为“uri”
-
issuer
- e.g. CNCF
- 类型:string
string
-
name
-
publications
- 通过您的职业生涯指定您的出版物
- Type:
array- 项目
- 类型:string
object - Properties
-
name
- 例如:万维网
- 类型:string
string
-
publisher
- 例如:IEEE、计算机杂志
- 类型:string
string
-
releaseDate
- $ref: #/definitions/iso8601
-
url
- e.g. http://www.computer.org.example.com/csdl/mags/co/1996/10/rx069-abs.html
- 类型:string
string - 字符串格式必须为“uri”
-
summary
- 出版物简短摘要。例如:关于万维网、HTTP、HTML的讨论。
- 类型:string
string
-
name
-
skills
- 列出你的专业技能组合
- Type:
array- 项目
- 类型:string
object - 此模式接受额外的属性。
- Properties
-
name
- 例如:网页开发
- 类型:string
string
-
level
- e.g. Master
- 类型:string
string
-
keywords
- 列出与此技能相关的一些关键词
- Type:
array- 项目
- e.g. HTML
- 类型:string
string
-
name
-
languages
- 列出您掌握的其他语言
- Type:
array- 项目
- 类型:string
object - Properties
-
language
- 例如:英语、西班牙语
- 类型:string
string
-
fluency
- 例如:流利、初学者
- 类型:string
string
-
language
-
interests
- Type:
array- 项目
- 类型:string
object - Properties
-
name
- e.g. Philosophy
- 类型:string
string
-
keywords
- Type:
array- 项目
- 例如:弗里德里希·尼采
- 类型:string
string
- Type:
-
name
- Type:
-
references
- 列出您已收到的推荐信
- Type:
array- 项目
- 类型:string
object - Properties
-
name
- 例如:蒂莫西·库克
- 类型:string
string
-
reference
- 例如:乔·博客是一位优秀的员工,他每周至少来上班一次。在无所事事方面,他超出了我的预期。
- 类型:string
string
-
name
-
projects
- 指定职业项目
- Type:
array- 项目
- 类型:string
object - Properties
-
name
- 例如:万维网
- 类型:string
string
-
description
- 项目简短摘要。例如:2017年汇编作品。
- 类型:string
string
-
highlights
- 指定多个功能
- Type:
array- 项目
- 例如:指引你接近但未完全到位
- 类型:string
string
-
keywords
- 指定涉及的特殊元素
- Type:
array- 项目
- e.g. AngularJS
- 类型:string
string
-
startDate
- $ref: #/definitions/iso8601
-
endDate
- $ref: #/definitions/iso8601
-
url
- e.g. http://www.computer.org/csdl/mags/co/1996/10/rx069-abs.html
- 类型:string
string - 字符串格式必须为“uri”
-
roles
- 在此项目或公司中指定您的角色
- Type:
array- 项目
- 例如:团队负责人、演讲者、写作者
- 类型:string
string
-
entity
- 指定相关的公司/实体关联,例如‘绿色和平组织’、‘XYZ公司’
- 类型:string
string
-
type
- _ 例如:‘志愿服务’、‘演示’、‘演讲’、‘申请’、‘会议’_
- 类型:string
string
-
name