Skip to content

Add pip-installable reviewer3 CLI for context-aware DOCX paragraph review via OpenAI/Ollama - #1

Merged
haesleinhuepf merged 9 commits into
mainfrom
copilot/create-reviewer3-cli-tool
Jul 25, 2026
Merged

Add pip-installable reviewer3 CLI for context-aware DOCX paragraph review via OpenAI/Ollama#1
haesleinhuepf merged 9 commits into
mainfrom
copilot/create-reviewer3-cli-tool

Conversation

Copilot AI commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This PR introduces a Python package and CLI (reviewer3) that reviews scientific .docx files paragraph-by-paragraph using an LLM, then writes feedback back into a new file (*_rv3.docx) without modifying the original.
Feedback generation is context-aware: each paragraph is reviewed with prior summaries, introduced terms/abbreviations, and earlier feedback history.

  • Packaging + CLI surface

    • Added pyproject.toml with install metadata and console script entrypoint:
      • reviewer3 = reviewer3.cli:main
    • Added CLI argument handling for input .docx and optional output path.
    • Enforced non-destructive output behavior (input/output path must differ).
  • Review orchestration pipeline

    • Added reviewer3/core.py with review_docx(...) flow:
      • iterate non-empty paragraphs
      • request structured LLM feedback per paragraph
      • carry forward running context (previous_summaries, introduced terms, prior feedback)
    • Added env-driven OpenAI client configuration with Ollama-friendly defaults:
      • REVIEWER3_OPENAI_BASE_URL (default http://localhost:11434/v1)
      • REVIEWER3_OPENAI_API_KEY (default ollama)
      • REVIEWER3_OPENAI_MODEL (default gpt-oss:20b)
      • REVIEWER3_OPENAI_TEMPERATURE
  • DOCX feedback writing

    • Added comment insertion for constructive questions using python-docx comments API.
    • Added tracked insertion suggestions (w:ins) authored as reviewer3 to represent rewrite suggestions.
    • Default output naming implemented via <input_stem>_rv3.docx.
  • Robust parsing + behavior contracts

    • Added structured feedback parsing (parse_feedback) with JSON fallback extraction and no_feedback support.
    • Supports LLM responses that intentionally provide no comment/suggestion for acceptable paragraphs.
  • Focused test coverage + docs

    • Added targeted unit tests for:
      • default output naming
      • context propagation across paragraphs
      • comment creation and tracked suggestion insertion in output DOCX
    • Expanded README with tool intent and output behavior.
from pathlib import Path
from reviewer3.core import review_docx, LLMReviewer

reviewer = LLMReviewer.from_env()  # defaults to local Ollama gpt-oss:20b
out = review_docx(
    input_docx=Path("manuscript.docx"),
    output_docx=Path("manuscript_rv3.docx"),
    reviewer=reviewer,
)
print(out)  # manuscript_rv3.docx
Original prompt

I would like to program a pip-installable command line tool named "reviewer3" that serves as reviewer of scientific texts. It can open docx files, read them paragraph by paragraph and process the content subsequently using an LLM to provide constructive (!) feedback for the paragraphs in form of text suggestions and comments (for questions) in the docx file. It should use the python-docx api to add comments and tracking-changes text suggestions. It will identify itself in the document as reviewer3. It will never overwrite the original file, but instead save its comments and suggestions as _rv3.docx .
I guess for this it makes sense to summarize the paragraphs one by one, list what was explained, which terms and abbreviations were introduced subsequently. When asking the LLM for feedback about a given paragraph, the paragraph, including the summaries of the paragraphs before should be provided as well as the feedback the LLM gave earlier. The LLM should also have the option to not provide any feedback about a paragraph in case it is ok.
The LLM should be asked via the openai python API. Per default I would like to use gpt-oss:20b in my local ollama installation. This config can be changed by modifying environment variables.

Copilot AI changed the title [WIP] Add command line tool reviewer3 for scientific text review Add pip-installable reviewer3 CLI for context-aware DOCX paragraph review via OpenAI/Ollama Jul 24, 2026
Copilot AI requested a review from haesleinhuepf July 24, 2026 17:10
@haesleinhuepf
haesleinhuepf marked this pull request as ready for review July 25, 2026 19:20
@haesleinhuepf
haesleinhuepf merged commit 0736a71 into main Jul 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants