Add MiniMax as LLM provider backend#501
Conversation
Add MiniMax as a first-class REST LLM provider alongside OpenAI, Anthropic, Cohere, and PaLM. MiniMax uses an OpenAI-compatible chat completions API with support for M2.5, M2.5-highspeed, M2.7, and M2.7-highspeed models. - New `spacy_llm/models/rest/minimax/` provider module (model, registry, init) - Registry entry `spacy.MiniMax.v1` for spaCy config integration - Think-tag stripping for reasoning model output - Temperature clamping and context length definitions - Test suite with unit and integration tests - Usage example config for text classification with MiniMax - README updated to list MiniMax as supported provider
JiwaniZakir
left a comment
There was a problem hiding this comment.
In model.py, the error-handling path inside the __call__ loop has a type mismatch bug: when "error" in responses, return responses["error"] returns a flat List[str] (e.g., ["<json error>", "<json error>"]), but the declared return type is Iterable[Iterable[str]]. Callers expecting a nested structure will silently iterate over individual characters of the error string rather than getting a proper response list. This should be return [responses["error"]] or appended to all_api_responses before returning, consistent with the non-error path.
Additionally, _verify_auth in model.py verifies credentials by making a live API call with self([["test"]]), which consumes billable tokens on every cold start or config validation. The other providers in this repo (e.g., OpenAI's implementation) typically use a lightweight /v1/models endpoint for this. Since MiniMax reportedly lacks that endpoint, it may be worth at minimum documenting this side-effect in a comment, or skipping the verification entirely and relying on the first real call to surface auth errors.
Finally, the _request closure is redefined on every iteration of the outer for prompts_for_doc in prompts loop — moving it outside the loop (accepting prompts_for_doc as a parameter) would be cleaner and avoids the closure capturing a loop variable.
Summary
Adds MiniMax as a first-class REST LLM provider backend for spacy-llm, alongside OpenAI, Anthropic, Cohere, and PaLM.
MiniMax offers an OpenAI-compatible chat completions API with models like MiniMax-M2.5 (204K context) and MiniMax-M2.7 (1M context), making it a compelling alternative for structured NLP pipelines.
Changes
spacy_llm/models/rest/minimax/with model, registry, and init filesspacy.MiniMax.v1for seamless spaCy config integrationUsage
Python
Config file
Supported Models
Test Plan
spacy.MiniMax.v1resolves correctly