Skip to content

Commit 492f2ca

Browse files
pcbeingused333claude
authored andcommitted
fix(ai): pass the stream error to StreamingEventData directly and update the API snapshot
mypy 1.16 rejected splatting {"error": error} into StreamingEventData(...) (typeddict-item). The field accepts None and capture_streaming_event reads it with .get(), so pass error=error. Regenerate the public API snapshot for the new StreamingEventData.error field. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent bc83070 commit 492f2ca

5 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎posthog/ai/anthropic/anthropic.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def _capture_streaming_event(
258258
privacy_mode=posthog_privacy_mode,
259259
groups=posthog_groups,
260260
stop_reason=stop_reason,
261-
**({"error": error} if error is not None else {}),
261+
error=error,
262262
)
263263

264264
# Use the common capture function

‎posthog/ai/anthropic/anthropic_async.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ async def _capture_streaming_event(
258258
privacy_mode=posthog_privacy_mode,
259259
groups=posthog_groups,
260260
stop_reason=stop_reason,
261-
**({"error": error} if error is not None else {}),
261+
error=error,
262262
)
263263

264264
# Use the common capture function

‎posthog/ai/gemini/_shared.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def _capture_streaming_event(
223223
privacy_mode=privacy_mode,
224224
groups=groups,
225225
stop_reason=stop_reason,
226-
**({"error": error} if error is not None else {}),
226+
error=error,
227227
)
228228
capture_streaming_event(self._ph_client, event_data)
229229

‎posthog/ai/openai/_streaming.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ def _build_streaming_event_data(
122122
groups=groups,
123123
stop_reason=stop_reason,
124124
service_tier=service_tier,
125-
**({"error": error} if error is not None else {}),
125+
error=error,
126126
)

‎references/public_api_snapshot.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ attribute posthog.ai.types.StreamingContentBlock.thinking: Optional[str]
623623
attribute posthog.ai.types.StreamingContentBlock.type: str
624624
attribute posthog.ai.types.StreamingEventData.base_url: str
625625
attribute posthog.ai.types.StreamingEventData.distinct_id: Optional[str]
626+
attribute posthog.ai.types.StreamingEventData.error: NotRequired[Optional[BaseException]]
626627
attribute posthog.ai.types.StreamingEventData.formatted_input: Any
627628
attribute posthog.ai.types.StreamingEventData.formatted_output: Any
628629
attribute posthog.ai.types.StreamingEventData.groups: Optional[Dict[str, Any]]

0 commit comments

Comments
 (0)