1 Star 0 Fork 5

l0o0/zotero-magic-for-user

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
outline-summary.yaml 3.76 KB
一键复制 编辑 原始数据 按行查看 历史
l0o0 提交于 2023-11-02 04:53 . template: 添加期刊标签信息
# This template is specifically for importing/sharing, using better
# notes 'import from clipboard': copy the content and
# goto Zotero menu bar, click Edit->New Template from Clipboard.
# Do not copy-paste this to better notes template editor directly.
name: "[text] Outline Summary"
content: |-
// @use-markdown
// @author Polygon
// @link https://gitee.com/zotero-chinese/zotero-magic-for-user/blob/master/outline-summary.yaml
// @warning 自动解析文献的基本结构并分部分总结
${{
// ✍️可修改[0]为[1]
sharedObj.by = ["Magic", "Grobid"][0]
// ✍️可修改"简体中文"为"其它语言"
sharedObj.language = "简体中文"
sharedObj.itemID = targetNoteItem ? (await targetNoteItem.parentItem.getBestAttachment()).id: undefined;
sharedObj.setGPTText = async (text) => {
const window = Zotero.getMainWindow()
await window.Meet.Global.views.show()
window.Meet.Global.views.inputContainer.querySelector("input").value = text
}
sharedObj.getBasicInfo = async () => {
return await Zotero.ZoteroMagic.api.paperSummary.getBasicInfo(sharedObj.by, sharedObj.itemID)
}
sharedObj.getSectionInfo = async (keywords) => {
return await Zotero.ZoteroMagic.api.paperSummary.getSectionInfo(keywords, sharedObj.by, sharedObj.itemID)
}
sharedObj.setGPTSystemMsg = () => {
const window = Zotero.getMainWindow()
window.Meet.Global.views.messages = [
{
"role": "system",
"content": "You are a researcher in the field of [___studyField___] who is good at summarizing papers using concise statements"
}
]
}
sharedObj.getGPTResponseText = async (question) => {
if (_env.dryRun) {return "GPT回答内容"}
const window = Zotero.getMainWindow()
return await window.Meet.Global.views.execText(question)
}
if (Zotero.ZoteroStyle.api.renderCell) {
pubtitle = Zotero.ZoteroStyle.api.renderCell(targetNoteItem.parentItem, "PublicationTags").innerText
}
return `# Magic Zotero Outline Summary大纲总结\n⏰创建时间:${new Date().toLocaleString()}` + (pubtitle ? "\n🎯期刊标签:" + pubtitle : "")
}}$
${{
const outline = {}
const getOutline = (outline, levels) => {
levels.forEach(level => {
if (!outline[level]) {
outline[level] = {text: ""}
}
outline = outline[level]
})
return outline
}
await Zotero.ZoteroMagic.api.paperSummary.PDFParserInstance.process(
async (paragraph, levels) => {
let _outline = getOutline(outline, levels)
_outline.text += (paragraph.text + "\n")
},
sharedObj.itemID
)
const window = Zotero.getMainWindow()
window.console.log(outline)
let result = ""
for (let key in outline) {
window.console.log(key)
sharedObj.setGPTSystemMsg()
await sharedObj.setGPTText(`正在总结[${key}]...`)
result +=
await sharedObj.getGPTResponseText(`
按照下面要求:
- 用精炼的语言,适当的排版,总结本段文字内容;
- 善用MD语言,你正处于MD文档环境中;
- 每个部分不要超过200字;
- 保留子标题,标题按照## xxx的md语法分级显示,但也要进行翻译;
- 适当使用emoj,丰富输出结果;
- 善用md语法,尽可能分要点;
- 语言一定要精炼,不要单纯重复原文;
- 直接输出总结结果,不要表现出总结二字,你只是对原文的转述;
- 文字如果过长请注意分段;
- 除了专有名词,所有输出文字请转化为${sharedObj.language};
你要总结的内容是:
${JSON.stringify(outline[key])}
`)
result += "\n\n"
}
return result
}}$
${{
const window = Zotero.getMainWindow()
window.Meet.Global.views.hide()
return ""
}}$
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/l0o0/zotero-magic-for-user.git
git@gitee.com:l0o0/zotero-magic-for-user.git
l0o0
zotero-magic-for-user
zotero-magic-for-user
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385