Skip to content

Commit b50b28d

Browse files
committed
Move _get_base_url to the base provider
In order to properly support "muxing providers" like openrouter, we'll have to tell litellm (or in future a native implementation), what server do we want to proxy to. We were already doing that with Vllm, but since are about to do the same for OpenRouter, let's move the `_get_base_url` method to the base provider.
1 parent ece8831 commit b50b28d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/codegate/providers/base.py

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from codegate.clients.clients import ClientType
1414
from codegate.codegate_logging import setup_logging
15+
from codegate.config import Config
1516
from codegate.db.connection import DbRecorder
1617
from codegate.pipeline.base import (
1718
PipelineContext,
@@ -88,6 +89,13 @@ async def process_request(
8889
def provider_route_name(self) -> str:
8990
pass
9091

92+
def _get_base_url(self) -> str:
93+
"""
94+
Get the base URL from config with proper formatting
95+
"""
96+
config = Config.get_config()
97+
return config.provider_urls.get(self.provider_route_name) if config else ""
98+
9199
async def _run_output_stream_pipeline(
92100
self,
93101
input_context: PipelineContext,

src/codegate/providers/vllm/provider.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def _get_base_url(self) -> str:
3939
"""
4040
Get the base URL from config with proper formatting
4141
"""
42-
config = Config.get_config()
43-
base_url = config.provider_urls.get("vllm") if config else ""
42+
base_url = super()._get_base_url()
4443
if base_url:
4544
base_url = base_url.rstrip("/")
4645
# Add /v1 if not present

0 commit comments

Comments
 (0)