Skip to content

Fix Open AI await response #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

frankong
Copy link

@frankong frankong commented Apr 6, 2025

Getting
TypeError: object tuple can't be used in 'await' expression when using AsyncOpenAI with streaming responses.

The error is from the await self._client._ph_client.capture( line because capture is not an asynchronous function.

Removing the await fixes this

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Fixes the TypeError by removing an unnecessary await on the synchronous capture call in WrappedResponses within posthog/ai/openai/openai_async.py, though a similar issue remains in WrappedCompletions.

  • Removed await from capture in /posthog/ai/openai/openai_async.py’s WrappedResponses._capture_streaming_event.
  • Noted that await is still used in WrappedCompletions._capture_streaming_event, which may trigger similar errors.
  • Suggest verifying consistency and testing streaming completions again.

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant