Skip to main content

A package to route chat requests between LLMs based on prompt classification

Project description

LLM Predictive Router Package

This package allows you to route chat requests between small and large LLM models based on prompt classification.

Installation

You can install the package using pip:

pip install llm-predictive-router

Example usage

# Example Usage
from llm_predictive_router import LLMRouter

# Define model configuration
config = {
    "classifier": {
        "model_id": "DevQuasar/roberta-prompt_classifier-v0.1"
    },
    "small_llm": {
        "escalation_order": 0,
        "url": "http://localhost:1234/v1",
        "api_key": "lm-studio",
        "model_id": "lmstudio-community/Meta-Llama-3-8B-Instruct-GGUF/Meta-Llama-3-8B-Instruct-Q4_K_M.gguf",
        "max_ctx": 4096
    },
    "large_llm": {
        "escalation_order": 1,
        "url": "http://localhost:1234/v1",
        "api_key": "lm-studio",
        "model_id": "lmstudio-community/Meta-Llama-3-70B-Instruct-GGUF/Meta-Llama-3-70B-Instruct-Q4_K_M.gguf",
        "max_ctx": 8192
    }
}

router = LLMRouter(config)

# Example call with customized temperature and max_tokens
response, context, selected_model = router.chat(
    "Hello", 
    temperature=0.5,   # Lower temperature for more focused responses
    max_tokens=100,    # Limit the response length
    verbose=True
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm-predictive-router-0.2.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_predictive_router-0.2-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file llm-predictive-router-0.2.tar.gz.

File metadata

  • Download URL: llm-predictive-router-0.2.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for llm-predictive-router-0.2.tar.gz
Algorithm Hash digest
SHA256 6c9878b7fae9074854390e0e2f6ab0f0d0338bc57a2f6d0d250e8428b869721c
MD5 7b941b757ebf2151705557d4cb7003d9
BLAKE2b-256 fe45cc2319270d887ca2e5602a10f6cea4c13fc2936a119f59be8067d1d92050

See more details on using hashes here.

File details

Details for the file llm_predictive_router-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_predictive_router-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ab122d049b4dbcd3aada68abded6e898ca3640df573eda006df812813bb64d52
MD5 7596b7865792322827a61da5e7ed425c
BLAKE2b-256 cab161e864fc3e1bebdc67ff7d241575a320b0fadab3af5b9eb1a36e4612deee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page