[PR #5011] [CLOSED] feat: Add ModelsLab provider for uncensored Llama 3.1 LLM support #4860

Closed
opened 2026-02-22 18:36:40 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/5011
Author: @adhikjoshi
Created: 2/18/2026
Status: Closed

Base: masterHead: feat/add-modelslab-provider


📝 Commits (5)

  • 79e26c0 feat: Add ModelsLab to ENV config and supportedLLM
  • b17b59d feat: Register ModelsLab in provider helpers
  • 83c4eee feat: Add ModelsLabLLM provider class
  • 9adf6b4 feat: Add ModelsLab provider tests
  • 74ff85d feat: Add ModelsLab frontend options component

📊 Changes

5 files changed (+727 additions, -0 deletions)

View changed files

frontend/src/components/LLMSelection/ModelsLabOptions/index.jsx (+139 -0)
server/utils/AiProviders/modelsLab/index.js (+232 -0)
server/utils/AiProviders/modelsLab/modelsLab.test.js (+339 -0)
📝 server/utils/helpers/index.js (+8 -0)
📝 server/utils/helpers/updateENV.js (+9 -0)

📄 Description

feat: Add ModelsLab provider for uncensored Llama 3.1 LLM support

Summary

This PR adds ModelsLab as an LLM provider in AnythingLLM, enabling users to chat with uncensored Llama 3.1 models (8B and 70B) featuring 128K context windows at competitive pricing.

What is ModelsLab?

ModelsLab is an AI API platform providing access to a wide range of AI models including uncensored language models, image generation, video generation, and more. Their uncensored Llama 3.1 models are ideal for creative writing, research, and use cases where standard content restrictions are too limiting.

Changes

New file

  • server/utils/AiProviders/modelsLab/index.jsModelsLabLLM class implementation

Modified files

  • server/utils/helpers/updateENV.js — add ModelsLabApiKey and ModelsLabModelPref env key mappings + "modelslab" to supportedLLM validator
  • server/utils/helpers/index.js — add case "modelslab" to getLLMProvider() and getBaseLLMProviderModel() switches
  • .env.example — add ModelsLab environment variable documentation
  • frontend/src/components/LLMSelection/ModelsLabOptions/index.jsx — settings UI component
  • frontend/src/pages/GeneralSettings/LLMPreference/index.jsx — add ModelsLab to provider list

New test file

  • server/utils/AiProviders/modelsLab/modelsLab.test.js — 25 test cases

Models

Model Context Best for
llama-3.1-8b-uncensored (default) 128K Fast, everyday tasks
llama-3.1-70b-uncensored 128K Complex reasoning, higher quality

Usage

Via UI

Settings → LLM Preference → ModelsLab → enter API key → select model

Via environment variables

LLM_PROVIDER=modelslab
MODELSLAB_API_KEY=your-api-key-here
MODELSLAB_MODEL_PREF=llama-3.1-8b-uncensored

Implementation approach

Follows the established OpenAI-compatible provider pattern used by TogetherAiLLM, FireworksAiLLM, and others:

  • Uses the openai npm package (already a project dependency) with baseURL pointing to ModelsLab's OpenAI-compatible endpoint
  • Implements all required BaseLLMProvider interface methods
  • Full streaming support via streamGetChatCompletion + handleDefaultStreamResponseV2
  • LLMPerformanceMonitor integration for consistent metrics tracking
  • Static model catalogue (avoids unnecessary API round-trips)
  • NativeEmbedder delegation (consistent with all other providers)

Testing

jest server/utils/AiProviders/modelsLab/modelsLab.test.js --verbose

Test coverage:

  • Constructor validation (missing API key, env var precedence, model override)
  • Context window limits (static + instance)
  • Model validation (valid models, invalid models, empty string)
  • Model listing (field presence, count)
  • Prompt construction (system, context injection, history, attachments)
  • Chat completion (success path, invalid model, empty choices)
  • Streaming (measureStream called, invalid model throws)
  • Embedding delegation

Checklist

  • Follows existing provider code style and patterns
  • No new npm dependencies introduced
  • Environment variables documented in .env.example
  • Settings UI component matches existing provider UI patterns
  • Test suite with 25 cases
  • supportedLLM validator updated
  • Provider loader switch updated
  • Static model listing (no live API calls at startup)
  • Streaming enabled

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/5011 **Author:** [@adhikjoshi](https://github.com/adhikjoshi) **Created:** 2/18/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `feat/add-modelslab-provider` --- ### 📝 Commits (5) - [`79e26c0`](https://github.com/Mintplex-Labs/anything-llm/commit/79e26c0e3f4a2868fd62904bbfa3730e98619fc2) feat: Add ModelsLab to ENV config and supportedLLM - [`b17b59d`](https://github.com/Mintplex-Labs/anything-llm/commit/b17b59d8e6d173d9dde555979897e395e1ef5cc2) feat: Register ModelsLab in provider helpers - [`83c4eee`](https://github.com/Mintplex-Labs/anything-llm/commit/83c4eeef07e9421ce4e9c6f834bd4eef9e71b877) feat: Add ModelsLabLLM provider class - [`9adf6b4`](https://github.com/Mintplex-Labs/anything-llm/commit/9adf6b42cb2c280afad2b9064290b9f29720cea4) feat: Add ModelsLab provider tests - [`74ff85d`](https://github.com/Mintplex-Labs/anything-llm/commit/74ff85df974a51e212881dde8ccf98c175efa98c) feat: Add ModelsLab frontend options component ### 📊 Changes **5 files changed** (+727 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `frontend/src/components/LLMSelection/ModelsLabOptions/index.jsx` (+139 -0) ➕ `server/utils/AiProviders/modelsLab/index.js` (+232 -0) ➕ `server/utils/AiProviders/modelsLab/modelsLab.test.js` (+339 -0) 📝 `server/utils/helpers/index.js` (+8 -0) 📝 `server/utils/helpers/updateENV.js` (+9 -0) </details> ### 📄 Description # feat: Add ModelsLab provider for uncensored Llama 3.1 LLM support ## Summary This PR adds [ModelsLab](https://modelslab.com) as an LLM provider in AnythingLLM, enabling users to chat with uncensored Llama 3.1 models (8B and 70B) featuring 128K context windows at competitive pricing. ## What is ModelsLab? ModelsLab is an AI API platform providing access to a wide range of AI models including uncensored language models, image generation, video generation, and more. Their uncensored Llama 3.1 models are ideal for creative writing, research, and use cases where standard content restrictions are too limiting. - Website: https://modelslab.com - API docs: https://docs.modelslab.com - Get API key: https://modelslab.com/dashboard ## Changes ### New file - `server/utils/AiProviders/modelsLab/index.js` — `ModelsLabLLM` class implementation ### Modified files - `server/utils/helpers/updateENV.js` — add `ModelsLabApiKey` and `ModelsLabModelPref` env key mappings + `"modelslab"` to `supportedLLM` validator - `server/utils/helpers/index.js` — add `case "modelslab"` to `getLLMProvider()` and `getBaseLLMProviderModel()` switches - `.env.example` — add ModelsLab environment variable documentation - `frontend/src/components/LLMSelection/ModelsLabOptions/index.jsx` — settings UI component - `frontend/src/pages/GeneralSettings/LLMPreference/index.jsx` — add ModelsLab to provider list ### New test file - `server/utils/AiProviders/modelsLab/modelsLab.test.js` — 25 test cases ## Models | Model | Context | Best for | |---|---|---| | `llama-3.1-8b-uncensored` (default) | 128K | Fast, everyday tasks | | `llama-3.1-70b-uncensored` | 128K | Complex reasoning, higher quality | ## Usage ### Via UI Settings → LLM Preference → ModelsLab → enter API key → select model ### Via environment variables ```env LLM_PROVIDER=modelslab MODELSLAB_API_KEY=your-api-key-here MODELSLAB_MODEL_PREF=llama-3.1-8b-uncensored ``` ## Implementation approach Follows the established OpenAI-compatible provider pattern used by `TogetherAiLLM`, `FireworksAiLLM`, and others: - Uses the `openai` npm package (already a project dependency) with `baseURL` pointing to ModelsLab's OpenAI-compatible endpoint - Implements all required `BaseLLMProvider` interface methods - Full streaming support via `streamGetChatCompletion` + `handleDefaultStreamResponseV2` - `LLMPerformanceMonitor` integration for consistent metrics tracking - Static model catalogue (avoids unnecessary API round-trips) - `NativeEmbedder` delegation (consistent with all other providers) ## Testing ```bash jest server/utils/AiProviders/modelsLab/modelsLab.test.js --verbose ``` Test coverage: - ✅ Constructor validation (missing API key, env var precedence, model override) - ✅ Context window limits (static + instance) - ✅ Model validation (valid models, invalid models, empty string) - ✅ Model listing (field presence, count) - ✅ Prompt construction (system, context injection, history, attachments) - ✅ Chat completion (success path, invalid model, empty choices) - ✅ Streaming (measureStream called, invalid model throws) - ✅ Embedding delegation ## Checklist - [x] Follows existing provider code style and patterns - [x] No new npm dependencies introduced - [x] Environment variables documented in `.env.example` - [x] Settings UI component matches existing provider UI patterns - [x] Test suite with 25 cases - [x] `supportedLLM` validator updated - [x] Provider loader switch updated - [x] Static model listing (no live API calls at startup) - [x] Streaming enabled --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:36:40 -05:00
yindo closed this issue 2026-02-22 18:36:41 -05:00
yindo changed title from [PR #5011] feat: Add ModelsLab provider for uncensored Llama 3.1 LLM support to [PR #5011] [CLOSED] feat: Add ModelsLab provider for uncensored Llama 3.1 LLM support 2026-06-05 15:20:44 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4860