Skip to content
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

fix(openai): implement aclose on async stream responses #1112

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Feb 12, 2025

Greptile Summary

Disclaimer: Experimental PR review

Added aclose method to LangfuseResponseGeneratorAsync class to properly handle cleanup of async streaming responses from OpenAI.

  • Added aclose method in /langfuse/openai.py to mirror existing close functionality for async streams
  • Method delegates to underlying response's aclose method to ensure proper resource cleanup
  • Maintains compatibility with OpenAI's async streaming API patterns
  • Addresses potential resource leaks when using async streaming responses

Important

Adds aclose() method to LangfuseResponseGeneratorAsync in langfuse/openai.py for closing async stream responses.

  • Behavior:
    • Adds aclose() method to LangfuseResponseGeneratorAsync in langfuse/openai.py to close async stream responses.
    • Ensures connection release when response body is read to completion in async contexts.

This description was created by Ellipsis for beb1d98. It will automatically update as commits are pushed.

Copy link

@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.

LGTM

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

@hassiebp hassiebp merged commit ab79710 into main Feb 12, 2025
10 checks passed
@hassiebp hassiebp deleted the hassieb/lfe-3861-fix-openai-aclose branch February 12, 2025 21:02
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.

bug: OpenAI streaming structured output causes AttributeError in Python/FastAPI
1 participant