Perspective icon indicating copy to clipboard operation
Perspective copied to clipboard

Add Pluggable LLM Provider & Model Selection for Improved Redundancy and Cost Efficiency

Open Prateekiiitg56 opened this issue 10 months ago • 2 comments

📌Description

This PR introduces a pluggable LLM provider architecture that allows users to dynamically choose their LLM provider (e.g., Groq, Gemini, OpenAI, open-source models) and specific model at runtime.

The goal is to reduce dependency on a single AI provider, improve system resilience, and align with Perspective-AI’s mission of decentralization, user choice, and cost-efficient AI usage.

🎯 Motivation

Perspective-AI aims to counter algorithmic echo chambers by presenting balanced, multi-perspective analysis. Relying on a single LLM provider introduces:

Vendor lock-in

Single point of failure

Cost scalability issues

Reduced transparency and flexibility

By enabling multiple LLM backends, we:

Improve system redundancy

Encourage open-source LLM adoption

Allow users to select models based on cost, latency, or quality

Make the system more future-proof and extensible

✨ Key Features Added

  1. LLM Provider Selection

Users can now choose from multiple LLM providers, such as:

Groq

Gemini

OpenAI

Open-source / self-hosted LLMs (future-ready)

This selection can be configured via:

API request parameters

UI-level controls (frontend-ready)

Environment-level defaults

  1. Model-Level Granularity

Each provider exposes its available models, allowing users to select:

Faster vs. more capable models

Cost-efficient open-source alternatives

Task-specific models for reasoning or summarization

Example:

Groq → llama3-70b, mixtral

Gemini → gemini-pro

Open-source → Mistral, LLaMA, etc.

  1. Unified LLM Interface

A provider-agnostic abstraction layer ensures:

Clean separation between business logic and LLM implementations

Easy onboarding of new providers

Minimal refactoring when switching models

This keeps LangChain/LangGraph workflows intact while enabling backend flexibility.

  1. Cost-Efficient & Open-Source Friendly

Default preference can be given to open-source or low-cost LLMs

Reduces reliance on expensive proprietary APIs

Supports the long-term sustainability of the project

🧠 Architectural Impact

Before: Single LLM provider → tightly coupled → limited scalability

After: Pluggable LLM layer → provider abstraction → dynamic model routing

This aligns with Perspective-AI’s broader architecture of:

Modular design

Redundancy in critical dependencies

Transparent AI decision pipelines

🔐 Security & Configuration

API keys are managed via environment variables

No provider-specific secrets are exposed to the frontend

Safe fallbacks ensure graceful degradation if a provider fails

📈 Expected Outcomes

Reduced vendor lock-in

Improved system resilience

Lower operational costs

Better experimentation with reasoning quality

Stronger alignment with open-source principles

🛠️ Future Scope

Auto-routing models based on task complexity

User-defined cost/latency preferences

Self-hosted local LLM support

Provider benchmarking & quality comparison UI

@ParagGhatage Assign this to me !!

Prateekiiitg56 avatar Jan 09 '26 15:01 Prateekiiitg56

Hi @ParagGhatage, I’d like to work on this issue. My plan is to implement a pluggable LLM provider layer that allows selecting providers and models at runtime, with a clean provider-agnostic interface. I will ensure: Existing workflows (LangChain/LangGraph) remain intact Environment-level defaults and API key management are safe Graceful fallback if a provider fails Support for open-source and cost-efficient options Please let me know if this approach aligns with the current architecture before I start the implementation.

Kaustubh1204 avatar Jan 21 '26 19:01 Kaustubh1204

@ParagGhatage should i proceed?

Prateekiiitg56 avatar Feb 04 '26 19:02 Prateekiiitg56