Skip to content

Conversation

@madison-evans
Copy link
Contributor

the following PR is a re submission of a previously closed PR

Description

This PR adds a Router micro-service to GenAIComps.
The router decides which downstream LLM endpoint is best suited for an incoming prompt and returns that endpoint URL.
It is stateless and supports two interchangeable controller back-ends:

Controller Technique Config file Typical use-case
RouteLLM Matrix-factorisation ranking trained on preference datasets (e.g. gpt4_judge_battles) deployment/docker_compose/configs/routellm_config.yaml Fine-grained complexity routing
Semantic-Router Embedding-similarity / threshold deployment/docker_compose/configs/semantic_router_config.yaml Simple “weak vs strong” intent separation

How the configs fit together


comps/router/
├─ deployment/docker\_compose/configs/
│  ├─ router.yaml                # *Global* — maps strong/weak endpoints & points to per-controller YAMLs
│  ├─ routellm\_config.yaml       # RouteLLM-specific knobs (datasets, MF checkpoints, thresholds)
│  └─ semantic\_router\_config.yaml# Semantic-Router routes & encoder names
└─ src/opea\_router\_microservice.py
• Reads CONFIG\_PATH (env var) → loads router.yaml
• Uses “controller\_config\_paths” section to locate the chosen sub-config
• Instantiates controller via `ControllerFactory`

At runtime, docker compose mounts ./configs/app/configs in the container.
CONFIG_PATH=/app/configs/router.yaml tells the service where to start.

Deployment:

Docker Compose bundle (deployment/docker_compose/compose.yaml + deploy_router.sh)


Issues

n/a — new component


Type of change

  • New feature (non-breaking change which adds new functionality)
  • Bug fix
  • Breaking change
  • Others (enhancement, documentation, validation, etc.)

Dependencies

New PyPI packages added to comps/router/src/requirements.txt:

These depend on the existing stack (FastAPI, Pydantic, etc.).
Runtime requires HF_TOKEN and OPENAI_API_KEY secrets.


Tests

End-to-end validation script tests/router/test_router_routellm_on_xeon.sh

  1. Builds the router image (comps/router/src/Dockerfile)
  2. Spins up the service via Docker Compose
  3. Sends two sample prompts
    expects "weak" route for easy math, "strong"
  4. Shuts everything down

This assumes CI pipeline already exposes HF_TOKEN and OPENAI_API_KEY, so the script is invoked automatically.

# local smoke-test
export HF_TOKEN=***   OPENAI_API_KEY=***
chmod +x tests/router/test_router_routellm_on_xeon.sh
tests/router/test_router_routellm_on_xeon.sh

@madison-evans madison-evans force-pushed the routing-service branch 2 times, most recently from 5d91ac2 to 47e15f4 Compare May 21, 2025 15:09
@joshuayao joshuayao linked an issue May 22, 2025 that may be closed by this pull request
@joshuayao joshuayao mentioned this pull request May 22, 2025
@lvliang-intel
Copy link
Collaborator

@madison-evans,
please fix the CI issue, you need to add your new service to docker build yaml.

image

@ftian1
Copy link
Collaborator

ftian1 commented May 27, 2025

https://github.com/SAPD-Intel/RouteLLM

have you went through security process for this fork repo to be referenced?

@joshuayao
Copy link
Collaborator

Hi @madison-evans Could you please check the CI failures?

@madison-evans
Copy link
Contributor Author

@madison-evans, please fix the CI issue, you need to add your new service to docker build yaml.

image

for clarity, are you saying that I need to add my compose.yaml to .github/workflows/docker/compose as router-compose.yaml? Do I have that correct?

…cy. Now pulls from the referenced repo and then applies the patch located at 'comps/router/src/hf_compatibility.patch'

Signed-off-by: Madison Evans <[email protected]>
@madison-evans
Copy link
Contributor Author

example-test seems to be failing...

line 17, in <module>
      from llama_index.llms.openai import OpenAI
    File "/usr/local/lib/python3.11/site-packages/llama_index/llms/openai/__init__.py", line 2, in <module>
      from llama_index.llms.openai.responses import OpenAIResponses
    File "/usr/local/lib/python3.11/site-packages/llama_index/llms/openai/responses.py", line 6, in <module>
      from openai.types.responses import (
  ImportError: cannot import name 'ResponseTextAnnotationDeltaEvent' from 'openai.types.responses' (/usr/local/lib/python3.11/site-packages/openai/types/responses/__init__.py)
  + exit 1
  Error: Process completed with exit code 1.

A bit confused why that is. The commits I've made have been contained within comps/router

@codecov
Copy link

codecov bot commented May 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
comps/cores/proto/api_protocol.py 92.08% <100.00%> (+0.03%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chensuyue
Copy link
Collaborator

example-test seems to be failing...

line 17, in <module>
      from llama_index.llms.openai import OpenAI
    File "/usr/local/lib/python3.11/site-packages/llama_index/llms/openai/__init__.py", line 2, in <module>
      from llama_index.llms.openai.responses import OpenAIResponses
    File "/usr/local/lib/python3.11/site-packages/llama_index/llms/openai/responses.py", line 6, in <module>
      from openai.types.responses import (
  ImportError: cannot import name 'ResponseTextAnnotationDeltaEvent' from 'openai.types.responses' (/usr/local/lib/python3.11/site-packages/openai/types/responses/__init__.py)
  + exit 1
  Error: Process completed with exit code 1.

A bit confused why that is. The commits I've made have been contained within comps/router

This issue caused by deps update, and has been fixed yesterday. This example-test triggered due to your code update of comps/cores/ folder.

@madison-evans
Copy link
Contributor Author

all tests are passing now. Ready for review

@haim-barad
Copy link

Fixed as per your review comments - @ashahba

Copy link
Collaborator

@ashahba ashahba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@haim-barad
Copy link

What step (I assume last step) is needed for merge? Is "Update Branch" enough? If yes, which method?

@ashahba ashahba merged commit 5e08c3f into opea-project:main Jun 10, 2025
17 checks passed
@haim-barad haim-barad deleted the routing-service branch June 10, 2025 10:03
@yinghu5 yinghu5 added this to the v1.4 milestone Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] RouteLLM

9 participants