Skip to content

Commit 148f7d8

Browse files
committed
Revert "Enable streaming on o1 since it's now supported"
This was done too soon, as non-preview o1 doesn't support streaming at the moment This reverts commit 3badc07.
1 parent 64f7303 commit 148f7d8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/gptcmd/llm/openai.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def _estimate_cost_in_cents(
157157
+ Decimal(sampled_tokens) * sampled_scale
158158
) * Decimal("100")
159159

160+
def _supports_streaming(self) -> bool:
161+
return not self.model.startswith("o1")
162+
160163
def complete(self, messages: Sequence[Message]) -> LLMResponse:
161164
kwargs = {
162165
"model": self.model,
@@ -228,11 +231,16 @@ def validate_api_params(self, params):
228231

229232
@property
230233
def stream(self) -> bool:
231-
return self._stream
234+
return self._supports_streaming() and self._stream
232235

233236
@stream.setter
234237
def stream(self, val: bool):
235-
self._stream = val
238+
if not self._supports_streaming():
239+
raise NotImplementedError(
240+
"Streamed responses are not supported by this model"
241+
)
242+
else:
243+
self._stream = val
236244

237245
@property
238246
def valid_models(self) -> Iterable[str]:

0 commit comments

Comments
 (0)