Skip to content

Commit 2f95db0

Browse files
authored
Merge branch 'main' into issue-1020
2 parents 0fd96dc + a9951dd commit 2f95db0

File tree

7 files changed

+194
-53
lines changed

7 files changed

+194
-53
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ wheels/
2222

2323
# Virtual Environment
2424
venv/
25+
.venv/
2526
env/
2627
ENV/
2728

poetry.lock

+175-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PyYAML = "==6.0.2"
1414
fastapi = "==0.115.11"
1515
uvicorn = "==0.34.0"
1616
structlog = "==25.1.0"
17-
litellm = "==1.61.20"
17+
litellm = "==1.62.1"
1818
llama_cpp_python = "==0.3.5"
1919
cryptography = "==44.0.2"
2020
sqlalchemy = "==2.0.38"
@@ -50,7 +50,7 @@ ruff = "==0.9.9"
5050
bandit = "==1.8.3"
5151
build = "==1.2.2.post1"
5252
wheel = "==0.45.1"
53-
litellm = "==1.61.20"
53+
litellm = "==1.62.1"
5454
pytest-asyncio = "==0.25.3"
5555
llama_cpp_python = "==0.3.5"
5656
scikit-learn = "==1.6.1"

src/codegate/muxing/rulematcher.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import copy
2+
import fnmatch
23
from abc import ABC, abstractmethod
34
from asyncio import Lock
45
from typing import Dict, List, Optional
@@ -116,16 +117,16 @@ def _extract_request_filenames(self, detected_client: ClientType, data: dict) ->
116117
def _is_matcher_in_filenames(self, detected_client: ClientType, data: dict) -> bool:
117118
"""
118119
Check if the matcher is in the request filenames.
120+
The matcher is treated as a glob pattern and matched against the filenames.
119121
"""
120122
# Empty matcher_blob means we match everything
121123
if not self._mux_rule.matcher:
122124
return True
123125
filenames_to_match = self._extract_request_filenames(detected_client, data)
124-
# _mux_rule.matcher can be a filename or a file extension. We match if any of the filenames
125-
# match the rule.
126+
# _mux_rule.matcher is a glob pattern. We match if any of the filenames
127+
# match the pattern.
126128
is_filename_match = any(
127-
self._mux_rule.matcher == filename or filename.endswith(self._mux_rule.matcher)
128-
for filename in filenames_to_match
129+
fnmatch.fnmatch(filename, self._mux_rule.matcher) for filename in filenames_to_match
129130
)
130131
return is_filename_match
131132

src/codegate/providers/crud/crud.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ async def try_update_to_provider(
401401
dbprovend.endpoint, authm.auth_type, authm.auth_blob, prov
402402
)
403403
except Exception as err:
404-
logger.error(
404+
logger.info(
405405
"Unable to get models from provider. Skipping",
406406
provider=dbprovend.name,
407407
err=str(err),

tests/integration/integration_tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ async def _setup_muxing(
231231
provider_endpoint = muxing_config.get("provider_endpoint")
232232
try:
233233
data_with_api_keys = self.replace_env_variables(provider_endpoint["data"], os.environ)
234-
response_create_provider = self.call_codegate(
234+
response_create_provider = self.call_provider(
235235
provider=provider,
236236
url=provider_endpoint["url"],
237237
headers=provider_endpoint["headers"],
@@ -250,7 +250,7 @@ async def _setup_muxing(
250250
mux["provider_id"] = created_provider_endpoint["id"]
251251

252252
# The endpoint actually takes a list
253-
self.call_codegate(
253+
self.call_provider(
254254
provider=provider,
255255
url=muxes_rules["url"],
256256
headers=muxes_rules["headers"],

tests/muxing/test_rulematcher.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ def test_catch_all(matcher_blob, thing_to_match):
5151
[
5252
(None, [], True), # Empty filenames and no blob
5353
(None, ["main.py"], True), # Empty blob should match
54-
(".py", ["main.py"], True), # Extension match
54+
("*.py", ["main.py"], True), # Extension match
5555
("main.py", ["main.py"], True), # Full name match
56-
(".py", ["main.py", "test.py"], True), # Extension match
56+
("*.py", ["main.py", "test.py"], True), # Extension match
5757
("main.py", ["main.py", "test.py"], True), # Full name match
5858
("main.py", ["test.py"], False), # Full name no match
59-
(".js", ["main.py", "test.py"], False), # Extension no match
60-
(".ts", ["main.tsx", "test.tsx"], False), # Extension no match
59+
("*.js", ["main.py", "test.py"], False), # Extension no match
60+
("*.ts", ["main.tsx", "test.tsx"], False), # Extension no match
6161
],
6262
)
6363
def test_file_matcher(
@@ -89,13 +89,13 @@ def test_file_matcher(
8989
[
9090
(None, [], True), # Empty filenames and no blob
9191
(None, ["main.py"], True), # Empty blob should match
92-
(".py", ["main.py"], True), # Extension match
92+
("*.py", ["main.py"], True), # Extension match
9393
("main.py", ["main.py"], True), # Full name match
94-
(".py", ["main.py", "test.py"], True), # Extension match
94+
("*.py", ["main.py", "test.py"], True), # Extension match
9595
("main.py", ["main.py", "test.py"], True), # Full name match
9696
("main.py", ["test.py"], False), # Full name no match
97-
(".js", ["main.py", "test.py"], False), # Extension no match
98-
(".ts", ["main.tsx", "test.tsx"], False), # Extension no match
97+
("*.js", ["main.py", "test.py"], False), # Extension no match
98+
("*.ts", ["main.tsx", "test.tsx"], False), # Extension no match
9999
],
100100
)
101101
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)