Skip to content

Commit 73b8531

Browse files
committed
Fix conflict
2 parents 2bcca43 + 442e7fa commit 73b8531

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

src/guidellm/backend/openai.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class OpenAIHTTPBackend(Backend):
6060
If not provided, the default timeout provided from settings is used.
6161
:param http2: If True, uses HTTP/2 for requests to the OpenAI server.
6262
Defaults to True.
63+
:param follow_redirects: If True, the HTTP client will follow redirect responses.
64+
If not provided, the default value from settings is used.
6365
:param max_output_tokens: The maximum number of tokens to request for completions.
6466
If not provided, the default maximum tokens provided from settings is used.
6567
:param extra_query: Query parameters to include in requests to the OpenAI server.
@@ -78,6 +80,7 @@ def __init__(
7880
project: Optional[str] = None,
7981
timeout: Optional[float] = None,
8082
http2: Optional[bool] = True,
83+
follow_redirects: Optional[bool] = None,
8184
max_output_tokens: Optional[int] = None,
8285
extra_query: Optional[Union[dict[str, str], dict[str, dict[str, str]]]] = None,
8386
):
@@ -105,6 +108,11 @@ def __init__(
105108
self.project = project or settings.openai.project
106109
self.timeout = timeout if timeout is not None else settings.request_timeout
107110
self.http2 = http2 if http2 is not None else settings.request_http2
111+
self.follow_redirects = (
112+
follow_redirects
113+
if follow_redirects is not None
114+
else settings.request_follow_redirects
115+
)
108116
self.max_output_tokens = (
109117
max_output_tokens
110118
if max_output_tokens is not None
@@ -138,6 +146,7 @@ def info(self) -> dict[str, Any]:
138146
"max_output_tokens": self.max_output_tokens,
139147
"timeout": self.timeout,
140148
"http2": self.http2,
149+
"follow_redirects": self.follow_redirects,
141150
"authorization": bool(self.authorization),
142151
"organization": self.organization,
143152
"project": self.project,
@@ -346,7 +355,11 @@ def _get_async_client(self) -> httpx.AsyncClient:
346355
:return: The async HTTP client.
347356
"""
348357
if self._async_client is None:
349-
client = httpx.AsyncClient(http2=self.http2, timeout=self.timeout)
358+
client = httpx.AsyncClient(
359+
http2=self.http2,
360+
timeout=self.timeout,
361+
follow_redirects=self.follow_redirects,
362+
)
350363
self._async_client = client
351364
else:
352365
client = self._async_client
@@ -492,12 +505,14 @@ async def _iterative_completions_request(
492505
raise ValueError(f"Unsupported type: {type_}")
493506

494507
logger.info(
495-
"{} making request: {} to target: {} using http2: {} for "
496-
"timeout: {} with headers: {} and params: {} and payload: {}",
508+
"{} making request: {} to target: {} using http2: {} following "
509+
"redirects: {} for timeout: {} with headers: {} and params: {} and ",
510+
"payload: {}",
497511
self.__class__.__name__,
498512
request_id,
499513
target,
500514
self.http2,
515+
self.follow_redirects,
501516
self.timeout,
502517
headers,
503518
params,
@@ -591,6 +606,7 @@ async def _iterative_completions_request(
591606
payload=payload,
592607
timeout=self.timeout,
593608
http2=self.http2,
609+
follow_redirects=self.follow_redirects,
594610
),
595611
start_time=start_time,
596612
end_time=iter_time,

src/guidellm/backend/response.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class RequestArgs(StandardBaseModel):
5353
content and other configurations.
5454
:param timeout: The timeout for the request in seconds, if any.
5555
:param http2: Whether HTTP/2 was used for the request, if applicable.
56+
:param follow_redirects: Whether the request should follow redirect responses.
5657
"""
5758

5859
target: str
@@ -61,6 +62,7 @@ class RequestArgs(StandardBaseModel):
6162
payload: dict[str, Any]
6263
timeout: Optional[float] = None
6364
http2: Optional[bool] = None
65+
follow_redirects: Optional[bool] = None
6466

6567

6668
class ResponseSummary(StandardBaseModel):

src/guidellm/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class Settings(BaseSettings):
115115
default_sweep_number: int = 10
116116

117117
# HTTP settings
118+
request_follow_redirects: bool = True
118119
request_timeout: int = 60 * 5 # 5 minutes
119120
request_http2: bool = True
120121

tests/unit/backend/test_openai_backend.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def test_openai_http_backend_default_initialization():
1616
assert backend.project == settings.openai.project
1717
assert backend.timeout == settings.request_timeout
1818
assert backend.http2 is True
19+
assert backend.follow_redirects is True
1920
assert backend.max_output_tokens == settings.openai.max_output_tokens
2021
assert backend.extra_query is None
2122

@@ -30,6 +31,7 @@ def test_openai_http_backend_intialization():
3031
project="test-proj",
3132
timeout=10,
3233
http2=False,
34+
follow_redirects=False,
3335
max_output_tokens=100,
3436
extra_query={"foo": "bar"},
3537
)
@@ -40,6 +42,7 @@ def test_openai_http_backend_intialization():
4042
assert backend.project == "test-proj"
4143
assert backend.timeout == 10
4244
assert backend.http2 is False
45+
assert backend.follow_redirects is False
4346
assert backend.max_output_tokens == 100
4447
assert backend.extra_query["foo"] == "bar"
4548

tests/unit/backend/test_response.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def test_request_args_default_initialization():
8181
)
8282
assert args.timeout is None
8383
assert args.http2 is None
84+
assert args.follow_redirects is None
8485

8586

8687
@pytest.mark.smoke
@@ -96,12 +97,14 @@ def test_request_args_initialization():
9697
},
9798
timeout=10.0,
9899
http2=True,
100+
follow_redirects=True,
99101
)
100102
assert args.target == "http://example.com"
101103
assert args.headers == {"Authorization": "Bearer token"}
102104
assert args.payload == {"query": "Hello, world!"}
103105
assert args.timeout == 10.0
104106
assert args.http2 is True
107+
assert args.follow_redirects is True
105108

106109

107110
@pytest.mark.smoke

0 commit comments

Comments
 (0)