mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
test vertex file content logging forwarding
Co-authored-by: Sameer Kankute <Sameerlite@users.noreply.github.com>
This commit is contained in:
parent
10261e4f90
commit
12ecac6f46
2 changed files with 33 additions and 2 deletions
|
|
@ -582,8 +582,6 @@ class VertexAIFilesConfig(VertexBase, BaseFilesConfig):
|
|||
)
|
||||
if transformed_content != content:
|
||||
# Create a new response with transformed content and updated Content-Length
|
||||
import httpx
|
||||
|
||||
# Update headers with correct Content-Length
|
||||
new_headers = dict(raw_response.headers)
|
||||
new_headers["content-length"] = str(len(transformed_content))
|
||||
|
|
|
|||
|
|
@ -149,6 +149,39 @@ class TestTransformFileContent:
|
|||
assert isinstance(result, HttpxBinaryResponseContent)
|
||||
assert result.response.content == b'{"line": 1}\n{"line": 2}\n'
|
||||
|
||||
def test_should_forward_logging_obj_to_batch_output_transformer(
|
||||
self, config, monkeypatch
|
||||
):
|
||||
raw_response = httpx.Response(
|
||||
status_code=200,
|
||||
content=b'{"line": 1}\n',
|
||||
headers={"content-type": "application/octet-stream"},
|
||||
request=httpx.Request("GET", "https://example.com"),
|
||||
)
|
||||
logging_obj = MagicMock()
|
||||
captured = {}
|
||||
|
||||
def mock_try_transform_vertex_batch_output_to_openai(content, logging_obj=None):
|
||||
captured["content"] = content
|
||||
captured["logging_obj"] = logging_obj
|
||||
return content
|
||||
|
||||
monkeypatch.setattr(
|
||||
config,
|
||||
"_try_transform_vertex_batch_output_to_openai",
|
||||
mock_try_transform_vertex_batch_output_to_openai,
|
||||
)
|
||||
|
||||
result = config.transform_file_content_response(
|
||||
raw_response=raw_response,
|
||||
logging_obj=logging_obj,
|
||||
litellm_params={},
|
||||
)
|
||||
|
||||
assert captured["content"] == raw_response.content
|
||||
assert captured["logging_obj"] is logging_obj
|
||||
assert result.response is raw_response
|
||||
|
||||
|
||||
class TestTransformDeleteFile:
|
||||
def test_should_build_correct_gcs_delete_url(self, config):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue