Skip to content

Commit 1d9c53e

Browse files
committed
refactor: simplify extra_body passing per review feedback
Remove unnecessary conditional when passing extra_body to OpenAI SDK. Empty dict and None are both handled correctly by the SDK.
1 parent b720d59 commit 1d9c53e

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

portkey_ai/api_resources/apis/chat_complete.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def stream_create( # type: ignore[return]
9595
store=store,
9696
extra_headers=extra_headers,
9797
extra_query=extra_query,
98-
extra_body=merged_extra_body if merged_extra_body else None,
98+
extra_body=merged_extra_body,
9999
timeout=timeout,
100100
)
101101

@@ -137,7 +137,7 @@ def normal_create(
137137
store=store,
138138
extra_headers=extra_headers,
139139
extra_query=extra_query,
140-
extra_body=merged_extra_body if merged_extra_body else None,
140+
extra_body=merged_extra_body,
141141
timeout=timeout,
142142
)
143143
data = ChatCompletions(**json.loads(response.text))
@@ -505,7 +505,7 @@ async def stream_create(
505505
store=store,
506506
extra_headers=extra_headers,
507507
extra_query=extra_query,
508-
extra_body=merged_extra_body if merged_extra_body else None,
508+
extra_body=merged_extra_body,
509509
timeout=timeout,
510510
)
511511

@@ -547,7 +547,7 @@ async def normal_create(
547547
store=store,
548548
extra_headers=extra_headers,
549549
extra_query=extra_query,
550-
extra_body=merged_extra_body if merged_extra_body else None,
550+
extra_body=merged_extra_body,
551551
timeout=timeout,
552552
)
553553
data = ChatCompletions(**json.loads(response.text))

portkey_ai/api_resources/apis/complete.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def stream_create( # type: ignore[return]
6565
stream_options=stream_options,
6666
extra_headers=extra_headers,
6767
extra_query=extra_query,
68-
extra_body=merged_extra_body if merged_extra_body else None,
68+
extra_body=merged_extra_body,
6969
timeout=timeout,
7070
)
7171

@@ -117,7 +117,7 @@ def normal_create(
117117
stream_options=stream_options,
118118
extra_headers=extra_headers,
119119
extra_query=extra_query,
120-
extra_body=merged_extra_body if merged_extra_body else None,
120+
extra_body=merged_extra_body,
121121
timeout=timeout,
122122
)
123123
data = TextCompletion(**json.loads(response.text))
@@ -248,7 +248,7 @@ async def stream_create(
248248
stream_options=stream_options,
249249
extra_headers=extra_headers,
250250
extra_query=extra_query,
251-
extra_body=merged_extra_body if merged_extra_body else None,
251+
extra_body=merged_extra_body,
252252
timeout=timeout,
253253
)
254254

@@ -300,7 +300,7 @@ async def normal_create(
300300
stream_options=stream_options,
301301
extra_headers=extra_headers,
302302
extra_query=extra_query,
303-
extra_body=merged_extra_body if merged_extra_body else None,
303+
extra_body=merged_extra_body,
304304
timeout=timeout,
305305
)
306306
data = TextCompletion(**json.loads(response.text))

0 commit comments

Comments
 (0)