Skip to main content

An academic paper writing agent based on LangGraph

Project description

seele-scholar-agent

English | 简体中文 | 日本語

PyPI version Python version CI License

LangGraph-based academic paper writing agent for topic proposal, literature retrieval, outline planning, section drafting, review loops, consistency checks, and reference generation.

Features

  • Search papers from OpenAlex, Semantic Scholar, ArXiv, and custom retrievers.
  • Propose concrete paper topics from broad research directions.
  • Generate structured outlines with suggested figures and tables.
  • Draft sections with numbered citations and optional RAG context.
  • Review sections, revise drafts, and cap revisions per section.
  • Generate references with CrossRef metadata enrichment.
  • Check terminology, logic, and citation consistency after references are generated.
  • Stream node output with astream() for UI integration.

Install

git clone https://github.com/onekyuu/seele-scholar-agent
cd seele-scholar-agent

uv sync

For development dependencies:

uv sync --extra dev

Configuration

This package only owns agent-level configuration. LLM keys and models are injected by the caller.

Agent .env file:

cp src/seele_scholar_agent/.env.example src/seele_scholar_agent/.env

Supported agent variables:

Variable Description Default
SEMANTIC_SCHOLAR_API_KEY Optional Semantic Scholar API key empty
MAX_REVISIONS Max review cycles per section 3

Example caller environment:

OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4o-mini
OPENAI_BASE_URL=https://api.openai.com/v1

Any OpenAI-compatible endpoint can be used through ChatOpenAI.

Quick Start

Run the no-interrupt workflow:

export OPENAI_API_KEY="sk-..."
export SCHOLAR_TOPIC="large language model interpretability"
export SCHOLAR_LANGUAGE="zh"

uv run python examples/simple_workflow.py

Use the graph in your own code:

from langchain_openai import ChatOpenAI

from seele_scholar_agent.graph import create_simple_writing_graph
from examples.common import build_initial_state, build_prompts

model = ChatOpenAI(model="gpt-4o-mini", api_key="sk-...")
state = build_initial_state("large language model interpretability")

app = create_simple_writing_graph(
    model=model,
    prompts=build_prompts(),
    rag_retriever=None,
)

result = await app.ainvoke(
    state,
    config={"configurable": {"thread_id": state["thread_id"]}},
)

Examples

Large runnable examples live in examples/:

File Purpose
examples/common.py Shared model, prompt, and initial-state helpers
examples/simple_workflow.py Full automatic workflow with create_simple_writing_graph
examples/full_workflow_with_interrupts.py Human-in-the-loop topic and outline approval
examples/custom_retrievers.py Inject custom RAG and paper retrievers
examples/stream_nodes.py Stream a single node with astream()
examples/figure_placeholders.py Parse {{FIGURE: ...}} and {{TABLE: ...}} placeholders

Run any example from the repository root:

uv run python examples/full_workflow_with_interrupts.py

Core API

The package exposes two graph builders:

from seele_scholar_agent.graph import create_simple_writing_graph, create_writing_graph
  • create_writing_graph(...): includes interrupts after topic proposal and outline planning.
  • create_simple_writing_graph(...): runs without interrupts and is useful for tests or batch jobs.

Both require:

  • model: a ChatOpenAI instance or compatible LangChain chat model.
  • prompts: a complete PromptsConfig.
  • rag_retriever: optional Callable[[str], Awaitable[list[DocumentChunk]]].

Optional paper sources can be injected with extra_paper_retrievers.

Workflow

START
  -> topic_proposer
  -> researcher
  -> planner
  -> writer <-> reviewer
  -> finalizer
  -> reference_generator
  -> consistency_checker
  -> END

create_writing_graph() interrupts after topic_proposer and planner so the caller can choose a topic and approve the outline.

Project Structure

src/seele_scholar_agent/
├── agent_config.py
├── config.py
├── graph.py
├── i18n.py
├── logging.py
├── state.py
├── nodes/
│   ├── topic_proposer.py
│   ├── researcher.py
│   ├── planner.py
│   ├── writer.py
│   ├── reviewer.py
│   ├── finalizer.py
│   ├── reference_generator.py
│   └── consistency_checker.py
└── tools/
    └── crossref.py

Development

uv run pytest
uv run ruff check src/
uv run mypy src/

Build the package:

uv build

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seele_scholar_agent-0.11.2.tar.gz (236.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seele_scholar_agent-0.11.2-py3-none-any.whl (34.0 kB view details)

Uploaded Python 3

File details

Details for the file seele_scholar_agent-0.11.2.tar.gz.

File metadata

  • Download URL: seele_scholar_agent-0.11.2.tar.gz
  • Upload date:
  • Size: 236.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for seele_scholar_agent-0.11.2.tar.gz
Algorithm Hash digest
SHA256 48b853169b7d2e3c313dd9747e5d8e7995bca601a1545185f1b686eb26282ef5
MD5 d2e566202c4344a96af9e6644401ab37
BLAKE2b-256 fd2d34a3710e8c2ce353127a5e6b7b2823c72657cb375378dbe433029c404755

See more details on using hashes here.

File details

Details for the file seele_scholar_agent-0.11.2-py3-none-any.whl.

File metadata

  • Download URL: seele_scholar_agent-0.11.2-py3-none-any.whl
  • Upload date:
  • Size: 34.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for seele_scholar_agent-0.11.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4651dc5e26760a610989743bed3412647af331820d7f92a63e19e3680e0a8ce7
MD5 ce3b27d6704b37a45c1af1d183d21dc0
BLAKE2b-256 af922ae46482ef844b85500074f5da5ba1e7ae1f5da1d9568eaded721ea3f76c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page