feat: OPENAI_BASE_URL for OpenAI-compatible endpoints + secret-free mock E2E - #993
Conversation
…e mock E2E
Backend: OPENAI_BASE_URL is now respected for the plain openai provider
(LLM and vision paths), not only for Azure. This enables OpenAI-compatible
endpoints like OpenRouter, LiteLLM and vLLM — and mock servers in tests.
E2E: new mock mode (E2E_LLM_MODE=mock) starts a WireMock container with
canned chat-completion stubs and points paperless-gpt at it. The main
document-processing flow now runs deterministically with zero API keys:
npm run test:e2e:mock
This is the basis for running E2E on every fork PR in CI without exposing
any secrets. Verified locally: 1 passed (1.0m) with all LLM API key env
vars unset.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
📝 WalkthroughWalkthroughThis PR adds OPENAI_BASE_URL support for non-Azure OpenAI client configuration in main.go, introduces a WireMock-based mock LLM mode for E2E tests (with mock response fixtures for correspondent, dates, custom fields, document types, tags, and titles), and updates documentation and the npm test script accordingly. ChangesOpenAI-compatible base URL and E2E mock mode
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant Developer
participant setupTestEnvironment
participant WireMockContainer
participant PaperlessGptContainer
Developer->>setupTestEnvironment: run test:e2e:mock (E2E_LLM_MODE=mock)
setupTestEnvironment->>setupTestEnvironment: isMockLlmMode() returns true
setupTestEnvironment->>WireMockContainer: start container, mount mocks/ mappings
WireMockContainer-->>setupTestEnvironment: admin mappings endpoint ready
setupTestEnvironment->>PaperlessGptContainer: set OPENAI_API_KEY=mock-key, OPENAI_BASE_URL=http://llm-mock:8080/v1
PaperlessGptContainer->>WireMockContainer: POST /v1/chat/completions
WireMockContainer-->>PaperlessGptContainer: static mock completion response
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Two tightly coupled changes:
1.
OPENAI_BASE_URLnow works without AzurePreviously
OPENAI_BASE_URLwas only honored whenOPENAI_API_TYPE=azure. It is now respected for the plainopenaiprovider too (both the LLM and the vision path), enabling any OpenAI-compatible endpoint: OpenRouter, LiteLLM, vLLM, … (long-standing community ask, related to #979).2. Secret-free E2E mock mode
npm run test:e2e:mock(envE2E_LLM_MODE=mock) starts a WireMock container serving canned OpenAI-compatible completions (web-app/e2e/mocks/) and points paperless-gpt at it via the newOPENAI_BASE_URLsupport. The main document-processing flow (upload → Generate Suggestions → Apply → History → Undo) runs deterministically with zero API keys and zero cost.Each stub matches a distinctive phrase from its prompt template in
default_prompts/; a low-priority catch-all answers anything else.Why
Part 2/3 of the contributor-friendly CI rework: this is the E2E tier that will run automatically on every PR including forks — no secrets involved, so no security gate needed. Real-LLM E2E moves behind a maintainer approval gate in the follow-up PR.
Verified
Locally with
OPENAI_API_KEY/MISTRAL_API_KEY/ANTHROPIC_API_KEYexplicitly unset:go test ./...passes. Existingtest:e2ebehavior is unchanged (mock mode is opt-in via env var).🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests