mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-05 08:07:05 +00:00
fix: handle windows paths in compression keys
This commit is contained in:
parent
cc57fe2111
commit
04408755df
2 changed files with 8 additions and 1 deletions
|
|
@ -34,7 +34,7 @@ def extract_key(message: dict, fallback_index: int, used_keys: Set[str]) -> str:
|
|||
if match:
|
||||
# Use just the filename, not full path
|
||||
path = match.group(1)
|
||||
key = path.split("/")[-1]
|
||||
key = re.split(r"[\\/]", path)[-1]
|
||||
break
|
||||
|
||||
if key is None:
|
||||
|
|
|
|||
|
|
@ -98,6 +98,13 @@ def test_extract_key_with_filename():
|
|||
assert key == "auth.py"
|
||||
|
||||
|
||||
def test_extract_key_with_windows_file_path():
|
||||
msg = {"role": "user", "content": r"File: C:\repo\auth.py"}
|
||||
used: set = set()
|
||||
key = extract_key(msg, fallback_index=0, used_keys=used)
|
||||
assert key == "auth.py"
|
||||
|
||||
|
||||
def test_extract_key_fallback():
|
||||
msg = {"role": "user", "content": "Some random content without a filename"}
|
||||
used: set = set()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue