Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ requires-python = ">=3.11"

[project.optional-dependencies]
dev = [
"httpx-aiohttp>=0.1.11", # Pin for raw headers fix
"ipykernel>=6.29", # For running Jupter notebooks, and pin to keep recent
Comment thread
jamesbraza marked this conversation as resolved.
"ipython>=8", # Pin to keep recent
"litellm>=1.71", # Lower pin for aiohttp transport adoption
Expand Down
20 changes: 20 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import httpx_aiohttp
import litellm.llms.custom_httpx.aiohttp_transport
import pytest
import vcr.stubs.aiohttp_stubs
import vcr.stubs.httpcore_stubs
from dotenv import load_dotenv
from lmi.utils import (
Expand Down Expand Up @@ -234,3 +235,22 @@ async def _vcr_handle_async_request(
# Permanently patch vcrpy's async VCR recording functionality,
# to work around https://github.com/kevin1024/vcrpy/issues/944
vcr.stubs.httpcore_stubs._vcr_handle_async_request = _vcr_handle_async_request

# Permanently patch vcrpy's aiohttp build_response to set raw_headers,
# to work around https://github.com/kevin1024/vcrpy/issues/970
_original_aiohttp_stubs_build_response = vcr.stubs.aiohttp_stubs.build_response


def _build_response_with_raw_headers(vcr_request, vcr_response, history):
"""Patched build_response that also sets _raw_headers on MockClientResponse."""
response = _original_aiohttp_stubs_build_response(
vcr_request, vcr_response, history
)
if response._raw_headers is None and response._headers is not None:
response._raw_headers = tuple(
(k.encode("utf-8"), v.encode("utf-8")) for k, v in response._headers.items()
Comment thread
jamesbraza marked this conversation as resolved.
)
return response


vcr.stubs.aiohttp_stubs.build_response = _build_response_with_raw_headers
10 changes: 6 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.