Skip to content

feat: make StudyPal provider-agnostic (any OpenAI-compatible LLM) - #1

Merged
aimanmalib merged 3 commits into
mainfrom
feat/provider-agnostic-llm
Jun 5, 2026
Merged

feat: make StudyPal provider-agnostic (any OpenAI-compatible LLM)#1
aimanmalib merged 3 commits into
mainfrom
feat/provider-agnostic-llm

Conversation

@aimanmalib

Copy link
Copy Markdown
Owner

What

Makes StudyPal provider-agnostic — it now runs on any OpenAI-compatible /chat/completions endpoint instead of being locked to one backend. Also fixes the test setup so npm test actually runs.

Why

The Next.js API routes already spoke the standard OpenAI protocol; only the base URL and auth header were hardcoded. This exposes that flexibility so users can run StudyPal on OpenAI, OpenRouter, Ollama, llama.cpp, or Xiaomi MiMo with one env var.

Changes

  • src/lib/mimo.ts — add PROVIDER_PRESETS (openai/openrouter/ollama/mimo) plus resolveConfig() / buildHeaders(). Auth header (bearer vs api-key) and base URL/model are chosen per provider. Select with LLM_PROVIDER + the provider key (or LLM_API_KEY). Legacy MIMO_* env vars still work. All exported function signatures (chatCompletion, streamCompletion, trackUsage, ...) unchanged, so the 4 API routes need no edits.
  • Test setup fix — the repo had no jest config, so npm test failed to parse TypeScript. Added a Babel-based jest config (separate from Next's SWC build) + @types/jest. Tests now run.
  • Tests — +10 multi-backend tests. 19 tests pass (was 9, and previously not runnable at all).
  • CI — new .github/workflows/ci.yml: type check + jest + next build on Node 18/20.
  • Docs — README rebranded with a Supported Providers table; added CONTRIBUTING.md and issue templates.
  • Cleanup — removed deprecated experimental.serverActions from next.config.js.

Backward compatibility

No breaking changes. Existing MIMO_API_KEY / MIMO_BASE_URL / MIMO_MODEL env vars continue to work (the default provider stays mimo).

Verification

npx tsc --noEmit     # clean
npm test             # 19 passed

(Local next build is memory-bound on the dev box; the production build is exercised by CI on a clean runner.)

Add provider presets (openai/openrouter/ollama/mimo) with bearer or
api-key auth chosen per provider via resolveConfig()/buildHeaders().
Keep MIMO_* env vars working (legacy precedence) and all exported
function signatures unchanged. Also fix the test setup: the repo had
no jest config so 'npm test' failed to parse TS; add a babel-based
jest config (separate from Next's SWC build). 9 tests pass.
Cover provider presets (openai/openrouter/ollama/mimo), bearer vs
api-key auth, env resolution, legacy MIMO key precedence, and base/model
overrides. Remove deprecated experimental.serverActions from next.config.
19 tests pass, typecheck clean.
Reposition README/layout/package.json/prompts from MiMo-exclusive to any
OpenAI-compatible LLM; add Supported Providers table. Add GitHub Actions
CI (tsc + jest + next build on Node 18/20), CONTRIBUTING guide, and issue
templates. 19 tests pass, typecheck clean.
@aimanmalib
aimanmalib merged commit cc34ecb into main Jun 5, 2026
2 checks passed
@aimanmalib
aimanmalib deleted the feat/provider-agnostic-llm branch June 5, 2026 09:08
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