Build a Literature Review Agent with Sciverse
AgentRAGIntermediate
Build a Literature Review Agent with Sciverse
Start from one research question, retrieve evidence, summarize papers, and generate a cited literature review
Scenario
Researchers or AI agents need to automatically retrieve relevant papers, extract evidence passages, and generate a cited literature review for a research question.
Estimated calls
~15-30 API calls per review task
Tools
agentic-searchcontentPipeline
agentic-search→ doc_id + chunk + offset→ content→ evidence markdown
Input example
User asks in Claude / Cursor: "Please review the applications of Transformers in protein structure prediction from 2020 to 2024, and list key papers and core contributions."
Output example
## Literature Review: Transformer Applications in Protein Structure Prediction (2020-2024) ### 1. The AlphaFold2 breakthrough Jumper et al. (2021) proposed AlphaFold2, using the Evoformer module... [Source: Nature, doc_id: af2_xxx, offset: 12480] ### 2. End-to-end prediction with ESMFold Lin et al. (2023) proposed ESMFold... [Source: Science, doc_id: esm_yyy, offset: 8320] --- Retrieved 12 core papers and extracted 28 evidence passages.
Agent Prompt example
You are a scientific literature review agent. When the user provides a research question:
1. Call agentic-search(query=user question, top_k=20) to retrieve relevant passages
2. For each high-scoring passage, call content(doc_id=hit.doc_id, offset=hit.offset, limit=2000) to read context
3. Organize a structured review, and cite every claim with [doc_id, offset]
4. Do not fabricate references; every statement must be grounded in Sciverse resultsImplementation steps
Step 1: Set up the environment
Install dependencies and configure API tokens
# 安装所需 Python 包
!pip install httpx anthropic
# 设置环境变量(替换为你的真实 Token)
import os
os.environ["SCIVERSE_API_TOKEN"] = "sv-your-token-here" # 替换为你的真实值
import os
os.environ["ANTHROPIC_API_KEY"] = "sk-ant-..." # 替换为你的真实值
Step 2: Retrieve relevant passages semantically
Use agentic-search to retrieve paper passages most relevant to the research question
import os
import asyncio
import httpx
BASE = "https://api.sciverse.space"
TOKEN = os.environ["SCIVERSE_API_TOKEN"]
HEADERS = {"Authorization": f"Bearer {TOKEN}"}
async def search_literature(query: str, top_k: int = 20):
async with httpx.AsyncClient(timeout=30) as client:
resp = await client.post(
f"{BASE}/agentic-search",
headers=HEADERS,
json={"query": query, "top_k": top_k}
)
resp.raise_for_status()
return (resp.json().get("hits") or [])
async def main():
hits = await search_literature(
"Transformer applications in protein structure prediction 2020-2024"
)
print(f"Found {len(hits)} relevant chunks")
for h in hits[:3]:
print(f" [{h['score']:.2f}] {h['title'][:60]}...")
return hits
hits = await main()
Step 3: Read source context
Call the content endpoint for high-scoring passages to read broader context
async def read_context(doc_id: str, offset: int = 0, limit: int = 2000):
"""读取指定文档的原文片段。返回 {text, next_offset, more}"""
async with httpx.AsyncClient(timeout=30) as client:
resp = await client.get(
f"{BASE}/content",
headers=HEADERS,
params={"doc_id": doc_id, "offset": offset, "limit": limit}
)
resp.raise_for_status()
return resp.json()
async def gather_evidence(hits, top_n=5):
sorted_hits = sorted(hits, key=lambda x: x["score"], reverse=True)[:top_n]
evidences = []
for hit in sorted_hits:
ctx = await read_context(hit["doc_id"], hit.get("offset", 0))
evidences.append({
"title": hit["title"],
"doc_id": hit["doc_id"],
"offset": hit.get("offset", 0),
"chunk": hit.get("chunk", ""),
"context": ctx["text"], # 注意:响应字段是 text
"score": hit["score"]
})
return evidences
evidences = await gather_evidence(hits)
Step 4: Generate a cited review (optional enhancement)
Use an LLM to synthesize the extracted evidence into a structured review
from anthropic import Anthropic
client = Anthropic() # 自动读取 ANTHROPIC_API_KEY
evidence_text = "\
\
".join([
f"[{e['doc_id']}, offset={e['offset']}] {e['title']}\
{e['context']}"
for e in evidences
])
msg = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=4096,
messages=[{
"role": "user",
"content": f"""基于以下文献证据,生成一份关于 Transformer 在蛋白质结构预测中应用的综述。
每个论点必须标注来源 [doc_id, offset]。
不要编造任何未在证据中出现的信息。
{evidence_text}"""
}]
)
print(msg.content[0].text)
Notes
- Do not cite papers that were not returned by Sciverse.
- Keep doc_id and offset in every evidence record so users can trace each claim.
- Use content to read more context before summarizing when a retrieved chunk is too short.
- Use top_k carefully; larger values improve recall but increase latency and downstream LLM cost.
- For formal writing, keep evidence extraction and final writing as two separate steps.
FAQ
适合什么综述场景?
适合从开放研究问题出发生成初版文献综述,并保留引用证据。
如何保证综述可追溯?
每个结论都应绑定 doc_id、quote 和 offset,不能只输出模型总结。
需要人工复核吗?
需要,Agent 适合生成初稿和证据包,最终观点仍应由研究者确认。
和普通搜索结果有什么区别?
本案例强调证据链、上下文和引用位置,而不是只返回论文列表。
Next steps
Need an API key?
Create one in Console > Tokens.The same API key works for enabled Sciverse, DianShi, and Skills capabilities, with starter quota available according to account permissions.