文档摘要
Discuse 可通过 POST /api/v2/summarize 将长文本或文档压缩成简短摘要。你可以发送原始文本(最多 100,000 个字符)或最多 5 个文档 URL,然后会得到一段通俗易懂的 summary——这对于在人工审核员阅读完整内容之前,先快速了解长报告、工单或上传文件的大意非常有用。
什么时候适合使用摘要功能?
审核队列里常常堆满长内容:支持对话串、粘贴的文章、多页 PDF、服务条款投诉等。如果审核员必须逐字阅读,速度会很慢,成本也很高。摘要可以让审核员一眼完成初步分流——判断哪些内容需要完整阅读,哪些可以快速放行或转交处理。
如何对内容进行摘要?
提供 text 或 file_urls 之一(必须提供其中一个)。使用 file_urls 时,Discuse 会先从文档中提取文本,然后再生成摘要。
摘要原始文本
curl -X POST https://api.discuse.com/api/v2/summarize \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"text": "Long support thread or article text here..."
}'
摘要文档
curl -X POST https://api.discuse.com/api/v2/summarize \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"file_urls": ["https://example.com/user-report.pdf"]
}'
响应
{
"summary": "A user reports repeated harassment from another account over three days, including direct messages and comments. They have screenshots and request the account be reviewed.",
"usage": {
"api_requests_used": 87,
"api_requests_limit": 500,
"api_requests_remaining": 413
}
}
请求字段
| 字段 | 类型 | 说明 |
|---|---|---|
api_key |
string | 可选,可放在请求体中;也可以改用 X-API-Key 发送 |
text |
string | 要生成摘要的文本,最多 100,000 个字符 |
file_urls |
string[] | 要读取并生成摘要的文档 URL,最多 5 个 |
提供 text 或 file_urls 之一。如果两者都发送,将使用 text。
响应字段
| 字段 | 类型 | 描述 |
|---|---|---|
summary |
string | 生成的摘要 |
usage |
object | api_requests_used, api_requests_limit, api_requests_remaining |
使用限制
摘要是付费套餐功能;每生成一次摘要,都会从你的文档摘要配额中扣除一次。
| 套餐 | 每月摘要次数 | 超额费用 |
|---|---|---|
| Basic | 不可用 | - |
| Gold | 100 | $0.02/summary |
| Platinum | 500 | $0.017/summary(15% 折扣) |
| Ultimate | 2,000 | $0.015/summary(25% 折扣) |
如果项目没有有效订阅,摘要请求将被拒绝。
最佳实践
用摘要做分流,不要用它做决定
摘要是给人工审核员使用的阅读辅助工具,不是审核结论。用它来确定队列优先级,然后再将原始内容提交到 POST /api/v2/check(或在 OCR 过程中进行审核),以做出真正的政策判断。
与 OCR 搭配处理扫描文档
file_urls 在生成摘要前已经会运行 OCR,因此扫描版 PDF 或文字图片可以直接使用——无需单独调用 OCR。
注意长度上限
text 的上限为 100,000 个字符。对于更长的源材料,可以分段生成摘要后再合并,或将文档作为 URL 传入。
集成示例
Node.js
async function summarize({ text, fileUrls }) {
const response = await fetch('https://api.discuse.com/api/v2/summarize', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.DISCUSE_API_KEY
},
body: JSON.stringify(text ? { text } : { file_urls: fileUrls })
});
return response.json();
}
Python
import os
import requests
def summarize(text=None, file_urls=None):
payload = {'text': text} if text else {'file_urls': file_urls}
response = requests.post(
'https://api.discuse.com/api/v2/summarize',
headers={
'Content-Type': 'application/json',
'X-API-Key': os.environ['DISCUSE_API_KEY']
},
json=payload
)
return response.json()
准备好加快你的审核队列了吗?开始使用 Discuse.