Skip to content

feat(export): opt-in APA .docx export of agentic answers#24

Merged
lfnothias merged 1 commit into
mainfrom
feat/apa-docx-optin
Jun 19, 2026
Merged

feat(export): opt-in APA .docx export of agentic answers#24
lfnothias merged 1 commit into
mainfrom
feat/apa-docx-optin

Conversation

@lfnothias

Copy link
Copy Markdown
Collaborator

Generalizable rework of #20 (closed as draft). Same capability — export an agentic answer + APA references to a .docx — but safe and opt-in.

What changed vs #20

  • Opt-in, off by default: config.rag_modes.agentic.export_apa_docx (+ export_apa_docx_dir). No behaviour change unless enabled. (Add APA DOCX manuscript export with reference deduplication #20 wrote a .docx on every agentic answer.)
  • Optional [docx] extra: python-docx is no longer a core dependency; uv sync --extra docx. Imported lazily; absent extra raises a clear ImportError that's caught off the answer path.
  • Tolerant exporter: handles Paper objects, dicts, and Author objects/strings. (Add APA DOCX manuscript export with reference deduplication #20 treated papers/authors as dicts/strings → would have silently produced blank refs on real Paper objects.)
  • No debug prints; export failures are logged, never break the answer; references are deduplicated.

Files

  • rag/export/apa_docx_exporter.py (new), rag/export/__init__.py
  • rag/agentic/orchestrator.py: _maybe_export_apa_docx gate + two call sites
  • config/schema.py, web/state.py, config.example.yml, pyproject.toml

Test Plan

  • tests/unit/test_apa_docx_export.py — APA formatting (Author objects/dicts/strings, 1/2/3+), config default-off, disabled-helper no-op, real .docx write (skipped without [docx]). 6 passed; full config suite green (32 passed).

Supersedes #20.

🤖 Generated with Claude Code

Generalizable rework of the approach in #20 (closed as draft):
- OFF by default via config.rag_modes.agentic.export_apa_docx (+ _dir).
- python-docx is an optional [docx] extra (uv sync --extra docx), imported
  lazily; absent extra raises a clear ImportError, swallowed off the answer path.
- Exporter tolerates Paper objects, dicts, and Author objects/strings
  (the original treated papers/authors as dicts/strings and silently failed).
- No debug prints; export failures never break the answer; references deduped.
- Hermetic tests: APA formatting, config default-off, disabled-helper no-op,
  and a real .docx write (skipped without the extra).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@lfnothias lfnothias merged commit 38a01fa into main Jun 19, 2026
1 of 2 checks passed
@lfnothias lfnothias deleted the feat/apa-docx-optin branch June 19, 2026 17:48
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.

1 participant