Skip to content

[Enhancement] Split LLM Routing for weak Ollama #8

Description

@lundelltravis

Hi! I’ve been experimenting with MuckScraper on a small local Ollama host (8GB VRAM) and ended up building a split‑routing system that lets the project run inference across both local Ollama and cloud LLMs (via OpenRouter). I wanted to share the changes in case this direction is useful for the main project — the architecture is modular enough that it could support any OpenAI‑compatible cloud provider with minimal adjustments.

Why:

Running everything through a local model wasn’t feasible on my hardware, but I still wanted fast, cheap inference for lightweight tasks. The solution was to route “simple” operations (classification, headlines, bias scoring) to Ollama, while sending heavier summarization and deep‑analysis tasks to a cloud LLM.

This keeps the pipeline responsive even on modest hardware while still enabling high‑quality summarization.

What changed:

I added a provider‑aware LLM client and updated the pipeline so each part of MuckScraper can choose the appropriate inference backend.

Key changes:

  1. New split‑routing LLM client
    The file newsfetcher/llmclient.py was rewritten to support two providers:
  • generate_text_ollama()
  • generate_text_openrouter()
  • get_embedding_ollama()
  • get_embedding_openrouter()

Plus a unified generate_text(provider=...) interface and provider‑specific status/config checks.

Timeouts are configurable via .env (OLLAMATIMEOUT, OPENROUTERTIMEOUT).

  1. Routing updates across the pipeline
    Lightweight tasks → Ollama
    Heavy summarization → OpenRouter

Specifically:

  • Topic classification → Ollama
  • Headline generation → Ollama
  • Outlet bias scoring → Ollama
  • Story summarization → OpenRouter
  • Deep article analysis → OpenRouter
  • Deep story reports → OpenRouter

This is all documented in IMPLEMENTATIONSUMMARY.md and LLMROUTING_CHANGES.md.

  1. Environment configuration
    .env now supports:

OLLAMA_HOST=http://localhost:11434 OLLAMA_MODEL=gemma3:4b OLLAMA_TIMEOUT=120 OPENROUTER_TIMEOUT=120 OPENROUTER_HOST=https://openrouter.ai/api/v1 OPENROUTER_MODEL=openrouter/free OPENROUTER_API_KEY= LLM_PROVIDER=openrouter # Provider toggle: "ollama" (default, home machine), "gemini", "groq", or "openrouter" EMBEDDING_PROVIDER=openrouter EMBEDDING_MODEL=nomic_embed_text OPENROUTER_EMBEDDING_MODEL=text-embedding-ada-002

The OpenRouter section can be swapped for any OpenAI‑compatible cloud LLM (Anthropic, OpenAI, Groq, DeepSeek, etc.) by adjusting the base URL and model name.

  1. Backward compatibility
    All existing function signatures remain intact.
    Code that doesn’t specify a provider still uses the default LLM_PROVIDER.

How it works:

The pipeline routes each LLM call based on the task type. This keeps local inference fast while offloading heavy work to the cloud.

If this direction aligns with your roadmap
I’d be happy to help adapt the routing layer. The architecture is intentionally simple so it can be extended to additional providers or models without major refactoring.

Thanks for building such a great project — this split‑routing approach has made it much more usable on constrained hardware.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions