Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/codegate/muxing/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import structlog
from fastapi import APIRouter, HTTPException, Request

from codegate.clients.detector import DetectClient
from codegate.muxing import rulematcher
from codegate.muxing.adapter import BodyAdapter, ResponseAdapter
from codegate.providers.registry import ProviderRegistry
Expand Down Expand Up @@ -38,6 +39,7 @@ def _ensure_path_starts_with_slash(self, path: str) -> str:
def _setup_routes(self):

@self.router.post(f"/{self.route_name}/{{rest_of_path:path}}")
@DetectClient()
async def route_to_dest_provider(
request: Request,
rest_of_path: str = "",
Expand Down Expand Up @@ -73,7 +75,9 @@ async def route_to_dest_provider(
api_key = model_route.auth_material.auth_blob

# Send the request to the destination provider. It will run the pipeline
response = await provider.process_request(new_data, api_key, rest_of_path)
response = await provider.process_request(
new_data, api_key, rest_of_path, request.state.detected_client
)
# Format the response to the client always using the OpenAI format
return self._response_adapter.format_response_to_client(
response, model_route.endpoint.provider_type
Expand Down