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

feat(client): add async api client #1102

Merged
merged 1 commit into from
Feb 5, 2025
Merged

feat(client): add async api client #1102

merged 1 commit into from
Feb 5, 2025

Conversation

hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Feb 5, 2025

Important

Add asynchronous API client AsyncFernLangfuse to Langfuse class for non-blocking operations.

  • Behavior:
    • Add AsyncFernLangfuse to Langfuse class in client.py for asynchronous API operations.
    • Initialize async_public_api_client in Langfuse.__init__() and assign to self.async_api.
  • Imports:
    • Import AsyncFernLangfuse from langfuse.api.client.

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

Greptile Summary

Disclaimer: Experimental PR review

Added asynchronous API client capabilities to the Langfuse Python SDK while maintaining backward compatibility with the existing synchronous client.

  • Added AsyncFernLangfuse client in /langfuse/client.py for non-blocking API calls
  • Preserved existing synchronous client as self.api and legacy self.client for backward compatibility
  • Added self.async_api property to access new async client functionality
  • Maintained consistent timeout and authentication handling between sync/async clients

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.

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

Comment on lines +302 to +310
async_public_api_client = AsyncFernLangfuse(
base_url=self.base_url,
username=public_key,
password=secret_key,
x_langfuse_sdk_name="python",
x_langfuse_sdk_version=version,
x_langfuse_public_key=public_key,
timeout=timeout,
)
Copy link

Choose a reason for hiding this comment

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

logic: The async client is instantiated without an httpx_client, while the sync client uses the shared httpx_client. This could lead to connection pooling issues since the async client will create its own connection pool.

@hassiebp hassiebp merged commit ed4f2e3 into main Feb 5, 2025
7 of 10 checks passed
@hassiebp hassiebp deleted the add-async-api branch February 5, 2025 14:43
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