extract-cite
🤖座席技能 - - - - - - npx skills@latest add https://github.com/OpenSourceAGI/qwksearch-research-agent --skill extract-cite (它涵盖了什么)
引用任何网页。两个传递:
extractCite:直接从HTML读取作者、日期、标题和来源(元标签、署名、JSON-LD、URL模式,以及可选的92k-name数据库,它告诉人们来自组织)。即时,离线,部分。extractCiteLLM一个模型调用(默认是OpenRouter),给出部分引用和部分缺失,完成完整的APA引用。 分数每一部分的自信, 标记部件以供审查,并阅读 作者资格 从页面的简介。输出在APA 7, MLA 9,芝加哥,哈佛,IEEE和BibTeX。同样的电话 检查内容:提取的文本是完整的文章还是付费墙存根,以及标题,导航,侧边栏和页脚块的可读性。
bun add extract-cite
import { extractCiteLLM } from "extract-cite";
const cite = await extractCiteLLM({
url: "https://www.npr.org/2023/12/28/1221827923/2023-hottest-year-record-climate-change",
apiKey: process.env.OPENROUTER_API_KEY, // default provider: OpenRouter
model: "anthropic/claude-haiku-4.5", // default
// baseUrl: "https://api.openai.com/v1" // any OpenAI-compatible API
});
cite.formatted.apa?.text; // full APA 7 entry
cite.formatted.mla?.html; // with <i> italics, HTML-escaped
cite.confidence; // { title: 0.98, publishedDate: 0.95, … }
cite.needsReview; // [{ field, confidence, reason }]
cite.citation.authors[0].qualifications; // { jobTitle, affiliation, credentials, evidence, … }
cite.contentCheck?.verdict; // "full" | "paywalled" | "truncated" | "blocked" | "not-article" | "unknown"
cite.contentCheck?.tips; // [{ region: "sidebar", selector: "aside.sidebar", example, tip }]
| 选项 | 默认的 | |
|---|---|---|
url / html / text | 该页面。一个 url 孤独是牵强;通过 html 或 text 对于阻止服务器的站点。 | |
apiKey | OPENROUTER_API_KEY | |
model | anthropic/claude-haiku-4.5 | |
baseUrl | https://openrouter.ai/api/v1 | |
styles | 所有 | apa, mla, chicago, harvard, ieee, bibtex |
reviewThreshold | 0.7 | 下面的部分进去 needsReview。 |
maxChars | 12000 | 发送到模型的页面文本(头和尾)。 |
content | 页面文本 | 你提取的文章(HTML或文本,例如提取网页 html),进行内容检查。 |
checkContent | true | 在同一个调用中运行内容检查。 |
contentWords | 3000 | 从一开始,支票上就写着内容。 |
fetch | 全球 | 替换 fetch 用于页面和模型调用。 |
纤细默认vs。 extract-cite/full
默认条目是slim (~60 kB):确实如此 不 绑定92k的人名JSON(约1 MB),因此个人对组织的检测只使用单词启发式。获取名称数据库:
// Lazy-load it from the jsDelivr CDN (shared, cached; resolves null on failure)
import { extractCite, loadHumanNamesDB } from "extract-cite";
await loadHumanNamesDB(); // or { url, fetch } to self-host
// Or bundle it: same API, names database registered on import
import { extractCite } from "extract-cite/full";
setHumanNamesDB(db) 注册您已持有的副本。两个条目共享一个数据库,因此导入 extract-cite/full 一旦启用它为苗条的导入。
内容检查
模型读取第一个 contentWords 的话语 content 以及页面块的轮廓(header.site-header (6 words) "Example Ledger Sign in…")和返回 contentCheck:一个 verdict, signals (“订阅继续阅读”) note 对于读者来说, contentSelector 保存文章主体,和 tips 对于杂乱的内容,仍然保留(标题、导航、侧边栏、页脚、广告、相关、时事通讯、分享、评论、cookie横幅)。 selectors 等于 { content, remove },在提取网页的条目的形状 extract-selectors-per-domain.json. 非判决 full 也在 needsReview 作为 field: "content"。
formatCitation(citation, style) 和 formatCitations(citation, styles) 离线重新设计结果。
它不会做什么
模型的回复不可信。文本被隔离为不可信的数据;字符串被去掉标记;日期必须是真实的;如果作者的名字从未出现在页面上,其置信度上限为0.2,并被标记;作者资格需要在页面上逐字引用,否则就会被删除。页面没有说明的部分返回空标记,而不是猜测。内容检查信号和示例必须在文本中,其选择器必须与页面上的元素匹配,否则它们将被删除。 还是: 检查 needsReview 在你引用之前。
从提取网页移动
extractCite, convertURLToDomain 和 isURLValid 过去住在 extract-webpage (src/html-to-cite). 这些代码被原封不动地搬到了这里; extract-webpage 再出口这三种产品,这样现有的进口就能继续运转。
演示
的引文选项卡 extract-pdf网站 (/demo#cite)针对新闻、期刊、组织和博客url运行此操作。
cd packages/extract-cite && bun run test