feat: make StudyPal provider-agnostic (any OpenAI-compatible LLM) - #1
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes StudyPal provider-agnostic — it now runs on any OpenAI-compatible
/chat/completionsendpoint instead of being locked to one backend. Also fixes the test setup sonpm testactually 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— addPROVIDER_PRESETS(openai/openrouter/ollama/mimo) plusresolveConfig()/buildHeaders(). Auth header (bearer vs api-key) and base URL/model are chosen per provider. Select withLLM_PROVIDER+ the provider key (orLLM_API_KEY). LegacyMIMO_*env vars still work. All exported function signatures (chatCompletion,streamCompletion,trackUsage, ...) unchanged, so the 4 API routes need no edits.npm testfailed to parse TypeScript. Added a Babel-based jest config (separate from Next's SWC build) +@types/jest. Tests now run..github/workflows/ci.yml: type check + jest +next buildon Node 18/20.CONTRIBUTING.mdand issue templates.experimental.serverActionsfromnext.config.js.Backward compatibility
No breaking changes. Existing
MIMO_API_KEY/MIMO_BASE_URL/MIMO_MODELenv vars continue to work (the default provider staysmimo).Verification
(Local
next buildis memory-bound on the dev box; the production build is exercised by CI on a clean runner.)