-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
When using the PostHog AsyncOpenAI client (from posthog.ai.openai import AsyncOpenAI) with streaming=True in self.client.chat.completions.create(), the following error occurs:
File "/usr/local/lib/python3.12/site-packages/posthog/ai/openai/openai_async.py", line 308, in async_generator
await self._capture_streaming_event(
File "/usr/local/lib/python3.12/site-packages/posthog/ai/openai/openai_async.py", line 370, in _capture_streaming_event
await self._client._ph_client.capture(
TypeError: object tuple can't be used in 'await' expression
It seems like the file contains two separate cases where self._client._ph_client.capture is awaited (and one where it isn't) even though the method is synchronous, not asynchronous. I've cross-checked this with AsyncAnthropic where the same method is correctly not being awaited.
Unless I'm missing something, removing the two awaits in posthog/ai/openai/openai_async.py should fix the issue.
Metadata
Metadata
Assignees
Labels
No labels