Skip to content
Open
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 packages/mistralai_gcp/src/mistralai_gcp/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def before_request(
headers=headers,
content=new_content,
stream=None,
extensions=request.extensions,
)

return next_request
25 changes: 25 additions & 0 deletions src/mistralai/extra/tests/test_gcp_timeout_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys
from pathlib import Path
import httpx

# Add the mistralai_gcp package to the path for imports
gcp_package_path = Path(__file__).parent.parent.parent.parent.parent / "packages" / "mistralai_gcp" / "src"
sys.path.insert(0, str(gcp_package_path))

from mistralai_gcp.sdk import GoogleCloudBeforeRequestHook

def test_gcp_before_request_preserves_timeout_extension():
hook = GoogleCloudBeforeRequestHook(region="europe-west4", project_id="proj")

req = httpx.Request(
"POST",
"https://europe-west4-aiplatform.googleapis.com/v1/dummy",
content=b'{"model":"mistral-large-2407"}',
headers={"content-type": "application/json"},
)
timeout = httpx.Timeout(30.0)
req.extensions["timeout"] = timeout

out = hook.before_request(None, req)
assert isinstance(out, httpx.Request)
assert out.extensions.get("timeout") == timeout