|
| 1 | +# Example Configuration for MCP-Based Category Classifier (HTTP Transport) |
| 2 | +# |
| 3 | +# This configuration demonstrates how to use an external MCP (Model Context Protocol) |
| 4 | +# service via HTTP for category classification instead of the built-in Candle/ModernBERT models. |
| 5 | +# |
| 6 | +# Use cases: |
| 7 | +# - Offload classification to a remote HTTP service |
| 8 | +# - Use custom classification models not supported in-tree |
| 9 | +# - Scale classification independently from the router |
| 10 | +# - Integrate with existing ML infrastructure via REST API |
| 11 | +# |
| 12 | +# Note: This example uses HTTP transport. The MCP server should expose an HTTP endpoint |
| 13 | +# that implements the MCP protocol (e.g., http://localhost:8080/mcp) |
| 14 | + |
| 15 | +# BERT model for semantic caching and tool selection |
| 16 | +bert_model: |
| 17 | + model_id: "sentence-transformers/all-MiniLM-L6-v2" |
| 18 | + threshold: 0.85 |
| 19 | + use_cpu: true |
| 20 | + |
| 21 | +# Classifier configuration |
| 22 | +classifier: |
| 23 | + # Disable in-tree category classifier (leave model_id empty) |
| 24 | + category_model: |
| 25 | + model_id: "" # Empty = disabled |
| 26 | + |
| 27 | + # Enable MCP-based category classifier (HTTP transport only) |
| 28 | + mcp_category_model: |
| 29 | + enabled: true # Enable MCP classifier |
| 30 | + transport_type: "http" # HTTP transport |
| 31 | + url: "http://localhost:8090/mcp" # MCP server endpoint |
| 32 | + |
| 33 | + # tool_name: Optional - auto-discovers classification tool if not specified |
| 34 | + # Will search for tools like: classify_text, classify, categorize, etc. |
| 35 | + # Uncomment to explicitly specify: |
| 36 | + # tool_name: "classify_text" |
| 37 | + |
| 38 | + threshold: 0.6 # Confidence threshold |
| 39 | + timeout_seconds: 30 # Request timeout |
| 40 | + |
| 41 | +# Categories for routing queries |
| 42 | +# |
| 43 | +# Categories are automatically loaded from MCP server via 'list_categories' tool. |
| 44 | +# The MCP server controls BOTH classification AND routing decisions. |
| 45 | +# |
| 46 | +# How it works: |
| 47 | +# 1. Router connects to MCP server at startup |
| 48 | +# 2. Calls 'list_categories' tool: MCP returns {"categories": ["business", "law", ...]} |
| 49 | +# 3. For each request, calls 'classify_text' tool which returns: |
| 50 | +# { |
| 51 | +# "class": 3, |
| 52 | +# "confidence": 0.85, |
| 53 | +# "model": "openai/gpt-oss-20b", # MCP decides which model to use |
| 54 | +# "use_reasoning": true # MCP decides whether to use reasoning |
| 55 | +# } |
| 56 | +# 4. Router uses the model and reasoning settings from MCP response |
| 57 | +# |
| 58 | +# BENEFITS: |
| 59 | +# - MCP server makes intelligent routing decisions per query |
| 60 | +# - No hardcoded routing rules needed in config |
| 61 | +# - MCP can adapt routing based on query complexity, content, etc. |
| 62 | +# - Centralized routing logic in MCP server |
| 63 | +# |
| 64 | +# FALLBACK: |
| 65 | +# - If MCP doesn't return model/use_reasoning, uses default_model below |
| 66 | +# - Can also add category-specific overrides here if needed |
| 67 | +# |
| 68 | +categories: [] |
| 69 | + |
| 70 | +# Default model to use when category can't be determined |
| 71 | +default_model: openai/gpt-oss-20b |
| 72 | + |
| 73 | +# vLLM endpoints configuration |
| 74 | +vllm_endpoints: |
| 75 | + - name: endpoint1 |
| 76 | + address: 127.0.0.1 |
| 77 | + port: 8000 |
| 78 | + models: |
| 79 | + - openai/gpt-oss-20b |
| 80 | + weight: 1 |
| 81 | + health_check_path: /health |
| 82 | + |
| 83 | +# Model-specific configuration |
| 84 | +model_config: |
| 85 | + openai/gpt-oss-20b: |
| 86 | + reasoning_family: gpt-oss |
| 87 | + preferred_endpoints: |
| 88 | + - endpoint1 |
| 89 | + pii_policy: |
| 90 | + allow_by_default: true |
| 91 | + |
| 92 | +# Reasoning family configurations |
| 93 | +reasoning_families: |
| 94 | + deepseek: |
| 95 | + type: chat_template_kwargs |
| 96 | + parameter: thinking |
| 97 | + qwen3: |
| 98 | + type: chat_template_kwargs |
| 99 | + parameter: enable_thinking |
| 100 | + gpt-oss: |
| 101 | + type: reasoning_effort |
| 102 | + parameter: reasoning_effort |
| 103 | + gpt: |
| 104 | + type: reasoning_effort |
| 105 | + parameter: reasoning_effort |
| 106 | + |
| 107 | +# Default reasoning effort level |
| 108 | +default_reasoning_effort: high |
| 109 | + |
| 110 | +# Tools configuration (optional) |
| 111 | +tools: |
| 112 | + enabled: false |
| 113 | + top_k: 5 |
| 114 | + similarity_threshold: 0.7 |
| 115 | + tools_db_path: "config/tools_db.json" |
| 116 | + fallback_to_empty: true |
| 117 | + |
| 118 | +# API configuration |
| 119 | +api: |
| 120 | + batch_classification: |
| 121 | + max_batch_size: 100 |
| 122 | + concurrency_threshold: 5 |
| 123 | + max_concurrency: 8 |
| 124 | + metrics: |
| 125 | + enabled: true |
| 126 | + detailed_goroutine_tracking: true |
| 127 | + high_resolution_timing: false |
| 128 | + sample_rate: 1.0 |
| 129 | + duration_buckets: |
| 130 | + - 0.001 |
| 131 | + - 0.005 |
| 132 | + - 0.01 |
| 133 | + - 0.025 |
| 134 | + - 0.05 |
| 135 | + - 0.1 |
| 136 | + - 0.25 |
| 137 | + - 0.5 |
| 138 | + - 1 |
| 139 | + - 2.5 |
| 140 | + - 5 |
| 141 | + - 10 |
| 142 | + - 30 |
| 143 | + size_buckets: |
| 144 | + - 1 |
| 145 | + - 2 |
| 146 | + - 5 |
| 147 | + - 10 |
| 148 | + - 20 |
| 149 | + - 50 |
| 150 | + - 100 |
| 151 | + - 200 |
| 152 | + |
| 153 | +# Observability configuration |
| 154 | +observability: |
| 155 | + tracing: |
| 156 | + enabled: false |
| 157 | + provider: "opentelemetry" |
| 158 | + exporter: |
| 159 | + type: "otlp" |
| 160 | + endpoint: "localhost:4317" |
| 161 | + insecure: true |
| 162 | + sampling: |
| 163 | + type: "always_on" |
| 164 | + resource: |
| 165 | + service_name: "semantic-router" |
| 166 | + service_version: "1.0.0" |
| 167 | + deployment_environment: "production" |
| 168 | + |
0 commit comments