python-codex 0.6.3__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,9 +25,13 @@ class OutcommingChatError(RuntimeError):
25
25
  self,
26
26
  message: "str",
27
27
  error_type: "typing.Union[str, None]" = None,
28
+ http_status: "typing.Union[int, None]" = None,
29
+ error_code: "typing.Union[str, None]" = None,
28
30
  ) -> "None":
29
31
  super().__init__(message)
30
32
  self.error_type = error_type
33
+ self.http_status = http_status
34
+ self.error_code = error_code
31
35
 
32
36
 
33
37
  class OutcommingTransport:
@@ -120,7 +124,7 @@ class OutcommingTransport:
120
124
  yield payload
121
125
  if not saw_done:
122
126
  raise OutcommingChatError(
123
- "outcomming chat stream ended before [DONE]"
127
+ "outcomming chat stream ended before [DONE]", error_code="502",
124
128
  )
125
129
  except (
126
130
  ConnectionError,
@@ -139,7 +143,8 @@ class OutcommingTransport:
139
143
  progress["phase"] = "reading_error_body"
140
144
  body = exc.read().decode("utf-8", errors="replace")
141
145
  raise OutcommingChatError(
142
- f"outcomming chat request failed with status {exc.code}: {body[:500]}"
146
+ f"outcomming chat request failed with status {exc.code}: {body[:500]}",
147
+ http_status=exc.code,
143
148
  ) from exc
144
149
  except TimeoutError as exc:
145
150
  raise OutcommingChatError(
@@ -219,7 +224,7 @@ class OutcommingTransport:
219
224
  if not finished:
220
225
  terminal = "finishReason" if api == "gemini" else "message_stop"
221
226
  raise OutcommingChatError(
222
- f"outcomming {api} stream ended before `{terminal}`"
227
+ f"outcomming {api} stream ended before `{terminal}`", error_code="502",
223
228
  )
224
229
  if api == "gemini":
225
230
  yield gemini_continuation_chunk(stream_state)
@@ -246,7 +251,8 @@ class OutcommingTransport:
246
251
  progress["phase"] = "reading_error_body"
247
252
  body = exc.read().decode("utf-8", errors="replace")
248
253
  raise OutcommingChatError(
249
- f"outcomming {api} request failed with status {exc.code}: {body[:500]}"
254
+ f"outcomming {api} request failed with status {exc.code}: {body[:500]}",
255
+ http_status=exc.code,
250
256
  ) from exc
251
257
  except TimeoutError as exc:
252
258
  raise OutcommingChatError(
@@ -338,7 +344,8 @@ class OutcommingTransport:
338
344
  progress["phase"] = "reading_error_body"
339
345
  body = exc.read().decode("utf-8", errors="replace")
340
346
  raise OutcommingChatError(
341
- f"outcomming request failed with status {exc.code}: {body[:500]}"
347
+ f"outcomming request failed with status {exc.code}: {body[:500]}",
348
+ http_status=exc.code,
342
349
  ) from exc
343
350
  except TimeoutError as exc:
344
351
  raise OutcommingChatError(